I am creating a MySQL table to store the concept of "a user follows another user". Of course, one user follows another or not, but more than one registry saying the same doesn't make any sense. This is, both fields together are unique:
create table following (
id_user1
id_user2
UNIQUE (id_user1, id_user)
)
I always add a id
field as a good practice to every table. However, I have the doubt if an id
field makes sense in this table, or the primary key should be id_user1 and id_user2 together.
SOLUTION A:
create table following (
id PRIMARY KEY
id_user1
id_user2
UNIQUE (id_user1, id_user)
)
SOLUTION B:
create table following (
id_user1
id_user2
PRIMARY KEY (id_user1, id_user)
)
Is there a reason to go for SOLUTION A or SOLUTION B?