mysql - How to design a relationship between team and game? -
i have come 2 options relate teams , games in database; 1 appropriate?
i trying make simple, here want. teams
have many games
, , each game
has home team
, away team
. it's many many relationship.
here thought:
i not sure whether should put boolean
field called ishome
in competes
table or add 2 fields called home_id
, away_id
, , set them foreign
key references team.id
in following picture.
if have 2 teams playing against each other can use
competes table -------------- home_team_id away_team_id game_id
like in 2nd option. if have dynamic number of teams in game use other.
Comments
Post a Comment