Diagram
I created the following diagram:
Considerations
So I will create two tables, one called Match
and the other one called Teams
. In Match
there will be data about two teams, Away
and Home
.
Let us take into account that each team
can have take part in many matches
, and a match
can have exactly two teams
.
Questions
- Is this considered a many-to-many (M:N) relationship?
- Is there anything I can do to change it?
Best Answer
No, it is not a Many-To-Many. Match has two separate relationships with Team - Home Team and Away Team. These relationships are One-To-Many - One Team can have many Matches as Home Team but one Match has only one Home Team. This repeats for Away Team but they are not the same relationship.
To what, and why?
Yes, you could make these relationships Many-To-Many, so a Match can have many Home Teams and many Away Teams, but that data model doesn't fit the use case in this scenario - it has been modelled correctly already.
You could also make these relationships One-To-One, meaning a Team can only have one Home Match and one Away Match total, but again this data model would not fit the use case.