I have a basic comment table with Id,Username,Comment, Date-time as the fields ..I need to add a reply table to this there a person can reply to the corresponding comment and then another person can reply to that reply and etc etc .Thank you in advance.
asked Dec 14, 2012 at 07:52 PM in Default
I would do it by keeping the replies in the Comment table, but having a separate table to link the Comments, thus:
So that if Comment 47 is a response to Comment 13, then there'll be a record in the ReplyTo table:
This has the advantage of being small, and not requiring multiple organisations for storing the same sort of information, as well as not affecting any existing systems.
answered Dec 14, 2012 at 09:16 PM
Though Thomas Rushton already provided a good solution, I'd suggest adding just a new column, InReplyToCommentID in the comments table. Then you have both comments, replies and their relation all in the same table. When you want to find all first Level comments you'll just need to query for comments with InReplyToCommentID being null, with no need to involve a second table. Unless a reply can be related to more than one comment, I think it's a simpler, more efficient solution.
answered Dec 17, 2012 at 02:28 PM