golfortennis1
Member
- Local time
- Today, 18:09
- Joined
- Jan 11, 2023
- Messages
- 43
One thing that may make this a little easier to understand and keep you data straight is to use what is called a Natural key. I know this is opposite from what was suggested with just using autonumbers. But this is a case where I think it would help. This would work well for courses and holes because the tables are relatively small. There are only so many golf courses. This looks like PGA courses so the list is
Although we tell people do not worry what the key looks like (you should never see it), if you are importing data from other sources and need to do data validation it may help. I am still convinced that your hole data was wrong in the shot table and it was hard for me to see what happened. But it appeared you picked the ID for the right number hole on the wrong course. Natural keys would have made this either to understand.
A key needs to be:
Unique
Non changing (except very rarely)
Known at data entry
Simple
No unique characters
This is not a hard change if you want to do it. It requires an update query and a little manual entry.
1. Give each course a unique readable identifier like we do with airports (SAN San Diego, DCA Washington National).
AUGS Augusta
PINE Pinehurst
ANGN Angus Glen North
ANGS Angus Glen South
etc.
2. Call that new field CourseID. Call the old CourseID OldCourseID (have to do that in reverse order). It will be needed to create the update to fix the joined tables
These new keys are not as efficient as an autonumber but still very good keys
3. You will have to break the relationship diagram and then put it back together after all changes
4. In the Hole table do something similar. Create new HoleID (string) and name the old HoleID OldHoleID
Now either manually or using an update query create your hole ID as follow. Not to hard now to do it manually.
AUGS1
AUGS2
AUGS3
AUGS4
....
PINE1
PINE2
PINE3
5. Now have to do the same for the FK in the shot table.
Create a HoleID (string), and rename the old HoleID_FK OldHoleID
This one has to be done with an update query to update the new hole id PINE1 where the oldHoleID was 1
6. Oh yeah you will have to do the same thing for Round. The CourseID_FK is now a string. This can be done manually. Where it use to store 2, but AUGS in new ID field.
None of this is required, but may help you with doing the relationships and seeing how it comes together. You would not have made the problems with the hole assignment. Instead of seeing hole id 27, you would AUGS9. It gets real confusing when looking at tables with nothing but foreign numeric keys until everything comes together.
If you like that ID, Create the fields in the Course, Range, Hole tables and populate manually. Rename and leave the old fields. Send it back and will show you the update query for the shot table.
So I must post a mea culpa: re:the hole listing, I thought I had mentioned this already, but upon further review, I had not.
In the first file I posted, I wanted to randomize the names of the courses I had played so as not to reveal any location data. Rest assured I have not played any of those courses ever, and if you are a golfer, your efforts certainly would earn you an invite to one of them if I had anything to say about it. But in my haste, I simply randomly put names against rounds, and did not pay attention to the actual distribution. I do apologize for the effort this caused. I certainly did not think anyone would spend near as much time as you have on my little db.
As this was from an excel file, I had run a lookup to assign the HoleID numbers to the course listing, and the imported. I have trashed probably 7 attempts at a new db, as I found it easier to start over to get it right, and in part because of your (and some others') advice, I broke up the data into smaller chunks to maintain as much relational integrity as this could possibly have. So I understand if you decide this was a bridge too far, and again I apologize, however, unless there is a step in form/query/report future that it could mess up, don't spend any time on the holeID and the shots. Perhaps foolishly I am doing everything twice(once for the actual DB, and once for the one I post here), as more practice = better leaning, and I am pretty confident that I have the holes and courses assigned to the proper shots.
I will look over what you posted and try to digest it. Frankly I haven't had much opportunity to look at your latest db work so I will be looking at that as well.