play_ Posted November 16, 2009 Share Posted November 16, 2009 Like many social sites, i am allowing users to add other users as friends. What would be the best way of doing this? as far as i can see, having just a table 'friends' with the fields 'userID' and 'friendID' is enough. friendID is essentially another user's ID. do i even need an autoincrement ID column? which column should i index and make primary? Link to comment https://forums.phpfreaks.com/topic/181710-solved-best-way-to-design-friends-featuretable-scheme/ Share on other sites More sharing options...
Mchl Posted November 16, 2009 Share Posted November 16, 2009 Create index on both columns and make this aggregate key primary. Link to comment https://forums.phpfreaks.com/topic/181710-solved-best-way-to-design-friends-featuretable-scheme/#findComment-958392 Share on other sites More sharing options...
play_ Posted November 16, 2009 Author Share Posted November 16, 2009 what do you mean by aggregate key? Link to comment https://forums.phpfreaks.com/topic/181710-solved-best-way-to-design-friends-featuretable-scheme/#findComment-958707 Share on other sites More sharing options...
Mchl Posted November 16, 2009 Share Posted November 16, 2009 It's an index created on more than one column. CREATE TABLE `ID1_ID2` ( `ID1` int(10) unsigned NOT NULL, `ID2` int(10) unsigned NOT NULL, PRIMARY KEY (`ID1`,`ID2`) ); Link to comment https://forums.phpfreaks.com/topic/181710-solved-best-way-to-design-friends-featuretable-scheme/#findComment-958722 Share on other sites More sharing options...
play_ Posted November 17, 2009 Author Share Posted November 17, 2009 thank you Link to comment https://forums.phpfreaks.com/topic/181710-solved-best-way-to-design-friends-featuretable-scheme/#findComment-958873 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.