If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Social Network DB Schema

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-11-07, 16:09
redonkulus redonkulus is offline
Registered User
 
Join Date: Dec 2007
Posts: 2
Social Network DB Schema

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?

-r
Reply With Quote
  #2 (permalink)  
Old 12-11-07, 16:38
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
I reckon your idea sounds fine... But...

If I have you as my friend, does that instantly make me your friend?
Code:
SELECT user_id
     , friend_id
FROM    my_friends
WHERE  <my user id> IN (user_id, friend_id)
If so the above will catch it.
If not simply change the where clause to read
Code:
WHERE  <my user id> = friend_id
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 12-11-07, 18:47
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Now I want my users to be able to make friends with each other ... Should I just have a column for user_id and then friends_id
If only life was that simple
Reply With Quote
  #4 (permalink)  
Old 12-12-07, 15:41
redonkulus redonkulus is offline
Registered User
 
Join Date: Dec 2007
Posts: 2
Hmm good question. I would think that you ask the person to be your friend and then they accept. Therefore, each person shows up as a friend of the other.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On