开发者

Facebook database design...why have a profile table?

See image below

Facebook database design...why have a profile table?

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 relati开发者_如何学Conship from the "account" table to BasicInformation, PersonalInformation etc.

http://i.stack.imgur.com/u7GKB.jpg


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.

  • 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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜