I am creating a database for storing wrestling events and have hit a wall with how to structure my database. Appreciate anyone's assistance.
I have the following tables:
tblPeople that will contain all of my wrestlers.
tblPeople
- personId
- personName
#eg: "211", "Dean Ambrose"
tblTeams that will contain a specific tag team
tblTeams
- teamId
- teamName
#eg: "13", "Shield"
tblPeopleInTeams will relate people to teams
tblPeopleInTeams
- peopleInTeamsId
- teamId
- peopleId
#eg: "1", "13", "211"
tblMatches will contain match details and needs to reflect the people or teams involved
I am unsure how I can structure tblMatches so that it can reference either a person or a team. An example would be that a match could have either "Dean Ambrose" or "Shield" as a competitor.
I could do:
tblMatches
- matchId
- peopleId
- teamId
#eg: "412", "211", NULL (for Dean Ambrose)
#eg: "412", NULL, "13" (for Shield)
But to use this I would have to only populate one of the fields and use conditional logic in my application to determine the type of entry. I imagine there is a better way to do this but I can't think of how. Any thoughts please?
Thanks, Jordan.