开发者

Database scheme design social networking sites

Hi I am planning to design a social networking site (like开发者_如何转开发 orkut) asp.net mvc.I am stuck in database design.Anyone provide me the resource for that one.


These are the steps you should follow for initial database design.

First, list down all the "objects" you want to store, such as users, posts, relationships and so on.

Second, figure out, for each of those, what information you want to store (user name, password, full name, address, ...).

Then design your database tables following the third normal form.

  1. Every column in a table should be an attribute of the key.
  2. Every column in a table should be an attribute of the entire key.
  3. Every column in a table should be an attribute of only the key.

Database design should always be done in third normal form, reverting to other forms if there is a performance problem and you understand the ramifications of reversion. You can generally do this safely (and efficiently) with the proper application of computed fields or triggers.

As an example, one thing you should not do is to try and model relationships in the users table. A row in that table will have the user name as the key and a relationship depends on two user names, so that would violate rule 3.


Barry Williams hosts a library of free data models, which he offers as starting points for all sorts of applications. His portfolio includes a suggested model for a social networking site; that page also includes links to some supporting information. Find out more.


You can figure out the fields/queries and everything else, but the basic tables are very simple:

  • User Table
    Stores the User's Login/Password/Access Information
  • User Info Table
    Stores the any additional data that the user might enter (Full Name, Birthday, etc)
  • Relationship Table
    Stores the relationships between user A and User B
  • Post Table
    Depending on what type of media your users will be posting in, this gives a list of all the messages posted, with a User ID attached

That is the basis of it and this layout is probably sufficent enough to mock Twitter (which is a very simple site).

Anything additional you should probably use your brain to figure out. It really isn't that hard. Facebook didn't become popular for creating a good database schema.


There will be two main tables for user module i.e.

  1. tblUser(userId(P key), other detail columns)
  2. tblContacts(UserId(F key from tbluser),ContactId(F key from tbluser) and both userid and contactid will be primary key, ie. composite key)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜