Sessions table
The Sessions table in the FitStack - V2 schema has 15 columns, keyed by Id, with 5 foreign keys to Courses, CourseSchedules, Gyms, Studios and 1 more. 2 columns in SessionCodes and Enrolments reference it.
One occurrence. Replaces Classes (81). Glossary: Session; avoid Class.
Columns (15)
| Column | Type | Constraints | Description |
|---|---|---|---|
| Id | uuid | primary key, not null | |
| CourseId | uuid | not null, references Courses.Id | |
| ScheduleId | uuid | references CourseSchedules.Id | Null for a one-off Session. SET NULL. |
| GymId | uuid | not null, references Gyms.Id | Denormalised from the Course for timetable queries. |
| StudioId | uuid | not null, references Studios.Id | |
| TrainerId | uuid | references Trainers.Id | Null = unstaffed; shown as needing a Trainer. |
| StartsAt | timestamp with time zone | not null | |
| EndsAt | timestamp with time zone | not null | |
| Capacity | integer | not null | Resolved at generation: Course, else Studio. |
| Status | text | not null | `SessionStatus`. |
| CancelReason | character varying(500) | ||
| CreatedAt | timestamp with time zone | not null | |
| ModifiedAt | timestamp with time zone | ||
| IsDeleted | boolean | not null | |
| DeletedAt | timestamp with time zone |
Indexes (4)
(GymId, StartsAt)(IX_Sessions_GymId_StartsAt)(CourseId, StartsAt)(IX_Sessions_CourseId_StartsAt)(TrainerId, StartsAt)(IX_Sessions_TrainerId_StartsAt)(StudioId, StartsAt)(IX_Sessions_StudioId_StartsAt)
Relationships
Sessions.CourseIdreferencesCourses.IdSessions.ScheduleIdreferencesCourseSchedules.IdSessions.GymIdreferencesGyms.IdSessions.StudioIdreferencesStudios.IdSessions.TrainerIdreferencesTrainers.IdSessionCodes.SessionIdreferencesSessionsEnrolments.SessionIdreferencesSessions