I have got a comment script written in PHP working pretty well. It saves the comments in a a mysql comments table with fields for commentid, subjectid, userid and timecreated.
I now want to implement a reply function. Should I create a new table of replies with userid, time created, reply and a commentid field.
Or would it be better to just include the replies in the comments table as comments but with two extra fields, one denoting that this particular comment is a reply and the other the comment it is a reply to.
Leaning toward first option but it means extra queries.
Would appreciate any suggestions from those with experience!
I would add two columns for
referenceid, andparentid. That way, you can have nested comments, if you so choose. Much easier and more efficient than joining multiple tables in your queries. If the comment is not a reply,referenceidis 0 (or null). No need to create another column to flag whether it’s a reply.