Created
September 21, 2013 20:25
-
-
Save IMSoP/6653849 to your computer and use it in GitHub Desktop.
Sample schema for http://stackoverflow.com/questions/18934654/creating-scheduler-app-process-and-concept-questions/18935552
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
table activities | |
activity_id int (auto-increment) primary key | |
name varchar | |
description varchar | |
table cabins | |
cabin_id int (auto-increment) primary key | |
name varchar | |
table schedules | |
schedule_id int (auto-increment) primary key | |
name varchar | |
created_by_user_id int (foreign key to users table, not shown) | |
cabin_id int (foreign key to cabins table) | |
table schedule_items | |
schedule_item_id int (auto-increment) primary key | |
schedule_id int (foreign key to schedules table, indicating which schedule this item belongs to) | |
start_time datetime -- this might just be a date, no time; it might also be a reference to an abstract "period", which then has the datetime | |
activity_id int (foreign key to activities table) | |
*/ | |
-- Sample query: | |
Select | |
S.name as schedule_name, | |
C.name as cabin_name, | |
SI.start_time, | |
A.name as activity_name | |
From | |
schedules as S | |
Join | |
cabins as C | |
On C.cabin_id = S.cabin_id | |
Join | |
schedule_itemas as SI | |
On SI.schedule_id = S.schedule_id | |
Join | |
activities as A | |
On A.activity_id = SI.activity_id | |
Where | |
S.created_by_user_id = 42 | |
Order by | |
C.cabin_name, | |
SI.start_time; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment