Hi,
I'm building a database of golf tournament finishing position statistics for my golf betting website. The idea is to have two pages of stats, one showing the golfer finishing positions for the last 5 US PGA tournaments and another for the last 5 European Tour events.
As this is my first stab at mysql/php I'd be grateful for feedback on the following database design:-
tbl_golfers (holds the names of all the golfers)
ID smallint UNSIGNED Not Null Auto Increment PRIMARY
Golfer varchar(40) UNIQUE
tbl_tournaments_Euro (holds European Tournament names and dates)
ID smallint UNSIGNED Not Null Auto Increment PRIMARY
Tournament varchar(100) Not Null
T_Date date Not Null INDEX
tbl_tournaments_US (holds US Tournament names and dates)
ID smallint UNSIGNED Not Null Auto Increment PRIMARY
Tournament varchar(100) Not Null
T_Date date Not Null INDEX
tbl_fp_Euro (holds golfer finishing positions for European tournaments)
GolferID smallint UNSIGNED Not Null INDEX
TournamentID smallint UNSIGNED Not Null INDEX
Position varchar(10) Null
tbl_fp_US (holds golfer finishing positions for US tournamnts)
GolferID smallint UNSIGNED Not Null INDEX
TournamentID smallint UNSIGNED Not Null INDEX
Position varchar(10) Null
A few questions:
1) Does this design look ok generally or are there better ways of doing it?
2) Is it ok to not have a PRIMARY KEY for the finishing positions tables?
3) Do the Keys I have assigned look ok?
4) What SQL query would I need to run to pull the finishing position stats from my database so that I can display each golfers finish for the last 5 tournaments of say the US Tour? This is what I'd want to see on my webpage:-
Golfer TName1 TName2 TName3 TName4 TName5
Sergio Garcia 27 10 Missed 42 Tied 3rd
Cut
Ernie Els 7 32 Tied 2nd 9 0
Vijay Singh 1 17 5 42 Missed
Cut
etc etc....
The 0 under TName5 for Ernie Els would denote a tournament he didn't play in ...would this appear automatically if no data was inserted into the finishing positions table(s) for a particular player/tournament combination, ie is that what the NULL is for in the Position field in the finishing position tables?
Hope this made sense and thanks for any advice you can offer.








Bookmarks