¿Cómo diseñar mi base de datos?

I want to create a database for soccer scores.

Obviously, we have:

  • Países (Netherlands, Germany, (But also Europe))
  • Competiciones (Eredivisie, Bundesliga, UEFA Europa League)
  • Equipos (FC Twente, Bayern Munchen, Atletico Madrid)
  • JUGADORES (Luuk de Jong, Manuel Neuer, Tiago Mendes)
  • Cerillas (FC Twente - PSV, Bayern - Leverkusen, etc)
  • Eventos (Goal scored in 40th minute by Luuk de Jong)

I'm using Dezign in which I have created the scheme below:

enter image description here

Obviously, a Competition is bound to a Country, a Player to a Team, etc.

But then some problems occur. An Event belongs to a Match and a Player. So the Event could get a match_id y un player_id. But then any player of any team could 'score' in a match in which he doesn't belong (A player of team C could score in a match between team A and team B). How can I restrict this for example?

Also, a Team could compete in its 'normal' competition, but also in the Champions League. Thus, a simple competition_id in the Team entity would not suffice.

And do you suggest any other thoughts?

Edit in response to Philipp enter image description here

preguntado el 09 de marzo de 12 a las 14:03

1 Respuestas

You lack an entity to express the Lineup(team, match) junto con una LineupPosition (lineup, player).

You could then associate an Event con un LineupPosition (specific player in a specific match), thereby linking your Event a la correcta Match, a través de LineupPosition->Lineup->Match.

respondido 09 mar '12, 14:03

See added image in question, you mean something like that? I can see it indeed will work for the player outside the match scoring problem. But how can I restrict more than two Lineups having the same match_id? - nhaarman

No tengo match_id in Lineup, but a home_lineup_id y away_lineup_id in Match instead. This way you can only have two lineups per Match and you don't loose the home/away information. - Felipe Reichart

I've edited the image again. Thanks a lot so far, I do have one last question I think. When I create entries in LineupPosition I can add players from several teams to the same lineup_id. This could come in handy (for example, national teams), but for 'normal' competition matches this should not be possible. Any thoughts on that? - nhaarman

A bit late, but sorry, no idea how to enforce this on the database level. - Felipe Reichart

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.