Based Database design for Highspeed Query
Posted on 2011-05-02
i am looking for some design help on how to design my tables in a db to achive the folowing.
Lets say my App has users and each user can have on or 1 mio friends. How do i establish and manage these relationships effectively ? My first Idea is to create a Table and lets say call it friendship, then the table would have 2 columns one would be the owner ( who has the friends) and the second one would be friend (the user who he is friend with) now for every friend i create a row. To find all friends of that user i would just query where owner = userid ..
that will work fine but not sure if you have lets say 100000 users and each has between 50 and 250 or more friends that this is the best way to go. So any idea would be great