-
Notifications
You must be signed in to change notification settings - Fork 0
/
database statements.txt
281 lines (231 loc) · 7.08 KB
/
database statements.txt
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
CREATE TABLE Users(
Username varchar(15) NOT NULL,
Password varchar(100)NOT NULL,
Name varchar(15),
Email varchar,
Age int,
bestScore int,
Gender varchar(15),
Height DOUBLE PRECISION ,
Weight DOUBLE PRECISION ,
HeightUnitPreference varchar(2),
WeightUnitPreference varchar(2),
PRIMARY KEY (Username)
);
CREATE TABLE KeyValues(
valueName varchar(25) NOT NULL,
Value DOUBLE PRECISION,
PRIMARY KEY(valueName)
);
INSERT INTO KeyValues(valueName, Value)
VALUES ('BMI_UNDERWEIGHT',18.5 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('BMI_NORMAL_lower',18.5 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('BMI_NORMAL_upper',24.9 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('BMI_OVERWEIGHT_lower',25 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('BMI_OVERWEIGHT_upper',29.9 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('BMI_OBESE_lower',30 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('BMI_OBESE_upper',39.9 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('BMI_MORBIDLY_OBESE_upper',40 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('HEIGHT_MAX_CM',250 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('HEIGHT_MAX_IN',96 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('WEIGHT_MAX_KG',120 );
INSERT INTO KeyValues(valueName, Value)
VALUES ('WEIGHT_MAX_LB',280 );
CREATE TABLE FitBitData(
Username varchar(15) NOT NULL,
Date date NOT NULL,
steps DOUBLE PRECISION,
stepGoal DOUBLE PRECISION,
distance DOUBLE PRECISION ,
distanceGoal DOUBLE PRECISION ,
calories DOUBLE PRECISION,
caloriesGoal DOUBLE PRECISION,
activeMinutes DOUBLE PRECISION,
restingHR DOUBLE PRECISION ,
PRIMARY KEY(Username, Date ),
FOREIGN KEY (Username) REFERENCES Users
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE FitBitData2(
Username varchar(15) NOT NULL,
Date date NOT NULL,
steps varchar(40),
stepGoal varchar(40),
distance varchar(40) ,
distanceGoal varchar(40) ,
calories varchar(40),
caloriesGoal varchar(40),
activeMinutes varchar(40),
restingHR varchar(40) ,
PRIMARY KEY(Username, Date ),
FOREIGN KEY (Username) REFERENCES Users
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE FitBitUSERTOKENS(
Username varchar(15) NOT NULL PRIMARY KEY,
token varchar(400),
FOREIGN KEY (Username) REFERENCES Users
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE ExerciseType(
Type varchar(15) NOT NULL PRIMARY KEY
);
CREATE TABLE SleepTrackerTable(
Username varchar(15) NOT NULL,
Date Date,
Value DOUBLE PRECISION ,
FOREIGN KEY (Username) REFERENCES Users(Username)
);
CREATE TABLE WaterTrackerTable(
Username varchar(15) NOT NULL,
Date Date,
Value DOUBLE PRECISION ,
FOREIGN KEY (Username) REFERENCES Users(Username)
);
CREATE TABLE Groups
(
GroupName varchar(15) NOT NULL PRIMARY KEY,
Admin varchar(15)
);
CREATE TABLE GroupUsers
(
GroupName varchar(15) NOT NULL,
Username varchar(15) NOT NULL,
FOREIGN KEY (GroupName) REFERENCES Groups
ON DELETE CASCADE
ON UPDATE CASCADE,
PRIMARY KEY(GroupName ,Username ),
FOREIGN KEY (Username) REFERENCES Users
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE GroupGoals
(
GroupName varchar(15) NOT NULL,
GoalName varchar(15) NOT NULL PRIMARY KEY,
ExerciseType varchar(15) NOT NULL,
Duration float NOT NULL,
StartDate date NOT NULL,
EndDate date NOT NULL,
FOREIGN KEY (GroupName) REFERENCES Groups
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE ExerciseTracker
(
Username varchar(15) NOT NULL,
ExerciseDate date NOT NULL,
ExerciseType varchar(15) NOT NULL,
ExerciseStartTime time NOT NULL,
ExerciseEndTime time NOT NULL,
PRIMARY KEY(Username,ExerciseDate,ExerciseType,ExerciseStartTime),
FOREIGN KEY (Username) REFERENCES Users(Username)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE ExerciseGoal
(
Username varchar(15) NOT NULL PRIMARY KEY,
Goal float NOT NULL,
GoalStart date,
GoalEnd date,
FOREIGN KEY (Username) REFERENCES Users(Username)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE TABLE WeightTrackerTable(
Username varchar(15) NOT NULL,
Date Date,
targetWeight DOUBLE PRECISION,
currentWeight DOUBLE PRECISION,
FOREIGN KEY (Username) REFERENCES Users(Username)
);
CREATE TABLE FoodTrackerTable(
Username varchar(15) NOT NULL,
Date Date,
MealType varchar(15),
FoodName varchar(15),
Calorie int,
FOREIGN KEY (Username) REFERENCES Users(Username)
);
CREATE TABLE Meals
(
id SERIAL,
Name varchar(15),
calorie int,
PRIMARY KEY(id)
);
create table reminder(
username varchar not null,
Date date not null,
time time not null,
Event varchar not null,
Remarks varchar,
Type varchar not null,
email boolean not null,
constraint reminder_user_username_fkey foreign key(username)
references users(username)
ON UPDATE cascade
ON DELETE cascade,
primary key(username,date,time,event)
);
Create table quiz(
question varchar not null,
selection1 varchar not null,
selection2 varchar not null,
selection3 varchar not null,
selection4 varchar not null,
number integer not null
);
insert into quiz (question,selection1,selection2,selection3,selection4,number)
Values('What are some things you can do to help support your brain health?',
'Eating nutritious foods',
'Regular physical activity',
'Doing mental exercises like crossword puzzles and other games',
'All of the above',3),
('How can you ensure that your wishes about your health care are known by your close family or friends?',
'By writing down my wishes regarding end of life care and specific medical procedures.',
'By choosing a decision maker I can trust.',
'By making important health care decisions now',
'A,B and C are correct.',
3),
('Depression in older adults can be hard to detect. However the earlier it is detected, the easier it can be to treat. Which of the following are symptoms of depression?',
'Decreased interest and pleasure in usual activities',
'Reports of pain',
'Complaints about memory problems',
'All of the above',3),
('What is the recommended amount of physical activity for adults per week (as per the Canadian Physical Activity Guidelines)?',
'60 minutes of moderate to vigorous intensity aerobic physical activity per week',
'150 minutes of moderate to vigorous',
'120 minutes of moderate to vigorous',
'90 minutes of moderate to vigorous',1),
('Eating a healthy diet can help reduce the risk of developing health problems, such as:',
'Eating nutritious foods',
'Regular physical activity',
'Doing mental exercises like crossword puzzles and other games',
'All of the above',3),
('You can help to prevent falls by:',
'Some forms of cancer',
'High blood pressure',
'Heart & respiratory disease',
'All of the above',4),
('What are some things you can do to help support your brain health?',
'Scheduling regular vision checkups and correcting any vision problems',
'Maintaining flexibility, balance and increasing muscle strength',
'Reducing trip and slip hazards in your home and outdoors',
'All of the above',4),
('Did you know that if everyone ate five to ten servings of vegetables and fruit each day, the current cancer rate could be reduced by as much as:',
'20%','15%','10%','5%',0);