I have a relatively simple database containing a Player
table (a single field username
) and a Game
(a single field date
) one. As a Player
can take part in multiple Game
and a Game
can be played by multiple Player
, I use a many-to-many
relationship where an extra column score
is added to the joined table to store the score of a Player
in a Game
.
In my Java code, I have obviously a Player
class with field username
and a Game
one with field date
. However, I do not know if I should create a third class for the join table or if I should add a List<Player>
attribute within the Game
class along with a list of List<Integer>
to store the score.
EDIT: Example
Player
table:
player_id player_name
1 Bob
2 Lea
3 John
Game
table:
game_id game_date
1 20/08/2017
2 19/08/2017
Joined
table:
game_id player_id score
1 1 50
1 2 35
2 1 50
2 3 29