Jump to content

Archived

This topic is now archived and is closed to further replies.

kobel4k3r5

making a friends list

Recommended Posts

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

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.