Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2007
    Posts
    2

    Unanswered: 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

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

  3. #3
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    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

  4. #4
    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.

Posting Permissions

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