Reputation: 50
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. Tables in CAPS for readability.
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? 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.
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!
Upvotes: 1
Views: 3430
Reputation: 25053
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.
EDIT (2020): If (as was just asked) you need to support multiple tees per hole, add this:
HOLE_LENGTH - distance from tee to cup
CourseID
HoleNum
TeeIdentifier - Black, White, Blue, etc
Distance
Upvotes: 6