Problem Statement:
Assume we have the following application that models soccer teams, the game they play, and the players in each team. In the design, we want to capture the following:
- We have a set of teams, each team has an ID (Unique Identifier), name, main stadium, and to which city this team belongs.
- Each team has many players, and each player belongs to one team. Each player has a number (Unique identifier), name, DOB, start year, and shirt number that he uses.
- Teams play matches, in each match there is a host team and a guest team. The match takes place in the stadium of the host team.
- For each match we need to keep track of the following:
- The date on which the game is played.
- The final result of the match.
- The players participated in the match. For each player, how many goals he scored. Whether or not he took yellow card. Whether or not he took Red card.
- During the match, one player may substitute another player. We want to capture this substitution and the time at which it took place.
- Each match has exactly three refree. For each refree we have an ID (Unique Identifier), name, DoB, years of experience. One referee is the main referee and the other two are assistant referee. Design an ER diagram to capture the above requirements. State any assumptions you have that affects your design. Make sure cardinalities and primary keys are clear.
Entities and Attributes
- Team
- Attributes:
- TeamID (Primary Key, Unique Identifier)
- Name
- MainStadium
- City
- Player
- Attributes:
- PlayerID (Primary Key, Unique Identifier)
- Name
- DOB (Date of Birth)
- StartYear
- ShirtNumber
- Relationships:
- Belongs to one Team (Many Players to One Team)
- Match
- Attributes:
- MatchID (Primary Key, Unique Identifier)
- Date
- FinalResult
- Relationships:
- Has one Host Team (Many Matches to One Host Team)
- Has one Guest Team (Many Matches to One Guest Team)
- Involves multiple Players (Many Players participate in a Match)
- Referee
- Attributes:
- RefereeID (Primary Key, Unique Identifier)
- Name
- DOB (Date of Birth)
- YearsOfExperience
- Relationships:
- Officiates a Match (Many Referees to Many Matches)
- MatchParticipation (Associative Entity)
- Attributes:
- GoalsScored
- YellowCard (Boolean)
- RedCard (Boolean)
- SubstitutionTime
- Relationships:
- Links Players to Matches (Many Players to Many Matches)
Relationships
- A Team can have multiple Players (1:N).
- A Match has one Host Team and one Guest Team (N:1 for both).