Facebook 数据库设计...为什么要有个人资料表?
见下图
既然 1 个帐户有 1 个个人资料关系,为什么要有个人资料表?除了存储状态之外,配置文件表的用途是什么。为什么不在帐户表中包含状态并从“帐户”表与基本信息、个人信息等建立直接关系。
See image below
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您在将来的某个时间更改模型,以便一个帐户可以拥有多个配置文件,那么使用两张表比只使用一张表要好得多。
关于连接的成本,您需要对其进行量化,并确定哪些地方不值得担心速度差异。过度担心连接会减慢速度是关系数据库新手最常见的错误之一。
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.
一些想法和有根据的猜测。
和配置文件是两个不同的
事物。
帐户表使该表更宽
并且速度较慢。
最近的帖子(是吗?),
桌子可以单独放置
表空间,可能在一个疯狂的
用于快速查找的快速磁盘阵列。
比任何事情都更常见
账户表。
许多第三方应用程序可能是
允许访问您的状态,但是
他们不一定有
访问您的电子邮件地址以及
密码。物理隔离(单独的表)显然很容易做到正确。
Some ideas and educated guesses.
and a profile are two different
things.
account table makes that table wider
and slower.
recent post (is that right?), that
table can be put on a separate
tablespace, probably on an insanely
fast disk array for fast lookups.
more often than anything in the
account table.
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.
我想这是因为并非每个帐户都有与之关联的个人资料。即关系实际上是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.
这只是一个抽象的问题。
帐户中包含个人资料数据。因此,它有一个配置文件的实例(表)。
这样您就可以单独访问个人资料数据,并且将来可能会向帐户添加更多数据。
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.