Home>

Is there a restriction to limit the combination to only one?

Favorite
+ ---- + --------------------- + ------------ +
| id | user_id | liked_id |
+ ---- + --------------------- + ------------ +
| 1 | 1 | 3 |
| 2 | 2 | 4 |
+ ---- + --------------------- + ------------ +

Is there a restriction in such a table definition that user_id is 1 and liked_id is 3 and the combination is not created in a later record? ??

Is it not possible in the first place?

  • Answer # 1

    I would abandon the id column and make user_id and liked_id a composite primary key.