jacko310592 Posted May 3, 2010 Share Posted May 3, 2010 before now, i had my site set up so a new member got a table assigned to him/her for friends and block list, i was told this was a bad idea as it would result in too many tables. this is the layout of the tables which where created: friend_id | accepted | blocked | date ----------------------------------------------------------------- friendID01 | 1 | 0 | 1270923292 ----------------------------------------------------------------- friendID02 | 0 | 1 | 1269465333 (date being the date they where accepted or blocked) would this be a better way of laying out a table which has friend/block data for all users... member_id | acceptedFriends | blocked --------------------------------------------------------------------------------------------------- member01 | friendID01(1270923292); frie.....| friendID02(1269465333); --------------------------------------------------------------------------------------------------- member02 | friendID01(1272542525); frie.....| sorry for the rather crap representation, but what im trying to show is all accepted friends of a member would be added to a single 'acceptedFriends' column, each separated via a ';' with the time stamp within brackets. (and same thing for blocked) would this be a good way for the data to be stored? please do say if you can think of anything better (: thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/200606-a-better-way/ Share on other sites More sharing options...
roopurt18 Posted May 3, 2010 Share Posted May 3, 2010 No. You don't store multiple values in a single "cell" as delimited strings. Table: member Columns: id | name | ... Table: member_friends Columns: id | member_id | friend_id Table member_blocked_members Columns: id | member_id | blocked_member_id EXAMPLE: Table: member Columns: id | name | ... 3, Jerry 4, Bob 5, Larry 6, Sally Table: member_friends Columns: id | member_id | friend_id 1, 3, 4 -- Jerry is friends with Bob 2, 3, 6 -- Jerry is friends with Sally 3, 5, 6 -- Larry is friends with Sally Table member_blocked_members Columns: id | member_id | blocked_member_id 1, 4, 5 -- Bob has blocked Larry 2, 6, 5 -- Sally has blocked Larry Quote Link to comment https://forums.phpfreaks.com/topic/200606-a-better-way/#findComment-1052696 Share on other sites More sharing options...
jacko310592 Posted May 3, 2010 Author Share Posted May 3, 2010 thanks roopurt18 (: good job i asked before it was too late Quote Link to comment https://forums.phpfreaks.com/topic/200606-a-better-way/#findComment-1052715 Share on other sites More sharing options...
roopurt18 Posted May 3, 2010 Share Posted May 3, 2010 Just remember that Bob and be friends with Sally while at the same time Sally is blocking Bob. You will probably want to honor "block" requests over "friend" requests when displaying information. You can accomplish this with UNION EXCEPT or sub-queries. Quote Link to comment https://forums.phpfreaks.com/topic/200606-a-better-way/#findComment-1052720 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.