dimanche 12 juin 2016

SQL: Football match table structure

First of all sorry for my english. Anyway, I designed a database for soccer leagues, I have a doubt about the MATCH table. The obvious way is to add two fields for home team id and for away team id, and a foreign key for each. But this way I think is not the best way, because , for example, if I want to get all the MATCH played by a team I have to write a where with two fields instead of one.

So my solution are two and I want to ask you what do you think:

  1. Create a ManyToMany table MATCHES_TEAMS and keep the two fields away/home team id or one of them in MATCH table.
  2. Create two ManyToMany table MATCHES_HOME_TEAMS and MATCHES_AWAY_TEAMS.

Thank you and goodbye

Aucun commentaire:

Enregistrer un commentaire