I'm creating a sports statistics database. With it, I'd like to catalog game/match statistics for many types of sports. For example, this database would be able to tell you how many touchdowns the Carolina Panthers scored in the 09-10 season (football), or how many free throws were made by the Miami Heat in their last game (basketball).
I'm having trouble designing one of the more fundamental tables called Matches. The Matches table has columns for:
- ID (PK *match_id*)
- date of play (*play_date*)
- IDs referring to the performances of the teams (FK *team_1_performance_id* and *team_2_performance_id*) in table Performances.
The Performances table holds:
- ID (PK *perf_id*)
- team ID (FK *team_id*)
- And most importantly, all the other stats like: number of strikes (*)
- average rushing yards per play (*)
- percent of 3-pointers made (*)
(*)The problem is, how can I make the Performances table relevant to the respective sport? For example, baseball games have strikes, but soccer and hockey do not (nor does any other sport I can think of). I don't want my Performance table to have a column for strikes when its only going to be relevant for a portion of records.
Or do I? Perhaps my design should be different all together? How would you go about this?
Now, I don't know if this is possible, but one idea I had was to maybe include some kind of perfomance table ID column in Matches that refers to different performance tables. So that when I query a match's performances, it will look at a specific table. This is where the title of this question comes from (Can an attribute designate one table over another?). Imagine "SELECT team_1_performance.strikes FROM Matches INNER JOIN appropriate_performance_table AS team_1_performance WHERE Matches.performance_table_id = 'Baseball'" How could I designate appropriate_performance_table, if that's even possible?
And another idea I had was to create matches tables for all the sports, like Rugby_Matches or Football_Matches, and then respective performance tables for those sports, like Rugby_Perfomances or Football_Performances. This just seems like a lot of tables that represent somewhat similar things.
If you can, try to keep your responses MySQL specific.
Thanks!