christophermichael Posted December 4, 2010 Share Posted December 4, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/220658-table-structure-ideas/ Share on other sites More sharing options...
ignace Posted December 4, 2010 Share Posted December 4, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/220658-table-structure-ideas/#findComment-1142938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.