forked from ProjectSidewalk/SidewalkWebpageDC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13.sql
117 lines (99 loc) · 3.63 KB
/
13.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
# --- !Ups
DROP TABLE sidewalk_edge_accessibility_feature;
DROP TABLE accessibility_feature;
INSERT INTO label_type VALUES (8, 'Problem', 'Composite type: represents cluster of NoCurbRamp, Obstacle, and/or SurfaceProblem labels');
CREATE TABLE user_clustering_session
(
user_clustering_session_id SERIAL NOT NULL,
is_anonymous BOOLEAN NOT NULL,
user_id TEXT,
ip_address TEXT,
time_created timestamp default current_timestamp NOT NULL,
PRIMARY KEY (user_clustering_session_id),
FOREIGN KEY (user_id) REFERENCES "user" (user_id)
);
CREATE TABLE user_attribute
(
user_attribute_id SERIAL NOT NULL,
user_clustering_session_id INT NOT NULL,
clustering_threshold DOUBLE PRECISION NOT NULL,
label_type_id INT NOT NULL,
region_id INT NOT NULL,
lat DOUBLE PRECISION NOT NULL,
lng DOUBLE PRECISION NOT NULL,
severity INT,
temporary BOOLEAN NOT NULL,
PRIMARY KEY (user_attribute_id),
FOREIGN KEY (user_clustering_session_id) REFERENCES user_clustering_session(user_clustering_session_id),
FOREIGN KEY (label_type_id) REFERENCES label_type(label_type_id),
FOREIGN KEY (region_id) REFERENCES region(region_id)
);
CREATE TABLE user_attribute_label
(
user_attribute_label_id SERIAL NOT NULL,
user_attribute_id INT NOT NULL,
label_id INT NOT NULL,
PRIMARY KEY (user_attribute_label_id),
FOREIGN KEY (user_attribute_id) REFERENCES user_attribute(user_attribute_id),
FOREIGN KEY (label_id) REFERENCES label(label_id)
);
CREATE TABLE global_clustering_session
(
global_clustering_session_id SERIAL NOT NULL,
region_id INT NOT NULL,
time_created timestamp default current_timestamp NOT NULL,
PRIMARY KEY (global_clustering_session_id),
FOREIGN KEY (region_id) REFERENCES region(region_id)
);
CREATE TABLE global_attribute
(
global_attribute_id SERIAL NOT NULL,
global_clustering_session_id INT NOT NULL,
clustering_threshold DOUBLE PRECISION NOT NULL,
label_type_id INT NOT NULL,
region_id INT NOT NULL,
lat DOUBLE PRECISION NOT NULL,
lng DOUBLE PRECISION NOT NULL,
severity INT,
temporary BOOLEAN NOT NULL,
PRIMARY KEY (global_attribute_id),
FOREIGN KEY (global_clustering_session_id) REFERENCES global_clustering_session(global_clustering_session_id),
FOREIGN KEY (label_type_id) REFERENCES label_type(label_type_id),
FOREIGN KEY (region_id) REFERENCES region(region_id)
);
CREATE TABLE global_attribute_user_attribute
(
global_attribute_user_attribute_id SERIAL NOT NULL,
global_attribute_id INT NOT NULL,
user_attribute_id INT NOT NULL,
PRIMARY KEY (global_attribute_user_attribute_id),
FOREIGN KEY (user_attribute_id) REFERENCES user_attribute(user_attribute_id),
FOREIGN KEY (global_attribute_id) REFERENCES global_attribute(global_attribute_id)
);
# --- !Downs
DROP TABLE global_attribute_user_attribute;
DROP TABLE global_attribute;
DROP TABLE global_clustering_session;
DROP TABLE user_attribute_label;
DROP TABLE user_attribute;
DROP TABLE user_clustering_session;
DELETE FROM label_type WHERE label_type.label_type = 'Problem';
CREATE TABLE accessibility_feature
(
accessibility_feature_id SERIAL NOT NULL,
geom public.geometry,
label_type_id INTEGER,
x DOUBLE PRECISION,
y DOUBLE PRECISION,
PRIMARY KEY (accessibility_feature_id),
FOREIGN KEY (label_type_id) REFERENCES label_type (label_type_id)
);
CREATE TABLE sidewalk_edge_accessibility_feature
(
sidewalk_edge_accessibility_feature_id SERIAL NOT NULL,
sidewalk_edge_id INTEGER,
accessibility_feature_id INTEGER,
PRIMARY KEY (accessibility_feature_id),
FOREIGN KEY (sidewalk_edge_id) REFERENCES sidewalk_edge (sidewalk_edge_id),
FOREIGN KEY (accessibility_feature_id) REFERENCES accessibility_feature (accessibility_feature_id)
);