There is a database with tables:
- Users
- Tournaments
- Participants
- Games
- Avatar
Where, Users is the user model, avatar holds addresses to png files to set avatar for user.
Tournament holds tournament related data, participant assigns a player to a tournament, and games holds tournament and non-tournament related instances of matches being played in the app, and related data such as what players played this game.
Database Visualized
My problem is with the player1 and player2 columns within the Games table.
I read a rule, that foreign keys point to a table, so it doesn’t make sense having 2 different columns of the games table pointing to Users, but then would the solution be to have a foreign key in games that points to users, and through that to set player1 and player2 as varchar accordingly?
I tried having 2 players set as varchar, get the players name upon the initiation of a game session and save it that way, but it feels not correct.
Andor Gunczer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.