-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDB.sql
209 lines (203 loc) · 5.32 KB
/
DB.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
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
CREATE TABLE
IF NOT EXISTS Workouts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
start_time DATETIME NOT NULL,
plan_id TEXT DEFAULT NULL,
FOREIGN KEY (plan_id) REFERENCES WorkoutPlan (id)
);
CREATE TABLE
IF NOT EXISTS Exercises (id TEXT PRIMARY KEY);
CREATE TABLE
IF NOT EXISTS ExerciseUses (
id INTEGER PRIMARY KEY AUTOINCREMENT,
workout_id INTEGER NOT NULL,
exercise_id TEXT NOT NULL,
FOREIGN KEY (workout_id) REFERENCES Workouts (id),
FOREIGN KEY (exercise_id) REFERENCES Exercises (id)
);
CREATE TABLE
IF NOT EXISTS Sets (
selected BOOLEAN NOT NULL DEFAULT TRUE,
id INTEGER PRIMARY KEY AUTOINCREMENT,
exercise_use_id INTEGER NOT NULL,
reps INTEGER NOT NULL,
weight REAL NOT NULL,
FOREIGN KEY (exercise_use_id) REFERENCES ExerciseUses (id)
);
CREATE TABLE
IF NOT EXISTS ActiveWorkout (
id INTEGER PRIMARY KEY CHECK (id = 1),
active_workout_id INTEGER NOT NULL,
FOREIGN KEY (active_workout_id) REFERENCES Workouts (id)
);
CREATE TABLE
IF NOT EXISTS WorkoutPlan (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
program_id TEXT NOT NULL,
FOREIGN KEY (program_id) REFERENCES PROGRAM (id)
);
CREATE TABLE
IF NOT EXISTS PROGRAM (id TEXT PRIMARY KEY)
--Test Data
--
-- INSERT INTO
-- Workouts (start_time)
-- VALUES
-- ('2024-12-18');
-- INSERT INTO
-- Workouts (start_time)
-- VALUES
-- ('2024-12-19');
-- INSERT INTO
-- Workouts (start_time)
-- VALUES
-- ('2024-12-20');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Bench Press');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Shoulder Press');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Tricep Dips');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Deadlift');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Pull Up');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Bicep Curl');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Squat');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Leg Press');
-- INSERT INTO
-- Exercises (id)
-- VALUES
-- ('Calf Raise');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (1, 'Bench Press');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (1, 'Shoulder Press');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (1, 'Tricep Dips');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (2, 'Deadlift');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (2, 'Pull Up');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (2, 'Bicep Curl');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (3, 'Squat');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (3, 'Leg Press');
-- INSERT INTO
-- ExerciseUses (workout_id, exercise_id)
-- VALUES
-- (3, 'Calf Raise');
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (1, 10, 65);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (1, 8, 65);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (2, 10, 30);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (2, 8, 30);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (3, 12, 10);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (3, 10, 10);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (4, 5, 100);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (4, 5, 100);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (5, 8, 0);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (5, 6, 0);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (6, 12, 20);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (6, 10, 20);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (7, 10, 80);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (7, 8, 80);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (8, 12, 120);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (8, 10, 120);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (9, 15, 40);
-- INSERT INTO
-- Sets (exercise_use_id, reps, weight)
-- VALUES
-- (9, 12, 40);
-- Insert Into
-- ActiveWorkout (active_workout_id, id)
-- Values
-- (3, 1);