SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: How is the 'friends' table in Facebook constructed?

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2004
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How is the 'friends' table in Facebook constructed?

    Hi all,

    does anyone know how facebook makes it possible to organise all these related friends. Millions of people are on Facebook, and they all have about 50 friends on average. How do they construct the database?

    Any tricks on managing these enormous amounts?

    Kind regards,
    M

  2. #2
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a many-to-many relationship created by a `user_friends` table. i would imagine the user_friends table having field such as `user1`, `user2`, and then properties of the relationship such as `status`, `created_on`, and any more they might have.

    of course, this is all speculation, no one knows for sure, and if they do, they won't be posting the answer here on sitepoint.

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i forgot to mention that the trick is not in designing the database, but rather optimizing the queries. the data is all there, finding the best way to pick it out is what might be a little bit harder for some people.

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2004
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So there's no magic in it, I guess, except for smart querying off course? Not even with millions and millions of rows? Because I can't imagina the size of the many2many table with the relationships.

  5. #5
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Databases are designed to have huge amounts of data in them. If you use proper indexing and decent enough queries, it shouldn't be a problem.

  6. #6
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    982
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think the magic is in the table schema. It probably all rests in the hardware and configurations
    MySQL v5.1.58
    PHP v5.3.6

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •