views:

585

answers:

5

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.

Thanks in Advance.

A: 

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.

Chacha102
+2  A: 

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.

paxdiablo
+1  A: 

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.

APC
A: 

HI I am also designing a site like this and would like to know if the relationship tables would be a good way to go. A site like facebook has 500 million users so the relationship table must be at least 150 times that. If you had to search for friends it would take a very long time. So Im guessing that each user either has his own table of friends or a csv file associated with them with a list of their friends. Any help with this would be very helpful to my design. Thank You..

Dom
A: 

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 mean to say composite key)

Pankaj Kaushik