The design of database table structure optimization in multi-page Forum is discussed. I have been imagining a brand new forum in my mind. I would like to discuss with you the "optimization design of the database table structure in multi-page Forum. Raise the question: as a comprehensive idea of a brand-new forum in the near future. I would like to discuss with you the "optimization design of the database table structure in multi-page Forum.
Question:
As a comprehensive forum, the classification of the Forum is inevitable. The structure of the common single-layer multi-version is too simple to implement complicated classification. The multi-level and multi-version structure like phorum can implement any complicated classification (the directory classification structure can be implemented at an unlimited level), but the difficulty is that navigation is neither intuitive nor inconvenient. Therefore, I think that the structure of the common double-layer multi-version on the Internet is reasonable and basically meets the requirements of comprehensive forum classification, it can also easily implement an intuitive and convenient forum navigation interface. The example is www.chinaasp.com's current Forum. This structure has two levels of directories. The top layer is a large category, and the bottom layer is a classification, that is, the specific forum layout. How can we use a database table to implement this structure more efficiently?
Solution 1:
No matter how many pages the forum will have in the future, all the posts will be stored in one table. this table records all the information of a post and the subcategory ID number of the post, assume that this table is called T_articles, and T_columns1 is used to record the information of a category (the name of a category and the ID number of the category ), use t_columns2. to record the information of a small class (the name of a small class, the ID number of a small class, and the ID number of the class to which the small class belongs)
Solution 2:
Create a table for each small class and store all posts of this class in this table. this table records only the information of one post (subject, body, etc ), such tables are represented by T_articles1 and T_articles2. Use T_columns1 to record the category information (the category name and the ID number of the category), and t_columns2. (the category name, ID number, and the ID number of the category to which the category belongs)
Requirements:
1. it is required to facilitate future expansion regardless of major and minor categories;
2. the table structure should be designed to improve the efficiency of database retrieval;
Comparison:
Which of the following is better?
Let's discuss it?
Reposted a reply from a friend of the Jiangnan Forum
Cach was added to programming base camp at 23:51:59
Solution 1 is better to expand the layout, but the disadvantage is that as the number of posts increases, the data volume will increase,
It will take a long time to make a query, and it will be troublesome if the data table has a problem.
But the advantage is that programming is much easier. Now many forums use this solution!
Solution 2 is faster than solution 2, but it may take some time to program!
I think some content should be added in solution 2, that is, adding a field to t_columns2.
The table name of the newly created small class (because Solution 2 is to create a table in a discussion area, these tables are
Dynamic addition, so it is necessary to add a field to store the table name, then you can use this field as a parameter
To generate the corresponding discussion area), the advantage is that the speed is fast, the problem of a discussion area table does not affect
Other discussion areas, so I still think solution 2 is better!
The above is my opinion!
Copyright Statement: The copyright of this post is owned by the submitter cach. the source must be indicated for reposted or resposted on other websites, and reposted by traditional media.
You must contact the original author and the Jiangxi hotline in advance. the comments in this post are purely personal opinions and have nothing to do with the position of this website.
Bytes. I would like to discuss with you the "optimization design of the database table structure in multi-page Forum. Question: As a comprehensive...