Jump to content

Recommended Posts

I can elaborate if necessary but this should be pretty straightforward.

 

The site I am coding has a membership system of course.  I would like to create associations between members, basically what one might call a friend's list.  But I am not sure how to create this table of relationships.  I do not want to have a table for every member to store each of their 'friends'.  I am not sure about a table with each row being a particular member with their username as the index.  Each column could be a friend but if someone has 200 friends then someone with only 3 would end up with 197 blank fields.  And it seems to be a logistical nightmare to have to deal with the random number of friends that might be listed in each user's row.

 

I am curious if there are any better ideas of how to achieve storing such information.

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/220658-table-structure-ideas/
Share on other sites

Should be straight-forward:

 

members (member_id)

friends (member_id, friend_id, status)

 

It should also be noted it works in both ways: if you and a friend both state you are friends then he will not only appear on your profile but also you will appear on his.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.