Reputation: 738
The question in the tile might not be clear for what I'm asking for so I'll add some examples below.
What I'm asking is for is when you insert a row in a table with composite keys, a single row is valid but if I swap the keys over this is also valid. This is not what I want. I would like prevent at the table level, when we try to insert a row with the same IDs but in different order to throw an error and not allow the insert.
VALID:
user_id | friend_id
1 2
ALSO VALID but I want it to be INVALID:
user_id | friend_id
1 2
2 1
Is this possible? I'm using Laravel and have composite keys already set. I have tried looking for what I'm asking but either I'm not good at finding what I'm looking for or it can't be done in the way I want.
Upvotes: 0
Views: 14