-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
47 lines (41 loc) · 1.09 KB
/
schema.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
CREATE DATABASE IF NOT EXISTS darwinFit;
USE darwinFit;
CREATE TABLE if not exists users (
id int NOT NULL AUTO_INCREMENT,
username VARCHAR(255) NOT NULL UNIQUE,
age int NOT NULL,
weight int NOT NULL,
height int NOT NULL,
gender VARCHAR(20) NOT NULL,
avg_calories int NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE if not exists food_history (
id int NOT NULL AUTO_INCREMENT,
food_name VARCHAR(255) NOT NULL,
user_id int NOT NULL,
date date NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES users(id)
);
CREATE TABLE if not exists exercise_history (
id int NOT NULL AUTO_INCREMENT,
exercise_name VARCHAR(255) NOT NULL,
user_id int NOT NULL,
date date NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES users(id)
);
CREATE TABLE if not exists daily (
id int NOT NULL AUTO_INCREMENT,
user_id int NOT NULL,
date date NOT NULL,
burnt int NOT NULL,
calories int NOT NULL,
total_fat int NOT NULL,
total_carbohydrate int NOT NULL,
protein int NOT NULL,
sugars int NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (user_id) REFERENCES users(id)
);