Take the 2-minute tour ×

Suppose that we have a web site where each person has a profile and other people write comments to the persons profile. (like the wall in facebook). What is the best way to store the comments made for a person ? I was thinking like a relational database type of thing where there will be a field to hold all the comments for a person in the form of a long string separated with some kind of delimiter but I am not sure if this is the best way. Any ideas ?

share|improve this question
Why don't you use a CMS or some kind of blogging system? –  kapep Dec 16 '11 at 17:21
Hmm never thought about that. I guess you mean something like Drupal then? Do you know if Drupal will allow me to create a web site where each person can create their own profile ? –  Cemre Dec 16 '11 at 17:26
Yes, user accounts and comments are build-in in drupal, profile pages the user can edit are possible with some modules, maybe this one. I think especially drupal is quite good for such sites, as it doesn't has a strict frontend-backend distinction. Great if you want to build social sites with user provided content. –  kapep Dec 16 '11 at 18:09
add comment

3 Answers

up vote 0 down vote accepted

You'll have two separate tables one for Users one for Comments, all the entries having their unique IDs, schema would go like:

Users (ID, name, mail, etc)
Comments (ID, for, from, time, content, etc)

Where for and from fields are User IDs.

share|improve this answer
add comment

The problem with Relational databases is that they do not scale well to super massive social networking sites. When your table starts to get huge the queries will start to take more and more time. If your site is going to be pretty small then a relational database is fine. I think that you may want to investigate "NoSql" databases.

Start here: http://nosql-database.org/

share|improve this answer
add comment

postgresql, mysql, sqlite or even leveldb if you want simple key value store. There's a lot of tutorials out there to get started with any of them.

share|improve this answer
Thanks but my main question is if the simple key value store is the best way to store the comments on a profile (same as storing the comments for a video on a youtube). What is the most efficient way to do it ? –  Cemre Dec 16 '11 at 17:24
Well, when you need relational data, use relational databases. When you need simple lookups, use key value stores. A comment system is fine using a key value store, but once you start wanting to make relational queries like "Give me all the comments on X day and by Y user", you're going to live easier if you started with relational data. Relational databases work fine as key value stores too for most common tasks so I'd say it's the best bet. –  Jazz Man Dec 16 '11 at 18:09
add comment

Your Answer


