Database for Basketball teams/games/scores per season. Table structure

两盒软妹~` 提交于 2019-12-11 03:13:51

问题


I am creating a database for a Basketball Season. At this point, I am keeping it simple, and storing tables:

-League id[PK], name->(NBA, NCAAM, etc)

-Year id[PK], league_id[FK], year->(2012-2013, 2011-2012, etc)

-Team id[PK], league_id[FK], name->(Bulls, Lakers, Etc)

-Game id[PK], home_team[FK], away_team[FK]

-Score id[PK], game_id[FK], home_score, away_score

My question is about table structure. I am somewhat new to sql, but I want to be able to make calcuations based on database info. For example:

Team A on the road, playing team B, where team A's road score avg is x and team B's home score average is y... and so on

Anything you see that screams DONT DO IT THAT WAY? Just wanted you guys to take a quick look.

Eventually would like to develop a cross sport DB similar to this:

http://www.bc.edu/content/dam/files/schools/cas_sites/cs/local/bach/2008/08LawrenceChang.pdf

But want to start here to get a base scraping algorithm, and some basic stats to start out. Let me know whatcha think. Thanks a bunch!


回答1:


At first glance I would put the scores in the game table and add a game date field. I would rename the year table as season, and include start and stop dates. Also consider adding a season id to the game table.




回答2:


The Year and Score tables both seem unnecessary to me. They can easily be added onto the Game table (including both a date and a season field for the Year).

Also I don't see why you need to generate the auto-increment primary key on the League table. The League name by itself would work perfectly fine, or better yet get rid of the League table altogether and just use ENUM on the league field in the Team table.



来源:https://stackoverflow.com/questions/15103510/database-for-basketball-teams-games-scores-per-season-table-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!