my problem is pretty simple but I can't put words on it. I've got a user table with ids for each of them.
I want to make a friendship table, but I don't want to be able to have duplicate records. Meaning not this:
id_user1 | id_user2
---------|----------
   2     |    3
   3     |    2
Am I clear enough?
For the moment I have this for my table creation:
CREATE TABLE User(
    id INT NOT NULL AUTO_INCREMENT,
    name VARCHAR(100) NOT NULL,
    surname VARCHAR(100) NOT NULL,
    PRIMARY KEY (id)
);
CREATE TABLE Friends(
    id_user1 INT NOT NULL,
    id_user2 INT NOT NULL,
    PRIMARY KEY(id_user1, id_user2),
    FOREIGN KEY (id_user1) REFERENCES User(id),
    FOREIGN KEY (id_user2) REFERENCES User(id),
);
[EDIT 1:] Maybe the best practice is to save each record twice? Both ways?
 
     
     
    