已关闭,此问题为opinion-based。它目前不接受回答。
**想改善这个问题吗?**更新问题,以便editing this post可以用事实和引用来回答。
17天前关闭
Improve this question
我有一个网站,用户可以评论帖子或回复评论。用户也可以喜欢回复或评论。但是,在应答表中还有另一个名为reply_to的字段。以下是我当前的schema:
Comment
id
user (foreign key)
post (foreign key)
comment
Reply
id
user (foreign key)
reply_to (who the user is replying to)
comment (foreign key)
reply
CommentLike (Table that shows which user liked which comments)
id
comment (foreign key)
user (foreign key)
like (1 = likes, 0 = dislikes)
ReplyLike (Table that shows which user liked which replies)
id
reply (foreign key)
user (foreign key)
like (1 = likes, 0 = dislikes)
这看起来像是一个很好的模式,或者有更好的方法来创建这种结构吗?
1条答案
按热度按时间qjp7pelc1#
我建议的结构如下,只有两个表:
reply
本身就是一个comment
,只是父注解的子注解。因此,我不会把它作为一个单独的实体。ON DELETE CASCADE
来实现这一点。