Jump to content


making a friends list

  • Please log in to reply
2 replies to this topic

#1 kobel4k3r5

  • Members
  • PipPip
  • Member
  • 11 posts

Posted 15 September 2006 - 04:19 AM

how would i go making a friends list? i have somewhat of a way in mind but I'm not sure if this way will be efficient. it would use each row as a user, and each row will have lots of columns and some of the columns will be buddyid1, id2, etc..

#2 btherl

  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 15 September 2006 - 08:43 AM

A better structure is to have one row for each friend relationship.  You'll need 2 tables.

The first table will store the user's name, user id and other data (password, name, etc etc).

The second table will have two columns, "id1" and "id2".  A row in that table means "id2 is a friend of id1".

The problem with using columns is that you don't know how many columns you need.  Rows make life much easier :)

#3 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 15 September 2006 - 12:41 PM

And more than that, good luck counting how many friends someone has if you have to count non-NULL columns... ugh.  Any duplicity in rows/columns is bad.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users