-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQL_commands.sql
176 lines (162 loc) · 9.22 KB
/
SQL_commands.sql
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
ALTER TABLE "APP".REPORTTABLE
ADD CONSTRAINT FK_REPORTUSER
FOREIGN KEY(USERID)
REFERENCES "APP".USERTABLE (USERID)
ON DELETE CASCADE;
ALTER TABLE "APP".CONSUMPTIONTABLE
ADD CONSTRAINT FK_CONSUMEPTIONUSER
FOREIGN KEY(USERID)
REFERENCES "APP".USERTABLE (USERID)
ON DELETE CASCADE;
ALTER TABLE "APP".CONSUMPTIONTABLE
ADD CONSTRAINT FK_CONSUMPTIONFOOD
FOREIGN KEY(FOODID)
REFERENCES "APP".FOODTABLE (ID)
ON DELETE CASCADE;
ALTER TABLE "APP".CREDENTIALTABLE
ADD CONSTRAINT FK_CREDENTIALUSER
FOREIGN KEY(USERID)
REFERENCES "APP".USERTABLE (USERID)
ON DELETE CASCADE;
ALTER TABLE "APP".USERTABLE
ADD CONSTRAINT FK_USERCREDENTIAL
FOREIGN KEY(USERID)
REFERENCES "APP".CREDENTIALTABLE (USERID)
ON DELETE CASCADE;
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (5, 'VC665', '$6$rounds=5000$usesomesillystri$D4IrlXatmP7rx3P3InaxBeoomnAihCKRVQP22JZ6', '2010-04-02');
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (4, 'AS553', '$6$rounds=5000$usesomesillystri$D4Ir', '2012-04-02');
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (3, 'ASCSAC', '$6$rounds=5000$usesomesillyGERGE', '2013-04-02');
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (2, 'CC32', '$6$rounds=5000$usesomesilly', '2015-04-12');
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (1, 'DRAGONHUNTER', '$6$rounds=5000$usesomesillystri$D4IrlXatmP7rx3P3InaxBeoomnAroIuUUBOov1i.S5KPgErtP/EN5mcO.ChWQW21', '2009-04-02');
CREATE TABLE "APP".REPORTTABLE
(
ID INTEGER NOT NULL,
USERID INTEGER,
RDATE DATE,
CALCONSUMED INTEGER,
CALBURNED INTEGER,
STEPSTAKEN INTEGER,
CALGOAL INTEGER,
PRIMARY KEY (ID)
);
CREATE TABLE "APP".FOODTABLE
(
ID INTEGER NOT NULL,
FOODNAME VARCHAR(50),
CATEGORY VARCHAR(50),
CALAMOUNT INTEGER,
SERVINGUNIT VARCHAR(20),
SERVINGAMOUNT INTEGER,
FAT INTEGER,
PRIMARY KEY (ID)
);
CREATE TABLE "APP".CREDENTIALTABLE
(
ID INTEGER NOT NULL,
USERNAME VARCHAR (50),
PASSWDHASH VARCHAR (300),
SIGNUPDATE DATE,
PRIMARY KEY (ID)
);
CREATE TABLE "APP".USERTABLE
(
ID INTEGER NOT NULL,
NAME VARCHAR(50),
SURNNAME VARCHAR(50),
EMAIL VARCHAR(50),
DOB DATE,
HEIGHT INTEGER,
WEIGHT INTEGER,
GENDER VARCHAR(1),
ADDRESS VARCHAR(80),
POSTCODE VARCHAR(4),
LEVELOFFACTIVITY INTEGER,
CHECK (LEVELOFFACTIVITY >=1 AND LEVELOFFACTIVITY <=5),
STEPSPERMILE INTEGER,
PRIMARY KEY (ID)
);
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (1, 'DRAGONHUNTER', '$6$rounds=5000$usesomesillystri$D4IrlXatmP7rx3P3InaxBeoomnAihCKRVQP22JZ6EY47Wc6BkroIuUUBOov1i.S5KPgErtP/EN5mcO.ChWQW21', '2009-04-02')
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (2, 'CC32', '$6$rounds=5000$usesomesilly', '2015-04-12')
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (3, 'ASCSAC', '$6$rounds=5000$usesomesillyGERGE', '2013-04-02')
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (4, 'AS553', '$6$rounds=5000$usesomesillystri$D4Ir', '2012-04-02')
INSERT INTO APP.CREDENTIALTABLE (USERID, USERNAME, PASSWDHASH, SIGNUPDATE)
VALUES (5, 'VC665', '$6$rounds=5000$usesomesillystri$D4IrlXatmP7rx3P3InaxBeoomnAihCKRVQP22JZ6', '2010-04-02')
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (1, 'Bread, white or whole wheat', 'diet', 40, 'slice', 1, 0)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (2, 'Bread, white or whole wheat', 'regular', 70, 'slice', 1, 1)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (3, 'Butter', 'regular', 34, 'tsp', 1, 4)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (4, 'Butter', 'regular', 102, 'Ttsp', 1, 12)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (5, 'Butter', 'whipped', 23, 'tsp', 1, 3)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (6, 'Buttermilk', '1/2 %fat', 110, 'cup', 1, 1)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (7, 'Buttermilk', '1 1/2 %fat', 120, 'cup', 1, 4)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (8, 'Buttermilk', 'whole', 149, 'cup', 1, 8)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (9, 'Crackers, regular', 'butter, round', 122, 'pc', 8, 7)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (10, 'Crackers, regular', 'cheese, rounds', 121, 'pc', 8, 6)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (11, 'Crackers, regular', 'club', 126, 'pc', 8, 6)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (12, 'Crackers, regular', 'Cuban crackers', 127, 'pc', 6, 3)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (13, 'Crackers, regular', 'goldfish', 82, 'pc', 30, 2)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (14, 'Crackers, regular', 'graham', 118, 'pc', 4, 3)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (15, 'Crackers, regular', 'matzo', 112, 'pc', 1, 0)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (16, 'Crackers, regular', 'Melba', 71, 'pc', 6, 0)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (17, 'Crackers, regular', 'oyster', 84, 'pc', 20, 3)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (18, 'Crackers, regular', 'rice cake', 70, 'pc', 2, 1)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (19, 'Crackers, regular', 'rice crakers', 111, 'oz', 1, 0)
INSERT INTO APP.FOODTABLE (ID, FOODNAME, CATEGORY, CALAMOUNT, SERVINGUNIT, SERVINGAMOUNT, FAT)
VALUES (20, 'Crackers, regular', 'Triscuits', 117, 'pc', 6, 4)
INSERT INTO APP.CONSUMPTIONTABLE (ID, FOODID, USERID, CDATE, SERVINGUNIT, SERVINGAMOUNT)
VALUES (1, 1, 1, '2019-04-03', 'slice', 2);
INSERT INTO APP.CONSUMPTIONTABLE (ID, FOODID, USERID, CDATE, SERVINGUNIT, SERVINGAMOUNT)
VALUES (2, 1, 2, '2019-04-03', 'slice', 1);
INSERT INTO APP.CONSUMPTIONTABLE (ID, FOODID, USERID, CDATE, SERVINGUNIT, SERVINGAMOUNT)
VALUES (3, 2, 3, '2019-04-03', 'slice', 4);
INSERT INTO APP.CONSUMPTIONTABLE (ID, FOODID, USERID, CDATE, SERVINGUNIT, SERVINGAMOUNT)
VALUES (4, 1, 4, '2019-04-03', 'slice', 3);
INSERT INTO APP.CONSUMPTIONTABLE (ID, FOODID, USERID, CDATE, SERVINGUNIT, SERVINGAMOUNT)
VALUES (5, 2, 5, '2019-04-03', 'slice', 5);
INSERT INTO APP.REPORTTABLE (ID, USERID, RDATE, CALCONSUMED, CALBURNED, STEPSTAKEN, CALGOAL)
VALUES (1, 1, '2019-04-04', 2100, 1000, 5600, 5000);
INSERT INTO APP.REPORTTABLE (ID, USERID, RDATE, CALCONSUMED, CALBURNED, STEPSTAKEN, CALGOAL)
VALUES (2, 1, '2019-04-03', 2500, 1200, 5409, 4000);
INSERT INTO APP.REPORTTABLE (ID, USERID, RDATE, CALCONSUMED, CALBURNED, STEPSTAKEN, CALGOAL)
VALUES (3, 2, '2019-04-04', 2035, 800, 6789, 4000);
INSERT INTO APP.REPORTTABLE (ID, USERID, RDATE, CALCONSUMED, CALBURNED, STEPSTAKEN, CALGOAL)
VALUES (4, 3, '2019-04-04', 2000, 560, 8797, 4500);
INSERT INTO APP.REPORTTABLE (ID, USERID, RDATE, CALCONSUMED, CALBURNED, STEPSTAKEN, CALGOAL)
VALUES (5, 4, '2019-04-04', 1890, 1389, 4378, 4800);
INSERT INTO APP.USERTABLE (ID, "NAME", SURNNAME, EMAIL, DOB, HEIGHT, WEIGHT, GENDER, ADDRESS, POSTCODE, LEVELOFFACTIVITY, STEPSPERMILE)
VALUES (1, 'Andy', 'Chen', '[email protected]', '1990-04-03', 180, 89, 'M', '8 GRANGE RD, VIC', '3163', 2, 1200);
INSERT INTO APP.USERTABLE (ID, "NAME", SURNNAME, EMAIL, DOB, HEIGHT, WEIGHT, GENDER, ADDRESS, POSTCODE, LEVELOFFACTIVITY, STEPSPERMILE)
VALUES (2, 'Mary', 'Abidal', '[email protected]', '1999-04-03', 169, 69, 'F', '9 GRANGE RD, VIC', '3163', 3, 1300);
INSERT INTO APP.USERTABLE (ID, "NAME", SURNNAME, EMAIL, DOB, HEIGHT, WEIGHT, GENDER, ADDRESS, POSTCODE, LEVELOFFACTIVITY, STEPSPERMILE)
VALUES (3, 'Jane', 'Smith', '[email protected]', '1995-04-03', 175, 66, 'F', '10 GRANGE RD, VIC', '3163', 3, 1400);
INSERT INTO APP.USERTABLE (ID, "NAME", SURNNAME, EMAIL, DOB, HEIGHT, WEIGHT, GENDER, ADDRESS, POSTCODE, LEVELOFFACTIVITY, STEPSPERMILE)
VALUES (4, 'John', 'Freeman', '[email protected]', '1991-04-03', 183, 81, 'M', '11 GRANGE RD, VIC', '3163', 2, 1500);
INSERT INTO APP.USERTABLE (ID, "NAME", SURNNAME, EMAIL, DOB, HEIGHT, WEIGHT, GENDER, ADDRESS, POSTCODE, LEVELOFFACTIVITY, STEPSPERMILE)
VALUES (5, 'Kenny', 'Garnder', '[email protected]', '1988-04-03', 190, 90, 'M', '12 GRANGE RD, VIC', '3163', 5, 1600);