diff flys-backend/doc/schema/postgresql-minfo.sql @ 5202:646c154477fe

SCHEMA CHANGE: removed Waterlevel and WaterleveDifferences, added lookup table for wst
author Tom Gottfried <tom@intevation.de>
date Fri, 08 Mar 2013 12:45:48 +0100
parents b79eb203032d
children 8667f629d238
line wrap: on
line diff
--- a/flys-backend/doc/schema/postgresql-minfo.sql	Fri Mar 08 11:48:33 2013 +0100
+++ b/flys-backend/doc/schema/postgresql-minfo.sql	Fri Mar 08 12:45:48 2013 +0100
@@ -20,15 +20,17 @@
     CONSTRAINT fk_unit FOREIGN KEY (unit_id) REFERENCES units(id)
 );
 
-CREATE SEQUENCE BED_HEIGHT_TYPE_SEQ;
 
+-- lookup table for bedheight types
 CREATE TABLE bed_height_type (
     id          int NOT NULL,
-    name        VARCHAR(16)  NOT NULL,
-    description VARCHAR(255),
+    type        VARCHAR(64) NOT NULL,
     PRIMARY KEY(id)
 );
-
+INSERT INTO bed_height_type VALUES (1, 'Querprofil')
+INSERT INTO bed_height_type VALUES (2, 'Flächenpeilung')
+INSERT INTO bed_height_type VALUES (3, 'Flächen- u. Querprofilpeilungen')
+INSERT INTO bed_height_type VALUES (4, 'DGM')
 
 
 CREATE SEQUENCE BED_HEIGHT_SINGLE_ID_SEQ;
@@ -281,78 +283,6 @@
 );
 
 
-CREATE SEQUENCE WATERLEVEL_ID_SEQ;
-
-CREATE TABLE waterlevel (
-    id          int NOT NULL,
-    river_id    int NOT NULL,
-    unit_id     int NOT NULL,
-    description VARCHAR(256),
-    PRIMARY KEY (id),
-    CONSTRAINT fk_w_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE,
-    CONSTRAINT fk_w_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
-);
-
-
-CREATE SEQUENCE WATERLEVEL_Q_RANGES_ID_SEQ;
-
-CREATE TABLE waterlevel_q_range (
-    id              int NOT NULL,
-    waterlevel_id   int NOT NULL,
-    q               NUMERIC NOT NULL,
-    PRIMARY KEY (id),
-    CONSTRAINT fk_wqr_waterlevel_id FOREIGN KEY (waterlevel_id) REFERENCES waterlevel(id) ON DELETE CASCADE
-);
-
-
-CREATE SEQUENCE WATERLEVEL_VALUES_ID_SEQ;
-
-CREATE TABLE waterlevel_values (
-    id                      int NOT NULL,
-    waterlevel_q_range_id   int NOT NULL,
-    station                 NUMERIC NOT NULL,
-    w                       NUMERIC NOT NULL,
-    PRIMARY KEY (id),
-    CONSTRAINT fk_wv_waterlevel_q_range_id FOREIGN KEY (waterlevel_q_range_id) REFERENCES waterlevel_q_range(id) ON DELETE CASCADE
-);
-
-
-CREATE SEQUENCE WATERLEVEL_DIFFERENCE_ID_SEQ;
-
-CREATE TABLE waterlevel_difference (
-    id          int NOT NULL,
-    river_id    int NOT NULL,
-    unit_id     int NOT NULL,
-    description VARCHAR(256),
-    PRIMARY KEY (id),
-    CONSTRAINT fk_wd_river_id FOREIGN KEY (river_id) REFERENCES rivers (id) ON DELETE CASCADE,
-    CONSTRAINT fk_wd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
-);
-
-
-CREATE SEQUENCE WATERLEVEL_DIFF_COLUMN_ID_SEQ;
-
-CREATE TABLE waterlevel_difference_column (
-    id              int NOT NULL,
-    difference_id   int NOT NULL,
-    description     VARCHAR(256),
-    PRIMARY KEY (id),
-    CONSTRAINT fk_wdc_difference_id FOREIGN KEY (difference_id) REFERENCES waterlevel_difference (id) ON DELETE CASCADE
-);
-
-
-CREATE SEQUENCE WATERLEVEL_DIFF_VALUES_ID_SEQ;
-
-CREATE TABLE waterlevel_difference_values (
-    id          int NOT NULL,
-    column_id   int NOT NULL,
-    station     NUMERIC NOT NULL,
-    value       NUMERIC NOT NULL,
-    PRIMARY KEY (id),
-    CONSTRAINT fk_wdv_column_id FOREIGN KEY (column_id) REFERENCES waterlevel_difference_column (id) ON DELETE CASCADE
-);
-
-
 CREATE SEQUENCE MEASUREMENT_STATION_ID_SEQ;
 CREATE TABLE measurement_station (
 	id			             int          NOT NULL,

http://dive4elements.wald.intevation.org