一张大桌子或多张小桌子

发布于 2024-12-04 17:45:40 字数 419 浏览 1 评论 0原文

我正在开发一个网站(基于 WordPress MU)。在这个网站中,用户可以创建自己的博客,可以完全定制自己的博客(更改背景,写文章......),添加更多用户到他们的博客......

最常见的查询是获取博客的文章。 2个不同的博客几乎不相关。

博客的信息可以通过两种方式存储在数据库中:

  1. 几个包含所有信息的表,每个博客都被标识 通过 blog_id。
  2. 许多组的桌子。每组表包含一个博客的所有信息。更多博客,创建更多表格。

我的问题是:

  1. 就性能而言,哪一个更好?
  2. WordPress实际上使用的是第二种设计。如果博客数量 非常大(数千)那么表的数量可以是 数十 数千。这会导致任何问题吗?有限制吗 的 MySQL数据库有多少张表?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

桃扇骨 2024-12-11 17:45:40

选择选项 #1 - 它称为标准化

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

‘画卷フ 2024-12-11 17:45:40

为了代码的可维护性,我请求您选择选项 1。

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

后来的我们 2024-12-11 17:45:40
  1. 考虑到适当的索引,它们的性能应该非常相似
  2. 管理大量表会出现更多问题,尤其是在架构更改的情况下
  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
面如桃花 2024-12-11 17:45:40

我做了一些搜索,我想我经常看到人们说他们更喜欢一张包含许多数据的表而不是许多表。他们说这样更容易维护。

以下是数据库规范化的一些文本:

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

祝你好运!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文