English 中文(简体)
A. 论坛的正常数据库结构
原标题:Normalized database structure for a forum

论坛数据库的共同正常结构是将所有员额储存在一栏界定校对号码的表格中。 为了显示校对,我们需要执行<代码>SlectT>和关于校对编号(日期待定)的条款。 在这种情况下,我们处理的是每个问题的一个很长的表。

是否真正是储存职位和为论坛铺面的最佳途径?

比较复杂的是Q&A 如同股票交换项目,除了回答(即与论坛员额相同)外,每个答案都可以有评论意见。

大型网站,如 st流,最有效率的数据库结构是什么?

最佳回答

其规模远不如SO,但在我的申请中,模式一的工作是每个职位都有。

  • a FK to its parent post (root posts have null in this column)
  • a FK to the root post (root posts have their own ID in this column, which is a bit awkward to insert new root posts, but helps for queries)
  • a FK to their forum

这使人很容易获得治疗。

  • the root posts of a forum (searching for posts with a null parent)
  • all the messages in a thread at once (searching all the posts having a given root)
  • presenting the thread in flat mode (per date) or in tree mode (since each post knows its parent)
  • the last posts in a given forum (searching the latest post grouped by forum)
问题回答

更快捷的查询方式是三氯三苯和三氯三联苯。 例如,你可以使用透镜来建造一个配有额外左翼的隔热室,并为被nes的 set点打上正确的门。 复杂的是,从这一树中添加或删除。 或者,你可以带一把 has子去寻找左边和右边。 但是,我认为,单靠宽松的一套可能已经足够了,因为这样,那套补贴就没有秩序。

如果你们接受论坛是另一种形式的树种结构,我建议设置nes块或关闭表,以建立职位之间的关系。 nested set .closure table - could-sorry!

Simply storing thread and parent id s can make things a little tricky...





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签