Mercurial > dive4elements > river
annotate backend/doc/schema/postgresql-minfo.sql @ 8956:ee5ce13016ed
Work on SINFO-Fließtiefenentwicklung
author | gernotbelger |
---|---|
date | Tue, 20 Mar 2018 13:30:07 +0100 |
parents | 71b17f731762 |
children | f89fb9e9abad |
rev | line source |
---|---|
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 BEGIN; |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 CREATE SEQUENCE LOCATION_SYSTEM_SEQ; |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 CREATE TABLE location_system ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
6 id NUMERIC(9,0) NOT NULL, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 name VARCHAR(32) NOT NULL, |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 description VARCHAR(255), |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 PRIMARY KEY(id) |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 CREATE SEQUENCE ELEVATION_MODEL_SEQ; |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 CREATE TABLE elevation_model ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
16 id NUMERIC(9,0) NOT NULL, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 name VARCHAR(32) NOT NULL, |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
18 unit_id NUMERIC(9,0) NOT NULL, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 PRIMARY KEY(id), |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 CONSTRAINT fk_unit FOREIGN KEY (unit_id) REFERENCES units(id) |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
5202
646c154477fe
SCHEMA CHANGE: removed Waterlevel and WaterleveDifferences, added lookup table for wst
Tom Gottfried <tom@intevation.de>
parents:
4991
diff
changeset
|
24 -- lookup table for bedheight types |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 CREATE TABLE bed_height_type ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
26 id NUMERIC(9,0) NOT NULL, |
5273
db196abd16ca
Use lookup table from bedd_height from database in importer.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5206
diff
changeset
|
27 name VARCHAR(64) NOT NULL, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 PRIMARY KEY(id) |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 ); |
5276
170f514a4f29
SCHEMA CHANGE: lookup table for floodmaps and source-field added, Importer adapted to new directory names
Tom Gottfried <tom@intevation.de>
parents:
5275
diff
changeset
|
30 INSERT INTO bed_height_type VALUES (1, 'Querprofile'); |
5275
911f62917753
additional values in lookup table for bed height types
Tom Gottfried <tom@intevation.de>
parents:
5273
diff
changeset
|
31 INSERT INTO bed_height_type VALUES (2, 'Flächenpeilung'); |
911f62917753
additional values in lookup table for bed height types
Tom Gottfried <tom@intevation.de>
parents:
5273
diff
changeset
|
32 INSERT INTO bed_height_type VALUES (3, 'Flächen- u. Querprofilpeilungen'); |
911f62917753
additional values in lookup table for bed height types
Tom Gottfried <tom@intevation.de>
parents:
5273
diff
changeset
|
33 INSERT INTO bed_height_type VALUES (4, 'DGM'); |
911f62917753
additional values in lookup table for bed height types
Tom Gottfried <tom@intevation.de>
parents:
5273
diff
changeset
|
34 INSERT INTO bed_height_type VALUES (5, 'TIN'); |
911f62917753
additional values in lookup table for bed height types
Tom Gottfried <tom@intevation.de>
parents:
5273
diff
changeset
|
35 INSERT INTO bed_height_type VALUES (6, 'Modell'); |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
38 CREATE SEQUENCE BED_HEIGHT_ID_SEQ; |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
40 CREATE TABLE bed_height ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
41 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
42 river_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
43 year NUMERIC(9,0), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
44 type_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
45 location_system_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
46 cur_elevation_model_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
47 old_elevation_model_id NUMERIC(9,0), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
48 range_id NUMERIC(9,0), |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 evaluation_by VARCHAR(255), |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 description VARCHAR(255), |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 PRIMARY KEY(id), |
8666
1a4ad0d4231a
(issue1763) Use more distinct constraint names and adapt drop-script.
Tom Gottfried <tom@intevation.de>
parents:
8642
diff
changeset
|
52 CONSTRAINT fk_bh_river_id FOREIGN KEY (river_id) |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
53 REFERENCES rivers(id) ON DELETE CASCADE, |
8666
1a4ad0d4231a
(issue1763) Use more distinct constraint names and adapt drop-script.
Tom Gottfried <tom@intevation.de>
parents:
8642
diff
changeset
|
54 CONSTRAINT fk_bh_type FOREIGN KEY (type_id) REFERENCES bed_height_type(id), |
1a4ad0d4231a
(issue1763) Use more distinct constraint names and adapt drop-script.
Tom Gottfried <tom@intevation.de>
parents:
8642
diff
changeset
|
55 CONSTRAINT fk_bh_location_system FOREIGN KEY (location_system_id) |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
56 REFERENCES location_system(id), |
8666
1a4ad0d4231a
(issue1763) Use more distinct constraint names and adapt drop-script.
Tom Gottfried <tom@intevation.de>
parents:
8642
diff
changeset
|
57 CONSTRAINT fk_bh_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
58 REFERENCES elevation_model(id), |
8666
1a4ad0d4231a
(issue1763) Use more distinct constraint names and adapt drop-script.
Tom Gottfried <tom@intevation.de>
parents:
8642
diff
changeset
|
59 CONSTRAINT fk_bh_old_elevation_model FOREIGN KEY (old_elevation_model_id) |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
60 REFERENCES elevation_model(id), |
8666
1a4ad0d4231a
(issue1763) Use more distinct constraint names and adapt drop-script.
Tom Gottfried <tom@intevation.de>
parents:
8642
diff
changeset
|
61 CONSTRAINT fk_bh_range FOREIGN KEY (range_id) |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
62 REFERENCES ranges(id) ON DELETE CASCADE |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
66 CREATE SEQUENCE BED_HEIGHT_VALUES_ID_SEQ; |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
68 --FIXME: make precision and scale of station column equal with the km columns of the other tables |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
69 --FIXME: replace double precision with exact types |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
70 CREATE TABLE bed_height_values ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
71 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
72 bed_height_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
73 station DOUBLE PRECISION NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
74 height DOUBLE PRECISION, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
75 uncertainty DOUBLE PRECISION, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
76 data_gap DOUBLE PRECISION, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
77 sounding_width DOUBLE PRECISION, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 PRIMARY KEY(id), |
8559
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
79 UNIQUE (station, bed_height_id), |
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
80 CONSTRAINT fk_bed_values_parent FOREIGN KEY (bed_height_id) |
6d8d7425a6b5
Bed heights are just bed heights since a while ('single' is obsolete).
"Tom Gottfried <tom@intevation.de>"
parents:
8554
diff
changeset
|
81 REFERENCES bed_height(id) ON DELETE CASCADE |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 CREATE SEQUENCE DEPTHS_ID_SEQ; |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 CREATE TABLE depths ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
88 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
89 lower NUMERIC(6,2) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
90 upper NUMERIC(6,2) NOT NULL, |
5441
7c1dd9c3f6bd
remove unit from sediment density and depths (always t/m3 respectively cm, otherwise a typo)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5426
diff
changeset
|
91 PRIMARY KEY(id) |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 CREATE SEQUENCE SEDIMENT_DENSITY_ID_SEQ; |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 CREATE TABLE sediment_density ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
98 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
99 river_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
100 depth_id NUMERIC(9,0) NOT NULL, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 description VARCHAR(256), |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 PRIMARY KEY(id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
103 CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, |
5441
7c1dd9c3f6bd
remove unit from sediment density and depths (always t/m3 respectively cm, otherwise a typo)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5426
diff
changeset
|
104 CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id) |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 CREATE SEQUENCE SEDIMENT_DENSITY_VALUES_ID_SEQ; |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
110 --FIXME: make precision and scale of station column equal with the km columns of the other tables |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 CREATE TABLE sediment_density_values ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
112 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
113 sediment_density_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
114 station NUMERIC(6,2) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
115 shore_offset NUMERIC(6,2), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
116 density NUMERIC(8,2) NOT NULL, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 description VARCHAR(256), |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
118 year NUMERIC(4,0), |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 PRIMARY KEY(id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
120 CONSTRAINT fk_sdv_sediment_density_id FOREIGN KEY(sediment_density_id) REFERENCES sediment_density(id) ON DELETE CASCADE |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 |
7839
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
124 CREATE SEQUENCE POROSITY_ID_SEQ; |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
125 |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
126 CREATE TABLE porosity ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
127 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
128 river_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
129 depth_id NUMERIC(9,0) NOT NULL, |
7839
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
130 description VARCHAR(256), |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
131 time_interval_id NUMERIC(9,0) NOT NULL, |
7839
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
132 PRIMARY KEY(id), |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
133 CONSTRAINT fk_p_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
134 CONSTRAINT fk_p_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id), |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
135 CONSTRAINT fk_p_time_interval_id FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id) |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
136 ); |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
137 |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
138 |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
139 CREATE SEQUENCE POROSITY_VALUES_ID_SEQ; |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
140 |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
141 --FIXME: make precision and scale of station column equal with the km columns of the other tables |
7839
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
142 CREATE TABLE porosity_values ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
143 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
144 porosity_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
145 station DOUBLE PRECISION NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
146 shore_offset DOUBLE PRECISION, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
147 porosity DOUBLE PRECISION NOT NULL, |
7839
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
148 description VARCHAR(256), |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
149 PRIMARY KEY(id), |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
150 CONSTRAINT fk_pv_porosity_id FOREIGN KEY(porosity_id) REFERENCES porosity(id) ON DELETE CASCADE |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
151 ); |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
152 |
3f6b9fae1637
Added tables for porosity and porosity values to postgres schema.
Raimund Renkert <rrenkert@intevation.de>
parents:
7461
diff
changeset
|
153 |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
154 CREATE SEQUENCE MORPHOLOGIC_WIDTH_ID_SEQ; |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
155 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
156 CREATE TABLE morphologic_width ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
157 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
158 river_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
159 unit_id NUMERIC(9,0) NOT NULL, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
160 PRIMARY KEY(id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
161 CONSTRAINT fk_mw_river_id FOREIGN KEY(river_id) REFERENCES rivers(id) ON DELETE CASCADE, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
162 CONSTRAINT fk_mw_unit_id FOREIGN KEY(unit_id) REFERENCES units(id) |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
163 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 CREATE SEQUENCE MORPH_WIDTH_VALUES_ID_SEQ; |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
167 |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 CREATE TABLE morphologic_width_values ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
169 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
170 morphologic_width_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
171 station NUMERIC(7,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
172 width NUMERIC(7,3) NOT NULL, |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
173 description VARCHAR(256), |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
174 PRIMARY KEY(id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
175 CONSTRAINT fk_mwv_morphologic_width_id FOREIGN KEY (morphologic_width_id) REFERENCES morphologic_width(id) ON DELETE CASCADE |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 ); |
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
177 |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
178 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
179 CREATE SEQUENCE DISCHARGE_ZONE_ID_SEQ; |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
180 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
181 CREATE TABLE discharge_zone ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
182 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
183 river_id NUMERIC(9,0) NOT NULL, |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
184 gauge_name VARCHAR(64) NOT NULL, -- this is not very proper, but there are gauges with no db instance |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
185 value NUMERIC(8,3) NOT NULL, |
6369
7fb0e755e4fa
Minimal schema change: allow longer names in discharge zones
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6045
diff
changeset
|
186 lower_discharge VARCHAR(64) NOT NULL, |
7fb0e755e4fa
Minimal schema change: allow longer names in discharge zones
Tom Gottfried <tom.gottfried@intevation.de>
parents:
6045
diff
changeset
|
187 upper_discharge VARCHAR(64), |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
188 PRIMARY KEY(id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
189 CONSTRAINT fk_dz_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
190 ); |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
191 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
192 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
193 CREATE SEQUENCE FLOW_VELOCITY_MODEL_ID_SEQ; |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
194 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
195 CREATE TABLE flow_velocity_model ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
196 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
197 discharge_zone_id NUMERIC(9,0) NOT NULL, |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
198 description VARCHAR(256), |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
199 PRIMARY KEY (id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
200 CONSTRAINT fk_fvm_discharge_zone_id FOREIGN KEY (discharge_zone_id) REFERENCES discharge_zone (id) ON DELETE CASCADE |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
201 ); |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
202 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
203 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
204 CREATE SEQUENCE FLOW_VELOCITY_M_VALUES_ID_SEQ; |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
205 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
206 CREATE TABLE flow_velocity_model_values ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
207 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
208 flow_velocity_model_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
209 station NUMERIC(7,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
210 q NUMERIC(8,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
211 total_channel NUMERIC(5,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
212 main_channel NUMERIC(5,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
213 shear_stress NUMERIC(6,3) NOT NULL, |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
214 PRIMARY KEY(id), |
5709
e89d922df8ae
Schema change: add constraint to have unique stations per flow velocity model
Tom Gottfried <tom@intevation.de>
parents:
5684
diff
changeset
|
215 UNIQUE (station, flow_velocity_model_id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
216 CONSTRAINT fk_fvv_flow_velocity_model_id FOREIGN KEY (flow_velocity_model_id) REFERENCES flow_velocity_model(id) ON DELETE CASCADE |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
217 ); |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
218 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
219 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
220 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
221 CREATE SEQUENCE FV_MEASURE_ID_SEQ; |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
222 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
223 CREATE TABLE flow_velocity_measurements ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
224 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
225 river_id NUMERIC(9,0) NOT NULL, |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
226 description VARCHAR(256), |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
227 PRIMARY KEY (id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
228 CONSTRAINT fk_fvm_rivers_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
229 ); |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
230 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
231 CREATE SEQUENCE FV_MEASURE_VALUES_ID_SEQ; |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
232 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
233 CREATE TABLE flow_velocity_measure_values ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
234 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
235 measurements_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
236 station NUMERIC(7,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
237 datetime TIMESTAMP(0), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
238 w NUMERIC(7,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
239 q NUMERIC(8,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
240 v NUMERIC(5,3) NOT NULL, |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
241 description VARCHAR(256), |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
242 PRIMARY KEY (id), |
4991
b79eb203032d
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
Tom Gottfried <tom.gottfried@intevation.de>
parents:
4523
diff
changeset
|
243 CONSTRAINT fk_fvmv_measurements_id FOREIGN KEY (measurements_id) REFERENCES flow_velocity_measurements (id) ON DELETE CASCADE |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
244 ); |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
245 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
246 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
247 CREATE SEQUENCE GRAIN_FRACTION_ID_SEQ; |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
248 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
249 CREATE TABLE grain_fraction ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
250 id NUMERIC(9,0) NOT NULL, |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
251 name VARCHAR(64) NOT NULL, |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
252 lower NUMERIC(6,3), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
253 upper NUMERIC(6,3), |
8032
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
254 PRIMARY KEY (id), |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
255 UNIQUE(name, lower, upper) |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
256 ); |
8032
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
257 -- single fractions |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
258 INSERT INTO grain_fraction VALUES (1, 'coarse', 16, 200); |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
259 INSERT INTO grain_fraction VALUES (2, 'fine_middle', 2, 16); |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
260 INSERT INTO grain_fraction VALUES (3, 'sand', 0.063, 2); |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
261 INSERT INTO grain_fraction VALUES (4, 'susp_sand', 0.063, 2); |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
262 INSERT INTO grain_fraction VALUES (5, 'susp_sand_bed', 0.063, 2); |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
263 INSERT INTO grain_fraction VALUES (6, 'suspended_sediment', 0, 0.063); |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
264 -- aggregations of fractions |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
265 INSERT INTO grain_fraction VALUES (7, 'total', 0, 200); |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
266 INSERT INTO grain_fraction VALUES (8, 'bed_load', 0.063, 200); |
fd3a24336e6a
SCHEMA CHANGE and Importer (only longitudinal section data so far): only grain fractions given now in schema are valid. We are handling sediment loads, not yields.
"Tom Gottfried <tom@intevation.de>"
parents:
8019
diff
changeset
|
267 INSERT INTO grain_fraction VALUES (9, 'suspended_load', 0, 2); |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
268 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
269 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
270 --lookup table for sediment load kinds |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
271 CREATE TABLE sediment_load_kinds ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
272 id NUMERIC(9,0) PRIMARY KEY NOT NULL, |
7461
5b5a2cc8210f
Schema change: add lookup table for sediment yield kinds to have its values documented.
Tom Gottfried <tom@intevation.de>
parents:
6817
diff
changeset
|
273 kind VARCHAR(64) NOT NULL |
5b5a2cc8210f
Schema change: add lookup table for sediment yield kinds to have its values documented.
Tom Gottfried <tom@intevation.de>
parents:
6817
diff
changeset
|
274 ); |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
275 INSERT INTO sediment_load_kinds (id, kind) VALUES (0, 'non-official'); |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
276 INSERT INTO sediment_load_kinds (id, kind) VALUES (1, 'official'); |
7461
5b5a2cc8210f
Schema change: add lookup table for sediment yield kinds to have its values documented.
Tom Gottfried <tom@intevation.de>
parents:
6817
diff
changeset
|
277 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
278 CREATE SEQUENCE SEDIMENT_LOAD_LS_ID_SEQ; |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
279 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
280 CREATE TABLE sediment_load_ls ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
281 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
282 river_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
283 grain_fraction_id NUMERIC(9,0), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
284 unit_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
285 time_interval_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
286 sq_time_interval_id NUMERIC(9,0), |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
287 description VARCHAR(256), |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
288 kind NUMERIC(9,0), |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
289 PRIMARY KEY (id), |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
290 CONSTRAINT fk_slls_river_id FOREIGN KEY (river_id) |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
291 REFERENCES rivers(id) ON DELETE CASCADE, |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
292 CONSTRAINT fk_slls_kind_id FOREIGN KEY (kind) |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
293 REFERENCES sediment_load_kinds(id), |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
294 CONSTRAINT fk_slls_grain_fraction_id FOREIGN KEY (grain_fraction_id) |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
295 REFERENCES grain_fraction(id), |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
296 CONSTRAINT fk_slls_unit_id FOREIGN KEY (unit_id) |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
297 REFERENCES units(id), |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
298 CONSTRAINT fk_slls_time_interval_id FOREIGN KEY (time_interval_id) |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
299 REFERENCES time_intervals(id), |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
300 CONSTRAINT fk_slls_sq_time_interval_id FOREIGN KEY (sq_time_interval_id) |
8059
bde5f5ec7c72
SCHEMA CHANGE and Importer: get time intervals of SQ-relations from metalines in sediment load files.
Tom Gottfried <tom@intevation.de>
parents:
8032
diff
changeset
|
301 REFERENCES time_intervals(id) |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
302 ); |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
303 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
304 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
305 CREATE SEQUENCE SEDIMENT_LOAD_LS_VALUES_ID_SEQ; |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
306 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
307 CREATE TABLE sediment_load_ls_values ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
308 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
309 sediment_load_ls_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
310 station NUMERIC(7,3) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
311 value NUMERIC(10,3) NOT NULL, |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
312 PRIMARY KEY (id), |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
313 CONSTRAINT fk_sllsv_sediment_load_ls_id FOREIGN KEY (sediment_load_ls_id) |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
314 REFERENCES sediment_load_ls(id) ON DELETE CASCADE |
2858
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
315 ); |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
316 |
c3b2673eafbf
Adjusted PostgreSQL port of MINFO schema to match Oracle one.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2823
diff
changeset
|
317 |
4193
f63b39799d2d
Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3953
diff
changeset
|
318 CREATE SEQUENCE MEASUREMENT_STATION_ID_SEQ; |
f63b39799d2d
Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3953
diff
changeset
|
319 CREATE TABLE measurement_station ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
320 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
321 range_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
322 reference_gauge_id NUMERIC(9,0), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
323 time_interval_id NUMERIC(9,0), |
5206
8667f629d238
SCHEME CHANGE: Add measurement_station to oracle table and rename comment column
Andre Heinecke <aheinecke@intevation.de>
parents:
5202
diff
changeset
|
324 name VARCHAR(256) NOT NULL, |
8667f629d238
SCHEME CHANGE: Add measurement_station to oracle table and rename comment column
Andre Heinecke <aheinecke@intevation.de>
parents:
5202
diff
changeset
|
325 measurement_type VARCHAR(64) NOT NULL, |
8667f629d238
SCHEME CHANGE: Add measurement_station to oracle table and rename comment column
Andre Heinecke <aheinecke@intevation.de>
parents:
5202
diff
changeset
|
326 riverside VARCHAR(16), |
5456
e47c4e9b050e
Schema corrected: measurement_station.reference_gauge_station is not needed
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5455
diff
changeset
|
327 -- store name of reference gauges here too, as not all are in gauges |
5453
303701ab73c6
store name and km of reference gauges in measurement_stations too, as not all are in gauges
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5448
diff
changeset
|
328 reference_gauge_name VARCHAR(64), |
5206
8667f629d238
SCHEME CHANGE: Add measurement_station to oracle table and rename comment column
Andre Heinecke <aheinecke@intevation.de>
parents:
5202
diff
changeset
|
329 operator VARCHAR(64), |
8415
ffbeffe2d266
SCHEMA CHANGE: 'comment' is not acceptable as column name for Oracle.
Tom Gottfried <tom@intevation.de>
parents:
8412
diff
changeset
|
330 commentary VARCHAR(512), |
5206
8667f629d238
SCHEME CHANGE: Add measurement_station to oracle table and rename comment column
Andre Heinecke <aheinecke@intevation.de>
parents:
5202
diff
changeset
|
331 PRIMARY KEY (id), |
8642
9db1f48bfea9
Enforce strings we rely on.
Tom Gottfried <tom@intevation.de>
parents:
8641
diff
changeset
|
332 CHECK(measurement_type IN ('Geschiebe', 'Schwebstoff')), |
8412
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
333 CONSTRAINT fk_ms_range_id FOREIGN KEY (range_id) |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
334 REFERENCES ranges(id) ON DELETE CASCADE, |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
335 CONSTRAINT fk_ms_reference_gauge_id FOREIGN KEY (reference_gauge_id) |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
336 REFERENCES gauges(id) ON DELETE CASCADE, |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
337 CONSTRAINT fk_time_interval_id FOREIGN KEY (time_interval_id) |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
338 REFERENCES time_intervals(id) |
4193
f63b39799d2d
Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3953
diff
changeset
|
339 ); |
f63b39799d2d
Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3953
diff
changeset
|
340 |
f63b39799d2d
Adapted DB schema (added relation measurement_station); improved importer to read files from filesystem with measurement stations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3953
diff
changeset
|
341 |
8017
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
342 CREATE SEQUENCE SEDIMENT_LOAD_ID_SEQ; |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
343 |
8018
ad614eff7a9b
SCHEMA CHANGE: consistent naming scheme and drop script for sediment load at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
8017
diff
changeset
|
344 CREATE TABLE sediment_load ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
345 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
346 grain_fraction_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
347 time_interval_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
348 sq_time_interval_id NUMERIC(9,0), |
8017
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
349 description VARCHAR(256), |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
350 kind NUMERIC(9,0), |
8017
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
351 PRIMARY KEY (id), |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
352 CONSTRAINT fk_sl_kind_id FOREIGN KEY (kind) |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8059
diff
changeset
|
353 REFERENCES sediment_load_kinds(id), |
8017
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
354 CONSTRAINT fk_sl_grain_fraction_id FOREIGN KEY (grain_fraction_id) |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
355 REFERENCES grain_fraction(id), |
8641
c851d1ea543a
SCHEMA CHANGE: Remove unnecessary direct relation of sq_relation with rivers.
Tom Gottfried <tom@intevation.de>
parents:
8560
diff
changeset
|
356 CONSTRAINT fk_sl_time_interval_id FOREIGN KEY (time_interval_id) |
8017
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
357 REFERENCES time_intervals(id), |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
358 CONSTRAINT fk_sl_sq_time_interval_id FOREIGN KEY (sq_time_interval_id) |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
359 REFERENCES time_intervals(id) |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
360 ); |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
361 |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
362 |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
363 CREATE SEQUENCE SEDIMENT_LOAD_VALUES_ID_SEQ; |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
364 |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
365 CREATE TABLE sediment_load_values ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
366 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
367 sediment_load_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
368 measurement_station_id NUMERIC(9,0) NOT NULL, |
8017
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
369 value DOUBLE PRECISION NOT NULL, |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
370 PRIMARY KEY (id), |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
371 CONSTRAINT fk_slv_sediment_load_id FOREIGN KEY (sediment_load_id) |
8019 | 372 REFERENCES sediment_load(id) ON DELETE CASCADE, |
8017
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
373 CONSTRAINT fk_slv_m_station_id FOREIGN KEY (measurement_station_id) |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
374 REFERENCES measurement_station(id) ON DELETE CASCADE |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
375 ); |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
376 |
bcb05a98bb3f
SCHEMA CHANGE: Added new structure for sediment loads measured at measurement stations.
Tom Gottfried <tom@intevation.de>
parents:
7924
diff
changeset
|
377 |
3793
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
378 CREATE SEQUENCE SQ_RELATION_ID_SEQ; |
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
379 |
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
380 CREATE TABLE sq_relation ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
381 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
382 time_interval_id NUMERIC(9,0) NOT NULL, |
3793
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
383 description VARCHAR(256), |
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
384 PRIMARY KEY (id), |
8412
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
385 CONSTRAINT fk_sqr_tinterval_id FOREIGN KEY (time_interval_id) |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
386 REFERENCES time_intervals(id) |
3793
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
387 ); |
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
388 |
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
389 |
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
390 CREATE SEQUENCE SQ_RELATION_VALUES_ID_SEQ; |
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
391 |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
392 --FIXME: adjust precision and scale of the numerics |
3793
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
393 CREATE TABLE sq_relation_value ( |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
394 id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
395 sq_relation_id NUMERIC(9,0) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
396 measurement_station_id NUMERIC(9,0) NOT NULL, |
5455
45c5b8b08ffd
Schema Change: use parameter instead of fraction in sq_relation_value
Tom Gottfried <tom.gottfried@intevation.de>
parents:
5453
diff
changeset
|
397 parameter VARCHAR(1) NOT NULL, |
8943
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
398 a NUMERIC(38,20) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
399 b NUMERIC(38,20) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
400 qmax NUMERIC(38,20) NOT NULL, |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
401 rsq NUMERIC(38,3), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
402 ntot NUMERIC(9,0), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
403 noutl NUMERIC(9,0), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
404 cferguson NUMERIC(38,20), |
71b17f731762
Same data types, precision and scale as in Oracle (as far as possible)
mschaefer
parents:
8691
diff
changeset
|
405 cduan NUMERIC(38,20), |
3793
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
406 PRIMARY KEY (id), |
8691
bfca77cbf353
(issue1750) There can be only one SQ-relation of a parameter for a time range (given by sq_relation_id) per station and some other attributes might be null.
Tom Gottfried <tom@intevation.de>
parents:
8666
diff
changeset
|
407 UNIQUE(sq_relation_id, measurement_station_id, parameter), |
8412
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
408 CONSTRAINT fk_sqr_id FOREIGN KEY (sq_relation_id) |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
409 REFERENCES sq_relation(id) ON DELETE CASCADE, |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
410 CONSTRAINT fk_mstation_id FOREIGN KEY (measurement_station_id) |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8072
diff
changeset
|
411 REFERENCES measurement_station(id) ON DELETE CASCADE |
3793
8f232119011e
FYLS-Backend: Bring MINFO schemes of Oracle and PostgreSQL back in sync.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2858
diff
changeset
|
412 ); |
2823
13b3fcaa1b34
Add MINFO schema for PostgreSQL
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
413 COMMIT; |