-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_tables.sql
131 lines (113 loc) · 2.48 KB
/
create_tables.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
-- Plants Primary Table
CREATE TABLE plants (
id SERIAL PRIMARY KEY,
preferred_name TEXT,
english_name TEXT,
maori_name TEXT,
latin_name TEXT,
location_found TEXT,
small_description TEXT,
long_description TEXT,
author TEXT,
last_modified DATE,
display_image TEXT,
plant_type TEXT
);
-- Months For Use
CREATE TABLE months_ready_for_use (
id SERIAL PRIMARY KEY,
plant_id INTEGER REFERENCES plants(id),
event TEXT,
start_month TEXT,
end_month TEXT
);
ALTER TABLE months_ready_for_use
ADD CONSTRAINT fk_mru_plants
FOREIGN KEY (plant_id)
REFERENCES plants(id);
-- Attachments
CREATE TABLE attachments (
id SERIAL PRIMARY KEY,
plant_id INTEGER REFERENCES plants(id),
path TEXT,
type TEXT,
meta JSON,
downloadable BOOLEAN,
);
ALTER TABLE attachments
ADD CONSTRAINT fk_attachments_plants
FOREIGN KEY (plant_id)
REFERENCES plants(id);
-- Medical Section
CREATE TABLE medical (
id SERIAL PRIMARY KEY,
plant_id INTEGER REFERENCES plants(id),
medical_type TEXT,
use_identifier TEXT,
use TEXT,
image TEXT,
preparation TEXT
);
ALTER TABLE medical
ADD CONSTRAINT fk_medical_plants
FOREIGN KEY (plant_id)
REFERENCES plants(id);
-- Craft Section
CREATE TABLE craft (
id SERIAL PRIMARY KEY,
plant_id INTEGER REFERENCES plants(id),
part_of_plant TEXT,
use_identifier TEXT,
use TEXT,
image TEXT,
additional_info TEXT
);
ALTER TABLE craft
ADD CONSTRAINT fk_craft_plants
FOREIGN KEY (plant_id)
REFERENCES plants(id);
-- Sources Section
CREATE TABLE source (
id SERIAL PRIMARY KEY,
plant_id INTEGER REFERENCES plants(id),
source_type TEXT,
data TEXT
);
ALTER TABLE source
ADD CONSTRAINT fk_source_plants
FOREIGN KEY (plant_id)
REFERENCES plants(id);
-- Custom Sections
CREATE TABLE custom (
id SERIAL PRIMARY KEY,
plant_id INTEGER REFERENCES plants(id),
title TEXT,
text TEXT
);
ALTER TABLE custom
ADD CONSTRAINT fk_custom_plants
FOREIGN KEY (plant_id)
REFERENCES plants(id);
-- Edible Section
CREATE TABLE edible (
id SERIAL PRIMARY KEY,
plant_id INTEGER REFERENCES plants(id),
part_of_plant TEXT,
use_identifier TEXT,
image_of_part TEXT,
nutrition TEXT,
preparation TEXT,
preparation_type TEXT
);
ALTER TABLE edible
ADD CONSTRAINT fk_edible_plants
FOREIGN KEY (plant_id)
REFERENCES plants(id);
-- User Auth
CREATE TABLE auth (
id SERIAL PRIMARY KEY,
entry TEXT,
type TEXT,
nickname TEXT,
permissions TEXT,
);