-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.sql
66 lines (66 loc) · 1.93 KB
/
database.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
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS `settings` (
`name` TEXT NOT NULL UNIQUE,
`value` TEXT,
PRIMARY KEY(`name`)
);
CREATE TABLE IF NOT EXISTS `photos` (
`id` INTEGER NOT NULL UNIQUE,
`hash` TEXT NOT NULL,
`original_name` TEXT NOT NULL,
`new_name` TEXT NOT NULL,
`import_datetime` TEXT,
`random` TEXT,
`import_year` INTEGER,
`import_month` INTEGER,
`import_day` INTEGER,
`import_hour` INTEGER,
`import_minute` INTEGER,
`import_second` INTEGER,
`exif_height` INTEGER,
`exif_width` INTEGER ,
`exif_time` TEXT,
`exif_brand` TEXT,
`exif_peripheral` TEXT,
`fav` INTEGER DEFAULT 0,
PRIMARY KEY(`id` AUTOINCREMENT)
);
CREATE TABLE IF NOT EXISTS `includes` (
`including_folder` INTEGER,
`included_folder` INTEGER,
FOREIGN KEY(`including_folder`) REFERENCES `folders`(`id`),
FOREIGN KEY(`included_folder`) REFERENCES `folders`(`id`),
PRIMARY KEY(`including_folder`,`included_folder`)
);
CREATE TABLE IF NOT EXISTS `holds` (
`held_folder` INTEGER,
`holded_album` INTEGER,
FOREIGN KEY(`holded_album`) REFERENCES `albums`(`id`),
FOREIGN KEY(`held_folder`) REFERENCES `folders`(`id`),
PRIMARY KEY(`held_folder`,`holded_album`)
);
CREATE TABLE IF NOT EXISTS `folders` (
`id` INTEGER NOT NULL UNIQUE,
`name` INTEGER,
PRIMARY KEY(`id` AUTOINCREMENT)
);
CREATE TABLE IF NOT EXISTS `contains` (
`containing_album` INTEGER,
`contained_photo` INTEGER,
FOREIGN KEY(`contained_photo`) REFERENCES `photos`(`id`),
FOREIGN KEY(`containing_album`) REFERENCES `albums`(`id`),
PRIMARY KEY(`containing_album`,`contained_photo`)
);
CREATE TABLE IF NOT EXISTS `albums` (
`id` INTEGER NOT NULL UNIQUE,
`name` TEXT,
PRIMARY KEY(`id` AUTOINCREMENT)
);
CREATE TABLE IF NOT EXISTS `includes` (
`including_folder` INTEGER,
`included_folder` INTEGER,
FOREIGN KEY(`including_folder`) REFERENCES `folders`(`id`),
FOREIGN KEY(`included_folder`) REFERENCES `folders`(`id`),
PRIMARY KEY(`including_folder`,`included_folder`)
);
COMMIT;