CREATE TABLE Friends_Relations(
buddy_id VARCHAR(255) NOT NULL,
mate_id VARCHAR(255) NOT NULL,
PRIMARY KEY (buddy_id, mate_id),
FOREIGN KEY (buddy_id) REFERENCES Users(id) ON DELETE CASCADE,
FOREIGN KEY (mate_id) REFERENCES Users(id) ON DELETE CASCADE
);
There's this mutual friendship relation where (friend_A, friend_B) is the same as (friend_B, friend_A).
I've tried adding a unique key, but it was to no avail:
ALTER TABLE Friends_Relation ADD UNIQUE KEY (mate_id, buddy_id);
Is there a way to avoid these permutations ?