ybh305 — 2010-01-28T17:32:13-05:00 — #1
Is it possible to have a unique combination of two data types?
id - id1 - id2
1 - 100 - 264
user id 1 and user id 2 will always be unique to each other. No other row can contain 264 - 100, vice versa.
r937 — 2010-01-28T22:13:39-05:00 — #2
declare a compound UNIQUE constraint on (id1,id2)
if this is mysql, then, in your application logic, make sure you always insert ~only~ where id1 < id2, never the other way around
if this isn't mysql, you can add a CHECK constraint for ( id1 < id2 )
ybh305 — 2010-01-28T22:29:38-05:00 — #3