I have the attached data model for a calendar and results database for Swedish ultrarunning events.
EVENTS
General info about a (usually) recurring event
- One event can have many courses (one-to-many)
- One event can have many races (one-to-many)
COURSES
All the info about a course, that an event can use (e.g. 50 miles, 50 km, 100 miles)
- One course can be used in many races (such as a 50 miles course in each year's race at an event)
RACES
A particular instance of an event, at a particular date, using one of the courses in the COURSES post type.
- One race can have many courses (this is one of the things I have a question about!!) - possible many-to-many with COURSES
RESULTS
Results for a particular race, including times, positions etc. for each runner.
- One result can belong to one race (OR an intermediary custom post type, see question below)
RUNNERS
Info about each runner that participates at a race and gets a result.
- A runner can have many results
QUESTIONS
Now what I'm thinking about is how to deal with dividing the data into COURSES and RACES.
1) I can choose a many-to-many relationship and let each race have many courses. That is, a race in this case is everything that is happening at an event on a particular date.
2) I can choose a one-to-many relationship and create one race for each course at an event on a particular date. That is, I have to create many races if there are many courses that year, rather than as in #1 where I only need one race with many courses.
Scenario 1:
In the case of #1, could I create an intermediary post type - possibly containing the date - to which the result of that particular instance (a specific course on a particular date) is related? In this case, the date has to be in both RACES and in this intermediary post type? Or not in RACES?
Scenario 2:
In the case of #2, I would relate each result to one race in RACES and that race has only one course. Easy enough.
In scenario 1, the advantage could be that it is easier to create a race and I can have a description for whatever is unique to the event on that particular date.
In scenario 2, it will be more complicated to create let's say 4-5 different races for an instance of an event and those races have nothing in common but the date.
DISPLAYS
The following are the displays that I am planning that are related to COURSES and RACES.
a) List of all upcoming races, with the event name from EVENTS as the title, but with the distances from the COURSES table for each race from RACES on that date being displayed. Like at hidden link
b) Upcoming and past races below the event details of the event page. Like at hidden link
c) Detail page for a course, listing all upcoming and past races for that course. Such as hidden link
d) Results page for an event. Such as hidden link
e) Results page for a particular race instance. Such as hidden link
f) Views with top results by gender and age group for a particular course. Such as hidden link
FINAL QUESTION
Which approach to the relationships between COURSES, RACES and RESULTS is the best to accomplish this?