We allow commenting on our website (like a blog). Now we want to change it so that people can comment other comments.
Our table looks something like this:
ID | CommentID | Comment | User | Date
-------------------------------------------------------------------------
1001 | 1 | Nice site | Me | 20.01.2010
1001 | 2 | Thx! | You | 21.01.2010
I came up with two options:
1) Create a ParentCommentID and with that decide how the comments are listed from top to bottom.
2) Store the comment you’re commenting together with your own comment with some [QUOTE]-tags or something.
Any good tips to solving this?
I would go with a
ParentCommentIDthat acts as a foreign key back to that table’sCommentID. That will enforce referential integrity, and you’ll avoid some duplication.If ten people quote a comment, it is replicated ten times with option 2. In option one, you only have ten FKs.
The more characters you allow in a single comment, the more duplication you’ll have per quote with option 2.
Option 1 also allows you to do more reporting. You can more easily query to find out which comments are quoted the most often.