-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtables.sql
More file actions
31 lines (25 loc) · 752 Bytes
/
tables.sql
File metadata and controls
31 lines (25 loc) · 752 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
26
27
28
29
30
31
-- SQLite
PRAGMA foreign_keys = ON;
CREATE TABLE MainTasks (
mainTask_id integer PRIMARY KEY,
subject text NOT NULL,
description text,
done boolean CHECK(done <=1 AND done >=0) DEFAULT 0
);
CREATE TABLE SubTasks (
subTask_id integer PRIMARY KEY,
mainTask_id integer NOT NULL,
subject text NOT NULL,
done boolean CHECK(done <=1 AND done >=0) DEFAULT 0,
FOREIGN KEY (mainTask_id) REFERENCES MainTasks(mainTask_id) ON DELETE CASCADE
);
INSERT INTO MainTasks (subject, description)
VALUES
('MainTask No 1', 'Blabla description'),
('MainTask No 2', 'Blabla description'),
('MainTask No 3', 'Blabla description');
INSERT INTO SubTasks (subject, mainTask_id)
VALUES
('SubTask No 1', 1),
('SubTask No 2', 2),
('SubTask No 3', 2);