Home  >  Article  >  Backend Development  >  php discuz 主题表和回帖表的设计_PHP

php discuz 主题表和回帖表的设计_PHP

WBOY
WBOYOriginal
2016-06-01 12:23:37743browse

以下内容仅摘录部分:
如果由我们来设计主题表和回帖表,通常的做法是如下。

       这样在获取主题列表时,直接使用分页算法提取Topics;查看某一帖子时,还需要对Topics,Posts进行jion链接。

此种设计的缺陷为:
1. Topics表存储Content的内容,其体积将会很大,对大体积表进行分页,性能很慢。
2. 显示Posts内容时将进行join操作,损耗性能

而Discuz的做法是进行如下设计。

       将Topics里的Content拆分到Posts中去,同时Topics的主题帖也作为回帖放置到Posts里面,这样就解决了上面我们提出的两个问题。这是典型的违反数据库设计范式以换取更好性能的示例。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn