Mercurial > dive4elements > river
comparison backend/doc/schema/oracle-minfo.sql @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-backend/doc/schema/oracle-minfo.sql@e89d922df8ae |
children | 2d16f4a0bdcc |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 SET AUTOCOMMIT ON; | |
2 | |
3 CREATE SEQUENCE LOCATION_SYSTEM_SEQ; | |
4 | |
5 CREATE TABLE location_system ( | |
6 id NUMBER(38,0) NOT NULL, | |
7 name VARCHAR(32) NOT NULL, | |
8 description VARCHAR(255), | |
9 PRIMARY KEY(id) | |
10 ); | |
11 | |
12 | |
13 CREATE SEQUENCE ELEVATION_MODEL_SEQ; | |
14 | |
15 CREATE TABLE elevation_model ( | |
16 id NUMBER(38,0) NOT NULL, | |
17 name VARCHAR(32) NOT NULL, | |
18 unit_id NUMBER(38,0) NOT NULL, | |
19 PRIMARY KEY(id), | |
20 CONSTRAINT fk_unit FOREIGN KEY (unit_id) REFERENCES units(id) | |
21 ); | |
22 | |
23 | |
24 -- lookup table for bedheight types | |
25 CREATE TABLE bed_height_type ( | |
26 id NUMBER(38,0) NOT NULL, | |
27 name VARCHAR(65) NOT NULL, | |
28 PRIMARY KEY(id) | |
29 ); | |
30 INSERT INTO bed_height_type VALUES (1, 'Querprofile'); | |
31 INSERT INTO bed_height_type VALUES (2, 'Flächenpeilung'); | |
32 INSERT INTO bed_height_type VALUES (3, 'Flächen- u. Querprofilpeilungen'); | |
33 INSERT INTO bed_height_type VALUES (4, 'DGM'); | |
34 INSERT INTO bed_height_type VALUES (5, 'TIN'); | |
35 INSERT INTO bed_height_type VALUES (6, 'Modell'); | |
36 | |
37 | |
38 CREATE SEQUENCE BED_HEIGHT_SINGLE_ID_SEQ; | |
39 | |
40 CREATE TABLE bed_height_single ( | |
41 id NUMBER(38,0) NOT NULL, | |
42 river_id NUMBER(38,0) NOT NULL, | |
43 year NUMBER(38,0), | |
44 sounding_width NUMBER(38,0), | |
45 type_id NUMBER(38,0) NOT NULL, | |
46 location_system_id NUMBER(38,0) NOT NULL, | |
47 cur_elevation_model_id NUMBER(38,0) NOT NULL, | |
48 old_elevation_model_id NUMBER(38,0), | |
49 range_id NUMBER(38,0), | |
50 evaluation_by VARCHAR(255), | |
51 description VARCHAR(255), | |
52 PRIMARY KEY(id), | |
53 CONSTRAINT fk_bed_single_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, | |
54 CONSTRAINT fk_type FOREIGN KEY (type_id) REFERENCES bed_height_type(id), | |
55 CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) REFERENCES location_system(id), | |
56 CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), | |
57 CONSTRAINT fk_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), | |
58 CONSTRAINT fk_range FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE | |
59 ); | |
60 | |
61 | |
62 CREATE SEQUENCE BED_HEIGHT_EPOCH_ID_SEQ; | |
63 | |
64 CREATE TABLE bed_height_epoch ( | |
65 id NUMBER(38,0) NOT NULL, | |
66 river_id NUMBER(38,0) NOT NULL, | |
67 time_interval_id NUMBER(38,0) NOT NULL, | |
68 -- sounding_with NUMBER(38,0) NOT NULL, | |
69 -- type_id NUMBER(38,0) NOT NULL, | |
70 cur_elevation_model_id NUMBER(38,0) NOT NULL, | |
71 old_elevation_model_id NUMBER(38,0), | |
72 range_id NUMBER(38,0), | |
73 evaluation_by VARCHAR(255), | |
74 description VARCHAR(255), | |
75 PRIMARY KEY(id), | |
76 CONSTRAINT fk_time_interval FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id), | |
77 CONSTRAINT fk_epoch_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), | |
78 CONSTRAINT fk_epoch_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), | |
79 CONSTRAINT fk_epoch_range FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE | |
80 ); | |
81 | |
82 | |
83 CREATE SEQUENCE BED_SINGLE_VALUES_ID_SEQ; | |
84 | |
85 CREATE TABLE bed_height_single_values ( | |
86 id NUMBER(38,0) NOT NULL, | |
87 bed_height_single_id NUMBER(38,0) NOT NULL, | |
88 station NUMBER(38,2) NOT NULL, | |
89 height NUMBER(38,2), | |
90 uncertainty NUMBER(38,2), | |
91 data_gap NUMBER(38,2), | |
92 sounding_width NUMBER(38,2), | |
93 width NUMBER(38,2), | |
94 PRIMARY KEY(id), | |
95 CONSTRAINT fk_bed_single_values_parent FOREIGN KEY (bed_height_single_id) REFERENCES bed_height_single(id) ON DELETE CASCADE | |
96 ); | |
97 | |
98 | |
99 CREATE SEQUENCE BED_EPOCH_VALUES_ID_SEQ; | |
100 | |
101 CREATE TABLE bed_height_epoch_values ( | |
102 id NUMBER(38,0) NOT NULL, | |
103 bed_height_epoch_id NUMBER(38,0) NOT NULL, | |
104 station NUMBER(38,2) NOT NULL, | |
105 height NUMBER(38,2), | |
106 PRIMARY KEY(id), | |
107 CONSTRAINT fk_bed_epoch_values_parent FOREIGN KEY (bed_height_epoch_id) REFERENCES bed_height_epoch(id) ON DELETE CASCADE | |
108 ); | |
109 | |
110 | |
111 CREATE SEQUENCE DEPTHS_ID_SEQ; | |
112 | |
113 CREATE TABLE depths ( | |
114 id NUMBER(38,0) NOT NULL, | |
115 lower NUMBER(38,2) NOT NULL, | |
116 upper NUMBER(38,2) NOT NULL, | |
117 PRIMARY KEY(id) | |
118 ); | |
119 | |
120 | |
121 CREATE SEQUENCE SEDIMENT_DENSITY_ID_SEQ; | |
122 | |
123 CREATE TABLE sediment_density ( | |
124 id NUMBER(38,0) NOT NULL, | |
125 river_id NUMBER(38,0) NOT NULL, | |
126 depth_id NUMBER(38,0) NOT NULL, | |
127 description VARCHAR(256), | |
128 PRIMARY KEY(id), | |
129 CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, | |
130 CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id) | |
131 ); | |
132 | |
133 | |
134 CREATE SEQUENCE SEDIMENT_DENSITY_VALUES_ID_SEQ; | |
135 | |
136 CREATE TABLE sediment_density_values ( | |
137 id NUMBER(38,0) NOT NULL, | |
138 sediment_density_id NUMBER(38,0) NOT NULL, | |
139 station NUMBER(38,2) NOT NULL, | |
140 shore_offset NUMBER(38,2), | |
141 density NUMBER(38,2) NOT NULL, | |
142 description VARCHAR(256), | |
143 year NUMBER(38,0), | |
144 PRIMARY KEY(id), | |
145 CONSTRAINT fk_sdv_sediment_density_id FOREIGN KEY(sediment_density_id) REFERENCES sediment_density(id) ON DELETE CASCADE | |
146 ); | |
147 | |
148 | |
149 CREATE SEQUENCE MORPHOLOGIC_WIDTH_ID_SEQ; | |
150 | |
151 CREATE TABLE morphologic_width ( | |
152 id NUMBER(38,0) NOT NULL, | |
153 river_id NUMBER(38,0) NOT NULL, | |
154 unit_id NUMBER(38,0) NOT NULL, | |
155 PRIMARY KEY(id), | |
156 CONSTRAINT fk_mw_river_id FOREIGN KEY(river_id) REFERENCES rivers(id) ON DELETE CASCADE, | |
157 CONSTRAINT fk_mw_unit_id FOREIGN KEY(unit_id) REFERENCES units(id) | |
158 ); | |
159 | |
160 | |
161 CREATE SEQUENCE MORPH_WIDTH_VALUES_ID_SEQ; | |
162 | |
163 CREATE TABLE morphologic_width_values ( | |
164 id NUMBER(38,0) NOT NULL, | |
165 morphologic_width_id NUMBER(38,0) NOT NULL, | |
166 station NUMBER(38,3) NOT NULL, | |
167 width NUMBER(38,3) NOT NULL, | |
168 description VARCHAR(256), | |
169 PRIMARY KEY(id), | |
170 CONSTRAINT fk_mwv_morphologic_width_id FOREIGN KEY (morphologic_width_id) REFERENCES morphologic_width(id) ON DELETE CASCADE | |
171 ); | |
172 | |
173 | |
174 CREATE SEQUENCE DISCHARGE_ZONE_ID_SEQ; | |
175 | |
176 CREATE TABLE discharge_zone ( | |
177 id NUMBER(38,0) NOT NULL, | |
178 river_id NUMBER(38,0) NOT NULL, | |
179 gauge_name VARCHAR(64) NOT NULL, -- this is not very proper, but there are gauges with no db instance | |
180 value NUMBER(38,3) NOT NULL, | |
181 lower_discharge VARCHAR(16) NOT NULL, | |
182 upper_discharge VARCHAR(16), | |
183 PRIMARY KEY(id), | |
184 CONSTRAINT fk_dz_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE | |
185 ); | |
186 | |
187 | |
188 CREATE SEQUENCE FLOW_VELOCITY_MODEL_ID_SEQ; | |
189 | |
190 CREATE TABLE flow_velocity_model ( | |
191 id NUMBER(38,0) NOT NULL, | |
192 discharge_zone_id NUMBER(38,0) NOT NULL, | |
193 description VARCHAR(256), | |
194 PRIMARY KEY (id), | |
195 CONSTRAINT fk_fvm_discharge_zone_id FOREIGN KEY (discharge_zone_id) REFERENCES discharge_zone (id) ON DELETE CASCADE | |
196 ); | |
197 | |
198 | |
199 CREATE SEQUENCE FLOW_VELOCITY_M_VALUES_ID_SEQ; | |
200 | |
201 CREATE TABLE flow_velocity_model_values ( | |
202 id NUMBER(38,0) NOT NULL, | |
203 flow_velocity_model_id NUMBER(38,0) NOT NULL, | |
204 station NUMBER(38,3) NOT NULL, | |
205 q NUMBER(38,3) NOT NULL, | |
206 total_channel NUMBER(38,3) NOT NULL, | |
207 main_channel NUMBER(38,3) NOT NULL, | |
208 shear_stress NUMBER(38,3) NOT NULL, | |
209 PRIMARY KEY(id), | |
210 UNIQUE (station, flow_velocity_model_id), | |
211 CONSTRAINT fk_fvv_flow_velocity_model_id FOREIGN KEY (flow_velocity_model_id) REFERENCES flow_velocity_model(id) ON DELETE CASCADE | |
212 ); | |
213 | |
214 | |
215 | |
216 CREATE SEQUENCE FV_MEASURE_ID_SEQ; | |
217 | |
218 CREATE TABLE flow_velocity_measurements ( | |
219 id NUMBER(38,0) NOT NULL, | |
220 river_id NUMBER(38,0) NOT NULL, | |
221 description VARCHAR(256), | |
222 PRIMARY KEY (id), | |
223 CONSTRAINT fk_fvm_rivers_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE | |
224 ); | |
225 | |
226 CREATE SEQUENCE FV_MEASURE_VALUES_ID_SEQ; | |
227 | |
228 CREATE TABLE flow_velocity_measure_values ( | |
229 id NUMBER(38,0) NOT NULL, | |
230 measurements_id NUMBER(38,0) NOT NULL, | |
231 station NUMBER(38,3) NOT NULL, | |
232 datetime TIMESTAMP, | |
233 w NUMBER(38,3) NOT NULL, | |
234 q NUMBER(38,3) NOT NULL, | |
235 v NUMBER(38,3) NOT NULL, | |
236 description VARCHAR(256), | |
237 PRIMARY KEY (id), | |
238 CONSTRAINT fk_fvmv_measurements_id FOREIGN KEY (measurements_id) REFERENCES flow_velocity_measurements (id) ON DELETE CASCADE | |
239 ); | |
240 | |
241 | |
242 CREATE SEQUENCE GRAIN_FRACTION_ID_SEQ; | |
243 | |
244 CREATE TABLE grain_fraction ( | |
245 id NUMBER(38,0) NOT NULL, | |
246 name VARCHAR(64) NOT NULL, | |
247 lower NUMBER(38,3), | |
248 upper NUMBER(38,3), | |
249 PRIMARY KEY (id), | |
250 ); | |
251 | |
252 | |
253 CREATE SEQUENCE SEDIMENT_YIELD_ID_SEQ; | |
254 | |
255 CREATE TABLE sediment_yield ( | |
256 id NUMBER(38,0) NOT NULL, | |
257 river_id NUMBER(38,0) NOT NULL, | |
258 grain_fraction_id NUMBER(38,0), | |
259 unit_id NUMBER(38,0) NOT NULL, | |
260 time_interval_id NUMBER(38,0) NOT NULL, | |
261 description VARCHAR(256), | |
262 PRIMARY KEY (id), | |
263 CONSTRAINT fk_sy_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, | |
264 CONSTRAINT fk_sy_grain_fraction_id FOREIGN KEY (grain_fraction_id) REFERENCES grain_fraction(id), | |
265 CONSTRAINT fk_sy_unit_id FOREIGN KEY (unit_id) REFERENCES units(id), | |
266 CONSTRAINT fk_sy_time_interval_id FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id) | |
267 ); | |
268 | |
269 | |
270 CREATE SEQUENCE SEDIMENT_YIELD_VALUES_ID_SEQ; | |
271 | |
272 CREATE TABLE sediment_yield_values ( | |
273 id NUMBER(38,0) NOT NULL, | |
274 sediment_yield_id NUMBER(38,0) NOT NULL, | |
275 station NUMBER(38,3) NOT NULL, | |
276 value NUMBER(38,3) NOT NULL, | |
277 PRIMARY KEY (id), | |
278 CONSTRAINT fk_syv_sediment_yield_id FOREIGN KEY (sediment_yield_id) REFERENCES sediment_yield(id) ON DELETE CASCADE | |
279 ); | |
280 | |
281 | |
282 CREATE SEQUENCE MEASUREMENT_STATION_ID_SEQ; | |
283 CREATE TABLE measurement_station ( | |
284 id NUMBER(38) NOT NULL, | |
285 name VARCHAR(256) NOT NULL, | |
286 river_id NUMBER(38) NOT NULL, | |
287 station NUMBER(38,3) NOT NULL, | |
288 range_id NUMBER(38), | |
289 measurement_type VARCHAR(64) NOT NULL, | |
290 riverside VARCHAR(16), | |
291 reference_gauge_id NUMBER(38), | |
292 -- store name of reference gauges here too, as not all are in gauges | |
293 reference_gauge_name VARCHAR(64), | |
294 observation_timerange_id NUMBER(38), | |
295 operator VARCHAR(64), | |
296 description VARCHAR(512), | |
297 PRIMARY KEY (id), | |
298 CONSTRAINT fk_ms_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, | |
299 CONSTRAINT fk_ms_range_id FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE, | |
300 CONSTRAINT fk_ms_reference_gauge_id FOREIGN KEY (reference_gauge_id) REFERENCES gauges(id) ON DELETE CASCADE, | |
301 CONSTRAINT fk_ms_observation_timerange_id FOREIGN KEY (observation_timerange_id) REFERENCES time_intervals(id) | |
302 ); | |
303 | |
304 | |
305 CREATE SEQUENCE SQ_RELATION_ID_SEQ; | |
306 | |
307 CREATE TABLE sq_relation ( | |
308 id NUMBER(38,0) NOT NULL, | |
309 river_id NUMBER(38,0) NOT NULL, | |
310 time_interval_id NUMBER(38,0) NOT NULL, | |
311 description VARCHAR(256), | |
312 PRIMARY KEY (id), | |
313 CONSTRAINT fk_sqr_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, | |
314 CONSTRAINT fk_sqr_tinterval_id FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id) | |
315 ); | |
316 | |
317 | |
318 CREATE SEQUENCE SQ_RELATION_VALUES_ID_SEQ; | |
319 | |
320 CREATE TABLE sq_relation_value ( | |
321 id NUMBER(38,0) NOT NULL, | |
322 sq_relation_id NUMBER(38,0) NOT NULL, | |
323 measurement_station_id NUMBER(38,0) NOT NULL, | |
324 parameter VARCHAR(1) NOT NULL, | |
325 a NUMBER(38,20) NOT NULL, | |
326 b NUMBER(38,20) NOT NULL, | |
327 qmax NUMBER(38,20) NOT NULL, | |
328 rsq NUMBER(38,3), | |
329 ntot NUMBER(38,0), | |
330 noutl NUMBER(38,0), | |
331 cferguson NUMBER(38,20), | |
332 cduan NUMBER(38,20), | |
333 PRIMARY KEY (id), | |
334 CONSTRAINT fk_sqr_id FOREIGN KEY (sq_relation_id) REFERENCES sq_relation(id) ON DELETE CASCADE, | |
335 CONSTRAINT fk_mstation_id FOREIGN KEY (measurement_station_id) REFERENCES measurement_station(id) ON DELETE CASCADE | |
336 ); |