SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wanting to create a "buddy list" script...

    Okay, so I am wanting to create a script, and the best way I can think is to call it a buddy list.

    I have no problems with any aspect, except for saying who is who's buddy. What would be the best way to accomplish this? One person cannot be a friend of another, without the other being a friend of that person...

    I can't quite think of how I would link them together. I first thought of like another table called friends which had USER_ID and FRIEND_ID... then just get all FRIEND_IDs for the current USER_ID... however, if user's 1 and 2 were friends.. in that table I would have
    USER_ID = 1
    FRIEND_ID = 2

    USER_ID = 2
    FRIEND_ID = 1

    that seems rather redundant and surely there must be a better way. I think basically all IM programs accomplish this because I think each person has to be on each other's lists... so how can I cross reference the two user ids that they are FRIENDS OF EACH OTHER??

    I hope I explained that well enough... what im thinking is hard to write down hehe..

    Thanks in advance!

  2. #2
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *bump* anyone?

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    please don't bump

    if you put me on your buddy list, that doesn't mean i have to pu you on mine

    therefore, in most systems, "buddy" is a unidirectional relationship

    the way to store the data is just as you suggested, a separate table with user_id and buddy_id

    the difference is that if you store (34,61) this does not mean you have to store (61,34) as well

    make sense?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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