I'm trying to design a database to store player statistics for multiple types of sports.
In the database, you would have a bunch of players. Each player belongs to one team, and each team plays one sport. Here are the tables I have for just that part so far:
Player (Player_ID, Team_ID, FirstName, LastName)
Team (Team_ID, Sport_ID, TeamName)
Sport (Sport_ID, SportName)
Now I want to store the player's statistics. I run into a problem with different players playing different sports and therefore having to store different kinds of statistics for each sport. If I were storing hockey players and baseball players for example:
for the hockey players I want to store goals and assists
for the baseball players I want to store hits, home runs and RBIs.
Is there a proper way to do something like this using one database? Have I even started the right way?
Sports teams collect data, a ton of it. In order to make this data readily accessible, they usually store it in large structured databases. Data scientists and analysts are able to pull this data by using Structured Query Language (SQL).
Sports analytics is the process of plugging statistics into mathematical models to predict the outcome of a given play or game. Coaches rely on analytics to scout opponents and optimize play calls in games, while front offices use it to prioritize player development.
Stats Perform offers a comprehensive list of products and services designed to drive fan engagement, improve team performance and enhance fantasy and betting solutions.
The proper way is to make multiple tables, one for each sport seems likely.
Player (Player_ID, FirstName, LastName)
Team (Team_ID, Sport_ID, TeamName)
TeamList (Team_ID, Player_ID)
Sport (Sport_ID, SportName)
HockeyStats (Player_ID, Team_ID, Year, Goals, GamesPlayed, Assists)
BaseBallStats (Player_ID, Team_ID, Years, BoringSport)
This also resolves the situation with trading, which team the points were obtained from, as well as multiple sports.
You can get inspiration from sportsdb, a rdbms schema for sports modeling created by XML Team. In that schema the game and players statistics are stored in denormalized tables, and the core stats (like score) are kept separated from the sports-specific ones. The schema is quite complex, but can give you an idea about a possible implementation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With