samedi 9 juillet 2016

Database Design - 1 to 2 relationship

I am designing a database to keep track of games played over time. A game has two players. Currently, I have two tables: players and games.

Players
id
name
rating

Games
id
redplayer_id
red_score
blueplayer_id
blue_score

I recognize that this is not well normalized, but as its just a 1 to 2 relationship, I'm not sure what would be better. I'm thinking along the lines of adding a players_games table:

Players_games id
match_id
player_id
player_side (red/blue)

Then there would be two players_games for every game.

Does this make sense?

Aucun commentaire:

Enregistrer un commentaire