问题描述
我有一个用php写的评论脚本。它保存在一个mysql注释表中包含commentid,subjectid,userid和timecreated字段的注释。
现在我想实现一个回复函数。我应该使用userid,时间创建,回复和一个commentid字段创建一个新的回复表。
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.
倾向于第一个选项,
感谢那些有经验的人的任何建议!我会为 referenceid
添加两列,并且
Would appreciate any suggestions from those with experience! Thx.
推荐答案
code> parentid 。这样,你可以有嵌套的注释,如果你这样选择。比在查询中加入多个表格更简单,更高效。如果注释不是回复, referenceid
为0(或null)。无需创建另一列来标记是否为回复。
I would add two columns for referenceid
, and parentid
. 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, referenceid
is 0 (or null). No need to create another column to flag whether it's a reply.
这篇关于PHP / MYSQL注释 - 回复表结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!