If I want to link users with other users. Would this be a good way to do it:
I'm asking because I probably get double data like this if i don't do specific checks:
+------+-------------+
|userId|relatedUserId|
+------+-------------+
| 1 | 2 |
| 1 | 3 |
| 2 | 1 |
| 2 | 3 |
| 3 | 1 |
| 3 | 2 |
+------+-------------+
>
would prevent at least the first two relationships in this example from existing.<>
(or!=
) would probably be better.<>
would prevent1,1
or2,2
, but would not prevent1,2
or2,3
. The point of preventing these is to enforce an entry order for the values. By enforcing the order1,2
would have to be entered the same way as2,1
(as1,2
) and would therefore be detected as a duplicate.