[英]mySQL database scheme for golf scores
I am designing a database to store golf scores and other statistics about each hole or round, but am having difficulty in knowing which method will be most efficient.我正在设计一个数据库来存储每个洞或每轮的高尔夫分数和其他统计数据,但我很难知道哪种方法最有效。 My question centers around structuring the tables for courses and rounds.我的问题围绕着为课程和轮次构建表格。 Here's two options, although I'm not sure if there's a better third.这里有两个选项,虽然我不确定是否有更好的第三个。 I'm using mySQL 5.1.63 and PHP 5.2.17.我正在使用 mySQL 5.1.63 和 PHP 5.2.17。 Tables in CAPS for readability. CAPS 中的表格以提高可读性。
A similar question could be asked about recording the round.关于记录回合,可以问一个类似的问题。 Do I have round_1, round_2, ..., hit_fairway_1, hit_fairway_2, num_putts_1, num_putts_2, or do I break each of those attributes into their own table?我有 round_1、round_2、...、hit_fairway_1、hit_fairway_2、num_putts_1、num_putts_2,还是将这些属性中的每一个都分解到它们自己的表中? This question and its answers lean towards breaking this into tables.这个问题及其答案倾向于将其分解成表格。 Does that mean a structure like:这是否意味着像这样的结构:
Recurring queries (using PHP) would be mostly on did the person hit above or below par, hit the fairway, # of putts, etc.重复查询(使用 PHP)主要是关于这个人是否击球高于或低于标准杆、是否上球道、推杆数等。
Hopefully my question was clear enough.希望我的问题足够清楚。 I know there are semi-similar questions out there, like the one referenced above, but I couldn't quite transfer those answers to what I was looking for.我知道那里有半相似的问题,就像上面提到的那个,但我不能完全将这些答案转移到我正在寻找的东西上。
Thank you!谢谢!
Not sure what 'slope' is, but how's this for a start:不确定“斜率”是什么,但这是如何开始的:
COURSE - one record per course
CourseID
AddressInfo
NumHoles - usually 9 or 18
HOLE - one set of these per course
CourseID
HoleNum
Par
Slope - you can add more here if you want (water, sand, etc.)
MATCH
CourseID
MatchID
MatchName
StartDate
ROUND
RoundID
MatchID
PlayerID
RoundNum
StartDate
SCORE - every time a player plays a hole, add one of these
CourseID
MatchID
RoundID
HoleID
PlayerID
NumPutts
NumStrokes - you can add more specifics if you want (fairway, rough)
PLAYER
PlayerID
This is what you call 'fully normalized', and has minimal duplication of data from table to table.这就是您所说的“完全规范化”,并且表与表之间的数据重复最少。 The resulting SQL statements can get a little complicated for a beginner, but it will be worth it if you get it right now.生成的 SQL 语句对于初学者来说可能有点复杂,但如果您现在就明白了,那将是值得的。
EDIT (2020): If (as was just asked) you need to support multiple tees per hole, add this:编辑(2020 年):如果(如刚才所问)您需要支持每个洞有多个发球台,请添加以下内容:
HOLE_LENGTH - distance from tee to cup
CourseID
HoleNum
TeeIdentifier - Black, White, Blue, etc
Distance
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.