-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit_db.sql
162 lines (141 loc) · 4.31 KB
/
init_db.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
155
156
157
158
159
160
161
162
ALTER SESSION SET NLS_DATE_FORMAT='DD-MM-YYYY';
CREATE TABLE SpatialEntity (
id NUMBER NOT NULL,
name VARCHAR(30) NOT NULL,
geometry SDO_GEOMETRY NOT NULL,
validFrom DATE NULL,
validTo DATE NULL,
entityType VARCHAR(10) CHECK(entityType in ('country', 'countryRec', 'river', 'place', 'largePlace')),
color VARCHAR(15),
CHECK(validTo >= validFrom),
CONSTRAINT PKSpatialEntity PRIMARY KEY (id)
);
CREATE TABLE Picture (
id NUMBER NOT NULL,
description VARCHAR(255),
pictureType VARCHAR(10) CHECK( pictureType in ('normal', 'flag')),
createdAt DATE,
spatialEntityId NUMBER,
img ORDSYS.ORDIMAGE,
img_si ORDSYS.SI_STILLIMAGE,
img_ac ORDSYS.SI_AVERAGECOLOR,
img_ch ORDSYS.SI_COLORHISTOGRAM,
img_pc ORDSYS.SI_POSITIONALCOLOR,
img_tx ORDSYS.SI_TEXTURE,
CONSTRAINT PKPicture PRIMARY KEY (id),
CONSTRAINT FKPictureSpatialEntity FOREIGN KEY (spatialEntityId) REFERENCES SpatialEntity(id) ON DELETE CASCADE
);
CREATE TABLE Description (
id NUMBER NOT NULL,
description VARCHAR(255),
validFrom DATE NULL,
validTo DATE NULL,
spatialEntityId NUMBER,
CHECK(validTo >= validFrom),
CONSTRAINT PKDescription PRIMARY KEY(id),
CONSTRAINT FKDescriptionSpatialEntity FOREIGN KEY (spatialEntityId) REFERENCES SpatialEntity(id) ON DELETE CASCADE
);
CREATE TABLE BlindMapResult (
id NUMBER NOT NULL,
person VARCHAR(30) NOT NULL,
points NUMBER NOT NULL,
CONSTRAINT PKBlindMapResult PRIMARY KEY (id)
);
DELETE FROM USER_SDO_GEOM_METADATA WHERE
TABLE_NAME = 'SPATIALENTITY' AND COLUMN_NAME = 'GEOMETRY';
INSERT INTO USER_SDO_GEOM_METADATA VALUES (
'SPATIALENTITY', 'geometry',
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', 0, 1000, 0.001), SDO_DIM_ELEMENT('Y', 0, 1000, 0.001)),
NULL
);
CREATE INDEX SP_INDEX_SpatialEntitiesGeometry ON SpatialEntity (geometry) indextype is MDSYS.SPATIAL_INDEX ;
COMMIT;
INSERT INTO SpatialEntity(id, name, geometry, validFrom, validTo, entityType, color) VALUES (
1,
'Brno',
SDO_GEOMETRY(2003, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1003, 4),
SDO_ORDINATE_ARRAY(75, 15, 75, 95, 115, 55)
),
TO_DATE('27-10-1500', 'dd-mm-yyyy'),
TO_DATE('27-10-2200', 'dd-mm-yyyy'),
'largePlace',
'salmon'
);
INSERT INTO Description(id, description, validFrom, validTo, spatialEntityId) VALUES (
1,
'The best city on Pandora!',
TO_DATE('11-11-1500', 'dd-mm-yyyy'),
TO_DATE('11-11-2200', 'dd-mm-yyyy'),
1
);
INSERT INTO SpatialEntity(id, name, geometry, validFrom, validTo, entityType, color) VALUES (
2,
'Praha',
SDO_GEOMETRY(2001, NULL,
SDO_POINT_TYPE(242, 142, NULL),
NULL, NULL
),
TO_DATE('27-10-1100', 'dd-mm-yyyy'),
TO_DATE('27-10-2300', 'dd-mm-yyyy'),
'place',
'lightsalmon'
);
INSERT INTO Description(id, description, validFrom, validTo, spatialEntityId) VALUES (
2,
'Unknow village beyond the horizont.',
TO_DATE('11-11-1500', 'dd-mm-yyyy'),
TO_DATE('11-11-2200', 'dd-mm-yyyy'),
2
);
INSERT INTO SpatialEntity(id, name, geometry, validFrom, validTo, entityType, color) VALUES (
3,
'Some river',
SDO_GEOMETRY(2002, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 2, 1),
SDO_ORDINATE_ARRAY(0, 40, 50, 70, 120, 150)
),
TO_DATE('3-11-1120', 'dd-mm-yyyy'),
TO_DATE('3-11-2116', 'dd-mm-yyyy'),
'river',
'blue'
);
INSERT INTO Description(id, description, validFrom, validTo, spatialEntityId) VALUES (
3,
'Large river from somewhere to nowhere',
TO_DATE('11-11-1700', 'dd-mm-yyyy'),
TO_DATE('11-11-2200', 'dd-mm-yyyy'),
3
);
INSERT INTO SpatialEntity(id, name, geometry, validFrom, validTo, entityType, color) VALUES (
4,
'Czech Republic',
SDO_GEOMETRY(2003, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1003, 1),
SDO_ORDINATE_ARRAY(10, 10, 250, 50, 350, 120, 150, 150, 170, 100, 20, 250, 10, 10)
),
TO_DATE('1-1-1993', 'dd-mm-yyyy'),
TO_DATE('1-1-3000', 'dd-mm-yyyy'),
'country',
'gold'
);
INSERT INTO SpatialEntity(id, name, geometry, validFrom, validTo, entityType, color) VALUES (
5,
'Square republic',
SDO_GEOMETRY(2003, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1003, 3),
SDO_ORDINATE_ARRAY(20, 20, 250, 300)
),
TO_DATE('1-1-1993', 'dd-mm-yyyy'),
TO_DATE('1-1-3000', 'dd-mm-yyyy'),
'countryRec',
'gold'
);
INSERT INTO Description(id, description, validFrom, validTo, spatialEntityId) VALUES (
4,
'Some republic',
TO_DATE('11-11-1700', 'dd-mm-yyyy'),
TO_DATE('11-11-2200', 'dd-mm-yyyy'),
4
);
COMMIT;