开发者

One big table or many small tables

开发者 https://www.devze.com 2023-04-05 02:32 出处:网络
I am developing a website (WordPress MU - based). In this website, users can create their own blogs, can fully customize their own blogs (change background, write articles...), add more users to their

I am developing a website (WordPress MU - based). In this website, users can create their own blogs, can fully customize their own blogs (change background, write articles...), add more users to their blogs...

The most common query is to get articles of a blog. 2 different 开发者_开发技巧blogs are almost not related.

The information of the blogs can be stored in database in 2 ways:

  1. A few tables containing all the information, each blog is identified by blog_id.
  2. Many groups of tables. Each group of tables contains all information of a blog. More blogs, create more tables.

My questions are:

  1. In term of performance, which one is better?
  2. WordPress actually uses the second design. If the number of blogs is very large (thousands) then the number of tables can be tens of thousands. Does this cause any problem? Is there a limit of number of tables of a MySQL database?


Go for option #1 - it's called normalisation.


For the sake of code maintainability, I beg you to go for option 1.


  1. They should both really perform very similarly, given appropriate indexing
  2. Managing a large number of tables is more problematic, especially with schema changes


I did some searches and I think I saw more often people saying they would prefer one table with many data than many tables. They say it's easier to maintain.

Here is some texts of database normalization :

http://support.microsoft.com/kb/283878
http://www.phlonx.com/resources/nf3/

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消