[英]insert reference in comment table that joins two sessions (blog and news)
I am finalizing a comments system and was with a doubt. 我正在完成一个评论系统,对此表示怀疑。
I have a table for blogs and one for news, and they accept comments. 我有一个用于博客的表格,一个用于新闻的表格,它们接受评论。
My comments table receives the text and the id. 我的评论表接收文本和ID。 I wonder if I need to (or should I) go through some sort of reference to know where the comment comes from.
我想知道是否需要(或应该)通过某种参考来了解评论的来源。
table comment
id | id_content | text | ref
1 | 1 | test | blog
2 | 1 | test | news
thanks 谢谢
depending on the number of comments you expect to receive there are two ways of doing this ... 根据您希望收到的评论的数量,有两种方法可以执行此操作...
1 - parent_tbl, parent_id - in one big comment table 1-parent_tbl,parent_id-在一个大注释表中
2 - two tables for comments with a parent_id - one for each primary table 2-两张表带有parent_id的注释-每张主表一张
either way you need to index properly, the second will always work faster, but it doesn't expand well if you say add "press_releases" now you have to duplicate code, tables, what not. 无论哪种方式,您都需要正确地建立索引,第二种方式总是可以更快地工作,但是如果您说添加“ press_releases”,它就不能很好地扩展,因为您现在必须复制代码,表,而不能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.