-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
25 lines (22 loc) · 758 Bytes
/
init.sql
File metadata and controls
25 lines (22 loc) · 758 Bytes
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
CREATE TABLE exercises (
exercise_name TEXT PRIMARY KEY NOT NULL, exercise_link TEXT
);
CREATE TABLE exercise_aliases (
exercise_alias TEXT PRIMARY KEY NOT NULL,
exercise_name TEXT NOT NULL,
FOREIGN KEY (exercise_name) REFERENCES exercises(exercise_name) ON DELETE CASCADE
);
CREATE TABLE users (
user_id INTEGER PRIMARY KEY NOT NULL,
user_name TEXT NULL,
first_name TEXT NOT NULL,
last_name TEXT NULL
);
CREATE TABLE user_reps (
user_id INTEGER NOT NULL,
exercise_name TEXT NOT NULL,
reps INTEGER NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE,
FOREIGN KEY (exercise_name) REFERENCES exercises(exercise_name) ON DELETE CASCADE,
PRIMARY KEY (user_id, exercise_name)
);