samedi 25 juin 2016
MySQL: unique informations cross 2 tables
I have 2 tables battles & battle_user
structure:
battles table:
id create_date
1 2015/...
battle_user table:
id battle_id user_id
1 1 1
2 1 2
Only 2 users accepted in each battle, the question is: Is there a way using primary/foreign keys (or indexing) to prevent insert another battle for same 2 users?
prevent this:
battles table:
id create_date
1 2015/...
2 2015/...
battle_user table:
id battle_id user_id
1 1 1
2 1 2
3 2 1
4 2 2
prevent create 2 battles between same 2 users
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire