Facebook 数据库设计...为什么要有个人资料表?

发布于 2024-11-10 13:53:01 字数 282 浏览 4 评论 0原文

见下图 在此处输入图像描述

既然 1 个帐户有 1 个个人资料关系,为什么要有个人资料表?除了存储状态之外,配置文件表的用途是什么。为什么不在帐户表中包含状态并从“帐户”表与基本信息、个人信息等建立直接关系。

https://i.sstatic.net/u7GKB.jpg

See image below
enter image description here

Since 1 account has 1 profile relationship, Why have a profile table? what is the purpose of the profile table, apart from storing the status. Why not include status in the Account table and make a direct relationship from the "account" table to BasicInformation, PersonalInformation etc.

https://i.sstatic.net/u7GKB.jpg

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

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

发布评论

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

评论(4

枫以 2024-11-17 13:53:01

如果您在将来的某个时间更改模型,以便一个帐户可以拥有多个配置文件,那么使用两张表比只使用一张表要好得多。

关于连接的成本,您需要对其进行量化,并确定哪些地方不值得担心速度差异。过度担心连接会减慢速度是关系数据库新手最常见的错误之一。

If, at some future time, you change the model so that one account can have more than one profile, you are much better off with two tables than with just one.

With regard to the cost of joins, you need to quantify that, and decide where a speed difference just isn't worth worrying about. Excessive fear of slowing things down with joins is one of the most common newbie mistakes with relational databases.

淡淡離愁欲言轉身 2024-11-17 13:53:01

一些想法和有根据的猜测。

  • 在概念层面上,一个账户
    和配置文件是两个不同的
    事物。
  • 将个人资料状态添加到
    帐户表使该表更宽
    并且速度较慢。
  • 因为地位只代表你最重要的
    最近的帖子(是吗?),
    桌子可以单独放置
    表空间,可能在一个疯狂的
    用于快速查找的快速磁盘阵列。
  • 状态可能被查找很多
    比任何事情都更常见
    账户表。
  • 安全性更易于管理。
    许多第三方应用程序可能是
    允许访问您的状态,但是
    他们不一定有
    访问您的电子邮件地址以及
    密码。物理隔离(单独的表)显然很容易做到正确。

Some ideas and educated guesses.

  • At the conceptual level, an account
    and a profile are two different
    things.
  • Adding the profile status to the
    account table makes that table wider
    and slower.
  • Since status holds only your most
    recent post (is that right?), that
    table can be put on a separate
    tablespace, probably on an insanely
    fast disk array for fast lookups.
  • Status is probably looked up much
    more often than anything in the
    account table.
  • Security is simpler to administer.
    Lots of third-party apps might be
    allowed access to your status, but
    they shouldn't necessarily have
    access to your email address and
    password. Physical isolation (separate tables) is pretty easy to get obviously right.
若相惜即相离 2024-11-17 13:53:01

我想这是因为并非每个帐户都有与之关联的个人资料。即关系实际上是1:0/1,而不是1:1。

I guess it's because not every Account will have a profile associated with it. i.e. the relationship is actually 1:0/1, not 1:1.

北方。的韩爷 2024-11-17 13:53:01

这只是一个抽象的问题。

帐户中包含个人资料数据。因此,它有一个配置文件的实例(表)。

这样您就可以单独访问个人资料数据,并且将来可能会向帐户添加更多数据。

It's just a matter of abstraction.

An account has profile data in it. So, it has an instance (table) of a profile.

This way you can access profile data seperately, and maybe in the future add more data to the account.

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