Click to See Complete Forum and Search --> : Social Network DB Schema


mididelight
12-11-2007, 09:28 AM
Hey now,

I 'm looking to add a Friends section to my website, right now I have built the user sign up / management myself and it works great. Now I want my users to be able to make friends with each other.

I was thinking of creating a new table called my_friends but I'm not sure how the table should be setup. Should I just have a column for user_id and then friends_id and thats how the users are associated?

I'm not really sure, does anyone have any tips for me?

Seth

chazzy
12-11-2007, 10:27 PM
i guess it all depends on what makes up the relationship. if the relationship is just one person is friends with another and that's it (no differentiation about the initiator or any other data about the relationship) then that should be enough.

mididelight
12-11-2007, 11:38 PM
Actually the relationship would be 1 person to many friends. I was thinking the table would be something like this:

user_id | friend_id
-------------------
1 | 34
1 | 61
2 | 4
1 | 2


Does that sound correct?

chazzy
12-12-2007, 06:12 AM
Sure. It all depends on what your final outcome is. I was pointing out, do you need to worry about bidirectional friendships?

mididelight
12-12-2007, 11:08 AM
What does bidirectional friendships mean?