-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrab_tables.sql
369 lines (330 loc) · 10.1 KB
/
crab_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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
DROP SCHEMA crab cascade;
CREATE SCHEMA crab;
SET search_path = crab, pg_catalog;
CREATE TABLE cadastre_municipality (
id integer NOT NULL,
cadastre_municipality_code integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE cadastre_municipality_name (
id integer NOT NULL,
cadastre_municipality_id integer NOT NULL,
name character varying(40),
language_id character(2) NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE house_number (
id integer NOT NULL,
street_name_id integer NOT NULL,
house_number character varying(11) NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer,
start_operation_id integer NOT NULL,
house_number_id0 character varying(37) NOT NULL
);
CREATE TABLE house_number_post_canton (
id integer NOT NULL,
house_number_id integer NOT NULL,
postcode integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE house_numbering_scheme (
id integer NOT NULL,
name character varying
);
CREATE TABLE language (
id character(2) NOT NULL,
name character varying
);
CREATE TABLE municipality (
id integer NOT NULL,
nis_code integer NOT NULL,
language_id character(2) NOT NULL,
language2_id character(2),
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_operation_id integer NOT NULL,
start_organisation_id integer NOT NULL
);
CREATE TABLE municipality_cadastre_municipality (
id integer NOT NULL,
cadastre_municipality_id integer NOT NULL,
municipality_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE municipality_name (
id integer NOT NULL,
municipality_id integer NOT NULL,
name character varying(40) NOT NULL,
language_id character(2) NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_operation_id integer NOT NULL,
start_organisation_id integer NOT NULL
);
CREATE TABLE municipality_sub_post_canton (
id integer NOT NULL,
sub_post_canton_id integer NOT NULL,
municipality_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_operation_id integer NOT NULL,
start_organisation_id integer NOT NULL
);
CREATE TABLE object_type (
id integer NOT NULL,
name character varying
);
CREATE TABLE operation (
id integer NOT NULL,
name character varying
);
CREATE TABLE organisation (
id integer NOT NULL,
name character varying
);
CREATE TABLE post_canton (
id integer NOT NULL,
postcode integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE post_canton_name (
id integer NOT NULL,
post_canton_id integer NOT NULL,
name character varying(255) NOT NULL,
language_id character(2) NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE street_object (
id integer NOT NULL,
object_id varchar(21) NOT NULL,
street_object_type_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE street_name (
id integer NOT NULL,
municipality_nis_code integer NOT NULL,
street_name character varying(80) NOT NULL,
language_id character(2) NOT NULL,
street_name2 character varying(80),
language2_id character(2),
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL,
street_name0 character varying(80)
);
CREATE TABLE street_object_type (
id integer NOT NULL,
name character varying
);
CREATE TABLE street_side (
id integer NOT NULL,
street_name_id integer NOT NULL,
street_object_id integer NOT NULL,
street_side_type_id integer NOT NULL,
begin_position numeric(7,2) NOT NULL,
end_position numeric(7,2),
house_numbering_scheme_id integer,
first_house_number character varying(20),
last_house_number character varying(20),
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE street_side_type (
id integer NOT NULL,
name character varying
);
CREATE TABLE sub_address (
id integer NOT NULL,
house_number_id integer NOT NULL,
-- TODO: This shouldn't be allowed to be NULL, but the data we got contains some
-- NULLs
-- sub_address character varying(35) NOT NULL,
sub_address character varying(35),
sub_address_type_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE sub_address_type (
id integer NOT NULL,
name character varying
);
CREATE TABLE sub_post_canton (
id integer NOT NULL,
post_canton_id integer NOT NULL,
sub_canton_number integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_operation_id integer NOT NULL,
start_organisation_id integer NOT NULL
);
CREATE TABLE sub_street (
id integer NOT NULL,
street_code varchar(4) NOT NULL,
postcode integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE sub_street_name (
id integer NOT NULL,
sub_street_id integer NOT NULL,
name character varying(80),
language_id character(2) NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE sub_street_street_name (
id integer NOT NULL,
street_name_id integer NOT NULL,
sub_street_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE terrain_object (
id integer NOT NULL,
object_id character varying(21) NOT NULL,
object_type_id integer NOT NULL,
point public.geometry,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL,
cadastre_municipality_code integer,
CONSTRAINT enforce_dims_point CHECK ((public.st_ndims(point) = 2)),
CONSTRAINT enforce_geotype_point CHECK (((public.geometrytype(point) = 'POINT'::text) OR (point IS NULL))),
CONSTRAINT enforce_srid_point CHECK ((public.st_srid(point) = 31370))
);
CREATE TABLE terrain_object_house_number (
id integer NOT NULL,
terrain_object_id integer NOT NULL,
house_number_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
start_time timestamp without time zone NOT NULL,
start_organisation_id integer NOT NULL,
start_operation_id integer NOT NULL
);
CREATE TABLE address_position (
id integer NOT NULL,
street_name_id integer NOT NULL,
street_name varchar(80) NOT NULL,
house_number varchar(11) NOT NULL,
appartement_number varchar(11),
bus_number varchar(11),
house_number_label varchar(23) NOT NULL,
nis_code integer NOT NULL,
municipality_name varchar(40) NOT NULL,
postcode integer NOT NULL,
source varchar(60),
point public.geometry NOT NULL,
CONSTRAINT enforce_dims_point CHECK ((public.st_ndims(point) = 2)),
CONSTRAINT enforce_geotype_point CHECK (((public.geometrytype(point) = 'POINT'::text) OR (point IS NULL))),
CONSTRAINT enforce_srid_point CHECK ((public.st_srid(point) = 31370))
);
COPY house_numbering_scheme (id, name) FROM stdin;
1 Even
2 Odd
3 All
4 Unordered
5 No numbers
\.
COPY language (id, name) FROM stdin;
nl Dutch
fr French
de German
\.
COPY object_type (id, name) FROM stdin;
1 Lot according to cadastre
2 Building according to GRB
3 Artwork accordign to GRB
4 Administrative lot according to GRB
5 Building according to municipality
99 Other
\.
COPY operation (id, name) FROM stdin;
1 Input in database
2 Filling in end date
3 Correction attributes
4 Removal from database
\.
COPY organisation (id, name) FROM stdin;
1 Municipality
2 Rijksregister
3 Administratie voor Algemene Patrimoniumdocumentatie (AAPD)
4 TeleAtlas
5 Agentschap voor Geografische Informatie Vlaanderen (AGIV)
6 Nationaal Geografisch Instituut (NGI)
7 bPost
8 NAVTEQ
9 Verrijkte Kruispuntbank voor Ondernemingen
99 Other
\.
COPY street_object_type (id, name) FROM stdin;
1 Street connection according to TeleAtlas
2 Street connection according to GRB
3 Waypoint according to GRB
4 Street connection according to NAVTEQ
5 Street connection according to municipality
99 Other
\.
COPY street_side_type (id, name) FROM stdin;
1 Left
2 Right
\.
COPY sub_address_type (id, name) FROM stdin;
1 Appartment number
2 Bus number
99 Other
\.