-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_tables.sql
154 lines (138 loc) · 4.22 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
PRAGMA foreign_keys = ON;
CREATE TABLE IF NOT EXISTS attribute (
token TEXT PRIMARY KEY,
name TEXT,
description TEXT
);
CREATE TABLE IF NOT EXISTS calibrated_sensor (
token TEXT PRIMARY KEY,
sensor_token TEXT,
translation FLOAT [3],
rotation FLOAT [4],
camera_intrinsic FLOAT [3] [3],
FOREIGN KEY (sensor_token) REFERENCES sensor(token)
);
CREATE TABLE IF NOT EXISTS category (
token TEXT PRIMARY KEY,
name TEXT,
description TEXT,
"index" INTEGER
);
CREATE TABLE IF NOT EXISTS ego_pose (
token TEXT PRIMARY KEY,
translation FLOAT [3],
rotation FLOAT [4],
timestamp INTEGER
);
CREATE TABLE IF NOT EXISTS instance (
token TEXT PRIMARY KEY,
category_token TEXT,
nbr_annotations INTEGER,
first_annotation_token TEXT,
last_annotation_token TEXT,
FOREIGN KEY (category_token) REFERENCES category(token),
FOREIGN KEY (first_annotation_token) REFERENCES sample_annotation(token),
FOREIGN KEY (last_annotation_token) REFERENCES sample_annotation(token)
);
CREATE TABLE IF NOT EXISTS lidarseg (
token TEXT PRIMARY KEY,
filename TEXT,
sample_data_token TEXT,
FOREIGN KEY (sample_data_token) REFERENCES sample_data(token)
);
CREATE TABLE IF NOT EXISTS log (
token TEXT PRIMARY KEY,
logfile TEXT,
vehicle TEXT,
date_captured TEXT,
location TEXT
);
CREATE TABLE IF NOT EXISTS map (
token TEXT PRIMARY KEY,
category TEXT,
filename TEXT
);
-- Handle the one-to-many relationship BETWEEN map AND logs
CREATE TABLE IF NOT EXISTS map_log (
map_token TEXT,
log_token TEXT,
FOREIGN KEY (map_token) REFERENCES map(token),
FOREIGN KEY (log_token) REFERENCES log(token),
PRIMARY KEY (map_token, log_token)
);
CREATE TABLE IF NOT EXISTS sample (
token TEXT PRIMARY KEY,
timestamp INTEGER,
scene_token TEXT,
next TEXT,
prev TEXT,
FOREIGN KEY (scene_token) REFERENCES scene(token),
FOREIGN KEY (next) REFERENCES sample(token),
FOREIGN KEY (prev) REFERENCES sample(token)
);
CREATE TABLE IF NOT EXISTS sample_annotation (
token TEXT PRIMARY KEY,
sample_token TEXT,
instance_token TEXT,
visibility_token TEXT,
translation FLOAT [3],
size FLOAT [3],
rotation FLOAT [4],
num_lidar_pts INTEGER,
num_radar_pts INTEGER,
next TEXT,
prev TEXT,
FOREIGN KEY (sample_token) REFERENCES sample(token),
FOREIGN KEY (instance_token) REFERENCES instance(token),
FOREIGN KEY (visibility_token) REFERENCES visibility(token),
FOREIGN KEY (next) REFERENCES sample_annotation(token),
FOREIGN KEY (prev) REFERENCES sample_annotation(token)
);
-- Handle the one-to-many relationship BETWEEN sample_annotations AND attributes
CREATE TABLE IF NOT EXISTS sample_annotation_attribute (
sample_annotation_token TEXT,
attribute_token TEXT,
FOREIGN KEY (sample_annotation_token) REFERENCES sample_annotation(token),
FOREIGN KEY (attribute_token) REFERENCES attribute(token),
PRIMARY KEY (sample_annotation_token, attribute_token)
);
CREATE TABLE IF NOT EXISTS sample_data (
token TEXT PRIMARY KEY,
sample_token TEXT,
ego_pose_token TEXT,
calibrated_sensor_token TEXT,
filename TEXT,
fileformat TEXT,
width INTEGER,
height INTEGER,
timestamp INTEGER,
is_key_frame BOOLEAN,
next TEXT,
prev TEXT,
FOREIGN KEY (sample_token) REFERENCES sample(token),
FOREIGN KEY (ego_pose_token) REFERENCES ego_pose(token),
FOREIGN KEY (calibrated_sensor_token) REFERENCES calibrated_sensor(token),
FOREIGN KEY (next) REFERENCES sample_data(token),
FOREIGN KEY (prev) REFERENCES sample_data(token)
);
CREATE TABLE IF NOT EXISTS scene (
token TEXT PRIMARY KEY,
name TEXT,
description TEXT,
log_token TEXT,
nbr_samples INTEGER,
first_sample_token TEXT,
last_sample_token TEXT,
FOREIGN KEY (log_token) REFERENCES log(token) FOREIGN KEY (first_sample_token) REFERENCES sample(token),
FOREIGN KEY (last_sample_token) REFERENCES sample(token)
);
CREATE TABLE IF NOT EXISTS sensor (
token TEXT PRIMARY KEY,
channel TEXT,
modality TEXT CHECK(modality IN ('camera', 'lidar', 'radar'))
);
CREATE TABLE IF NOT EXISTS visibility (
token TEXT PRIMARY KEY,
level TEXT,
description TEXT
);