对不同数据库条目的注释
例如,我有“新闻”和“文章”表,我想使用“评论”表评论这些条目。
建立关系和评论不同条目的最佳方式是什么?
For example, I have "news" and "articles" tables and I want comment these entries using "comments" table.
What the best way to make relationship and comment different entries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
我假设新闻和文章到评论都是一对多的。我还假设相同的评论不能同时关联到新文章和文章。
其中一种方法是:
优点是架构标准化,数据完整性得到正确维护,并且允许模式演变。例如,将来可能有可能为另一种类似的实体添加评论(例如允许为博客表添加评论)。
缺点是查询新闻或文章的评论时需要额外加入表
I assume both news and articles to comments are one-to-many . And I also assume the same comment cannot associate to a new and an article at the same time.
One of the way is that:
Advantages is that the Schema is normalized ,data integrity is properly maintained and it allows for schema evolution. For example , there may be possibility to add the comment for another similar kind of entity in the future (eg Allow adding comments for the blog table).
Disadvantages is that it requires join extra table when query the comments for a news or articles