-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase_diagram.sql
More file actions
112 lines (95 loc) · 2.81 KB
/
database_diagram.sql
File metadata and controls
112 lines (95 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
-- Use DBML to define your database structure
-- Docs: https://dbml.dbdiagram.io/docs
Table users {
-- Firebase cloud storage uses id_first_last
id integer [primary key, increment]
first_name varchar
last_name varchar
email varchar [unique]
phone varchar
role enum('Admin','Participant','Leader') [not null]
lottery_weight float [default: 1]
has_waiver boolean [default: false]
trips_lead integer [default: 0]
trips_participated integer [default: 0]
}
Table trips {
// Firebase cloud storage uses id_trip_name
id integer [primary key, increment]
trip_name varchar [not null] -- Combination of trip_name and planned_date must be unique
planned_date datetime [not null]
max_size integer
class varchar(1) -- Either class or
price_override float -- price_overrid will be NULL but not both
paperwork_links json -- Array of links to paperwork documents
image_links json -- Array of links to images
sentence_desc varchar(100)
blurb text
planning_checklist json -- Planning tasks, completion status, and whos responsible
SAO_approved boolean [default: false]
}
Table trip_classes {
trip_class varchar(1) [primary key]
link varchar
price float [not null]
}
Table trip_signup {
trip_id integer [not null] -- Combination of trip_id and
user_id integer [not null] -- user_id will function as primary key
trip_role enum('Leader','Participant') [not null]
-- Following are NULL for Leaders and have defaults for Participants
status enum('Signed Up','Selected','Not Selected','Attended','No Show')
need_paperwork boolean
confirmed boolean
}
-- Multiple users/trips get mapped to eachother
Ref: trip_signup.trip_id > trips.id
Ref: trip_signup.user_id > users.id
Ref: trip_classes.trip_class < trips.class
/* Old schema
Table users {
-- Firebase cloud storage uses id_first_last
id integer [primary key]
first_name varchar
last_name varchar
email varchar
phone varchar
role_id integer
}
Table web_roles {
-- Participant, trip leader, or admin
id integer [primary key]
role_name varchar
}
Table trip_user {
-- This includes both leader and user instances
instance_id integer [primary key]
trip_id integer
user_id integer
trip_role integer
}
Table trip_roles {
id integer [primary key]
role_name varchar
}
Table trips {
-- Firebase cloud storage uses id_trip_name
id integer [primary key]
trip_name varchar unique
planned_date datetime -- Editable before trip happens
class varchar(1)
price_override float
}
Table trip_classes {
trip_class varchar(1) [primary key]
link varchar
price float
}
-- Each user has a role
Ref: users.role_id > web_roles.id
Ref: trip_user.trip_role > trip_roles.id
-- Multiple users/trips get mapped to eachother
Ref: trip_user.trip_id > trips.id
Ref: trip_user.user_id > users.id
Ref: trip_classes.trip_class < trips.class
*/