Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006

    members and friends (was "Design Question")

    Say I have 10000 + members in my database

    Each member could have 0 - 10000 friends.

    What is the best way to store this information
    I can create a table called "friends"

    Then when someone adds a friend, his and the friends name is added to the database.

    Then I could do a sql search to find the user and his friends....

    But when he has 200 friends, his name would be added to the database 200 times with a different friend in each row. I could return all these friends easily, but the problem is. I don't think it would be effective haven't the same user with a different friend listed 200 times.
    It just doesn't seem like practical database design to me.

    Can anyone give me some advice?

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    the method you have described (a table with 2 ids, the user and the friend) is the "best practice" design

    yes, this will result in rows that look like this

    100 212
    100 331
    100 352
    100 756
    200 175
    200 823

    but this is actually fully normalized and the simplest and most efficient way to do it | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2006
    thank you alot!

Posting Permissions

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