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:

enter image description here

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.

enter image description here

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

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -