如何设计一个针对多种运动项目的体育统计数据库?

发布于 2024-10-07 02:10:45 字数 1435 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

总以为 2024-10-14 02:10:45

您可以从 sportsdb 中获得灵感,这是 XML Team 创建的用于运动建模的 RDBMS 模式。在该模式中,比赛和玩家统计数据存储在非规范化表中,并且核心统计数据(如得分)与特定运动的统计数据分开。该模式非常复杂,但可以让您了解可能的实现

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

2024-10-14 02:10:45

正确的方法是制作多个表格,每项运动似乎都有可能。

玩家(玩家 ID、名字、姓氏)
球队(Team_ID、Sport_ID、TeamName)
队伍列表(Team_ID、Player_ID)
运动(Sport_ID、SportName)
曲棍球统计(球员 ID、球队 ID、年份、进球数、已玩比赛数、助攻数)
BaseBallStats (Player_ID, Team_ID, Years, BoringSport)

这也解决了交易的情况,分数是从哪支球队获得的,以及多种运动。

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.

初心未许 2024-10-14 02:10:45

另一种方法是使用带有统计 ID 列的单个表,用于标识该行中描述的统计信息。如果要保存的统计数据会随着时间的推移而改变,这可能会很有效。只有当每个统计数据的基本形式相同时,它才会很好地工作(抱歉,我是英国人,不熟悉你提到的体育和统计数据),但是有多个表的小变体(所有百分比统计数据都在一个表中,另一个中的所有简单计数统计数据,等等)。

An alternative approach is a single table with a statistic-ID column, identifying which statistic is being described in that row. This may work well if the statistics to be kept will change over time. It will only work well if the basic form of each statistic is the same (sorry, I'm British and not familiar with the sports and stats you mention), but there are multi-table minor variants (all percentage stats in one table, all simple-count stats in another, etc).

寂寞笑我太脆弱 2024-10-14 02:10:45

你的初始设计没问题。

您需要创建一个游戏桌。因此,您将有一个包含字段(Game_ID、Sport_ID、Team1_ID、Team2_ID)的游戏表,然后可能是(Date_Played、Win_Lose_Tie 等...),

然后我将为每项运动创建一个统计表。 TBL_Baseball_Stats (Stat_ID, Game_ID, Player_ID, Hits, HRs, RBIs 等...

然后你可以有一个曲棍球统计表。 TBL_Hockey_Stats (Stat_ID,Game_ID, Player_ID, Goals, Assists, 等等...)

这将允许你拉按球员、比赛、运动等统计统计数据...

Your initial design is ok.

You will need to create a table for games. So you would have a games table with fields (Game_ID, Sport_ID,Team1_ID, Team2_ID) and then maybe (Date_Played, Win_Lose_Tie etc...)

I would then place Create a Statistics Table for each sport. TBL_Baseball_Stats (Stat_ID, Game_ID, Player_ID, Hits, HRs, RBIs etc...

Then you could have a table for Hockey Stats. TBL_Hockey_Stats (Stat_ID,Game_ID, Player_ID, Goals, Assists, etc ...)

This will allow you to pull up stats by Player, Game, Sport, etc...

老娘不死你永远是小三 2024-10-14 02:10:45

如果您希望能够动态创建新的运动项目,而无需修改数据库,则必须创建足够智能的东西来概括任何类型统计数据的存储。无论您选择什么,您都无法通过一张桌子来做到这一点。

因此,如果您有确定数量的不同运动,我建议您为每个统计数据创建一个表。

如果没有(您希望将来能够利用他们的统计数据创建新的运动),您应该寻找如何抽象这样的东西。一些草案建议:

  • 一项运动有许多统计数据
  • ,一项统计数据有许多字段,一项运动
  • 一个字段有许多属性(类型、值等)。

如果相同的轮廓出现在不同的统计数据中,您可以利用表继承。

If you want to be able to dynamically create new sports, without modifying the database at all, you will have to create something smart enough to generalize the storing of any kind of statistics. Whatever is your choice, you won't be able to do that with a single table.

So if you have a determined number of different sports, I would recommend you to create one table per statistic.

If not (you want to be able to create new sports in the future with their statistics), you should look for how to abstract such a thing. Some draft toughts:

  • a sport has many stats
  • a stat has many fields and one sport
  • a field has many properties (type, value, etc.)

If the same outlines appear in different statistics, you may take advantage of table inheritance.

百善笑为先 2024-10-14 02:10:45

多项运动都有自己不同类型的规则,因此您可以使用基于文档的数据库(例如:MONGODB),因为它很灵活并且没有特定的列。

Multiple sport have it's own different type of rule so you can use use document based database(Eg: MONGODB) because it is flexible and not have specific column.

余罪 2024-10-14 02:10:45

您必须注意,某些运动员具有相同的名字(名字和姓氏),因此在定义主键时要考虑到这一点。

对于棒球来说,有很多不同类型的统计数据 - 我会尝试至少通过添加 AVG 来满足竞争 DB 的期望。 /比赛/ 跑数/安打/ AB/ SB/ 2B/ 3B。以及投手统计数据 - W/ERA/WHIP/SO。

you must note that there are certain athletes that have the same name (first and last) therefor take that under consideration while defining primary keys.

For baseball there are a lot of different type of stats- i would try to meet the expectations to competing DBs by at least adding AVG. /Games/ Runs/Hits/ AB/ SB/ 2B/ 3B. and pitcher stats as well- W/ERA/WHIP/SO.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文