slushpuppie Posted January 15, 2009 Share Posted January 15, 2009 i have a table with a column called 'asker' and 'asked', which is keeping like a "buddy list", so it's storing user ids from another table. i want the pairs to be unique - in my application it really doesn't matter who is the asker and who was asked. so for example: uid 1 asks uid 8 to be their friend, so i put in 1 | 8 into the table. i set a UNIQUE index on those two fields, which prevents me from inserting 1 | 8 again, however 8 | 1 can be added, which i don't want to happen. so my question is basically is there a way to set this logic on the database level? or will i need to do this in my application code? thanks Link to comment https://forums.phpfreaks.com/topic/140968-unique-pairs/ Share on other sites More sharing options...
ngreenwood6 Posted January 15, 2009 Share Posted January 15, 2009 I don't know if you can do it from a database level but you could do it in you code. Link to comment https://forums.phpfreaks.com/topic/140968-unique-pairs/#findComment-737811 Share on other sites More sharing options...
fenway Posted January 18, 2009 Share Posted January 18, 2009 If your application always inserts the data ( low_uid, high_uid ), you won't have this problem. Link to comment https://forums.phpfreaks.com/topic/140968-unique-pairs/#findComment-739723 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.