I have 2 tables: players and teams. I assumed the relation between them is n:1 (foreign key inside player's table).
I want to be able to record all the teams the player has played.
What should I do?
In this case, it might be easier to create a n:n relation between players and teams. You can create an extra table that has 3 fields: The foreign key to player, the foreign key to team and an extra field to indicate if that is the current team of the player. For example, you could store the date that the player joined that team, and the team with the latest join date would be the player current team. This would both help you to track all the teams that the player played in, and also check his current team. From the teams perspective, you would look at the extra table and filter each player by only his latest join team (same as aforementioned) and would then count/check all the players which their latest team would be the team in question, and you could check the roster.
About the Community
|Asked: 1/12/21, 9:05 AM|
|Seen: 897 times|
|Last updated: 8/6/21, 10:49 AM|