mschaefer@8968: BEGIN; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Add new column wsts.sinfo_selection mschaefer@9008: mschaefer@9008: ALTER TABLE wsts ADD COLUMN sinfo_selection VARCHAR(1) CHECK((sinfo_selection IS NULL) OR (sinfo_selection IN ('W','Q'))); mschaefer@9008: COMMENT ON COLUMN wsts.sinfo_selection IS 'Whether and how the WST series is selected within S-INFO calculation types ("W"=without-Q-group, "Q"=with-Q-group, NULL=not-selectable)' ; mschaefer@9008: mschaefer@9008: mschaefer@9008: --Add new columns bed_height.sounding_width_info and bed_height.comment mschaefer@9008: mschaefer@9032: ALTER TABLE bed_height mschaefer@9032: ADD sounding_width_info VARCHAR(256), mschaefer@9038: ADD notes VARCHAR(256); mschaefer@9008: COMMENT ON COLUMN bed_height.sounding_width_info IS 'File header line info "ausgewertete Peilbreite"' ; mschaefer@9038: COMMENT ON COLUMN bed_height.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@9008: mschaefer@9008: mschaefer@9008: --Add new columns bed_height_values.min_height (Talweg) and bed_height_values.max_height (Kammlage) (same type as existing height column) mschaefer@9008: mschaefer@9032: ALTER TABLE bed_height_values mschaefer@9032: ADD min_height NUMERIC, mschaefer@9032: ADD max_height NUMERIC, mschaefer@9032: ADD height01 NUMERIC, mschaefer@9032: ADD height02 NUMERIC, mschaefer@9032: ADD height03 NUMERIC, mschaefer@9032: ADD height04 NUMERIC, mschaefer@9032: ADD height05 NUMERIC, mschaefer@9032: ADD height06 NUMERIC, mschaefer@9032: ADD height07 NUMERIC, mschaefer@9032: ADD height08 NUMERIC, mschaefer@9032: ADD height09 NUMERIC, mschaefer@9032: ADD height10 NUMERIC; mschaefer@9008: COMMENT ON COLUMN bed_height_values.min_height IS 'Minimum bed height (Talweg) in m' ; mschaefer@9008: COMMENT ON COLUMN bed_height_values.max_height IS 'Maximum bed height (Kammlage) in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height01 IS 'Bed height of section 1 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height02 IS 'Bed height of section 2 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height03 IS 'Bed height of section 3 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height04 IS 'Bed height of section 4 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height05 IS 'Bed height of section 5 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height06 IS 'Bed height of section 6 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height07 IS 'Bed height of section 7 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height08 IS 'Bed height of section 8 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height09 IS 'Bed height of section 9 in m' ; mschaefer@9032: COMMENT ON COLUMN bed_height_values.height10 IS 'Bed height of section 10 in m' ; mschaefer@9008: mschaefer@9008: mschaefer@9008: --Bed mobility mschaefer@9008: mschaefer@8968: CREATE TABLE bed_mobility ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cBedMobilityRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@8968: kmrange_info VARCHAR(32), mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@9038: notes VARCHAR(256) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE bed_mobility IS 'Longitudinal section of the bed mobility of a river' ; mschaefer@8968: COMMENT ON COLUMN bed_mobility.kmrange_info IS 'File header line info "Strecke"' ; mschaefer@8968: COMMENT ON COLUMN bed_mobility.filename IS 'Name without type extension of the imported file' ; mschaefer@9038: COMMENT ON COLUMN bed_mobility.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE BED_MOBILITY_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE bed_mobility_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: bed_mobility_id NUMERIC(9,0) NOT NULL CONSTRAINT cBedMobilityValuesBedMobility REFERENCES bed_mobility(id) ON DELETE CASCADE, mschaefer@8968: station NUMERIC(7,3) NOT NULL, mschaefer@8968: moving NUMERIC(1,0) DEFAULT 0 NOT NULL CHECK(moving IN (0,1)) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE bed_mobility_values IS 'Bed mobility of a km' ; mschaefer@8968: COMMENT ON COLUMN bed_mobility_values.station IS 'River km' ; mschaefer@8968: COMMENT ON COLUMN bed_mobility_values.moving IS 'Whether the river bed at the station is moving' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE BED_MOBILITY_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Infrastructure mschaefer@9008: mschaefer@8968: CREATE TABLE infrastructure ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cInfrastructureRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@8968: annotation_type_id integer NOT NULL CONSTRAINT cInfrastructureAnnotationType REFERENCES annotation_types(id), mschaefer@9614: group_id integer NOT NULL CONSTRAINT cInfrastructureGroupAnnoType REFERENCES annotation_types(id), mschaefer@8968: year NUMERIC(4,0) CHECK((year >= 1700) AND (year <= 2199)), mschaefer@8968: dataprovider VARCHAR(256), mschaefer@8968: evaluation_by VARCHAR(256), mschaefer@8968: kmrange_info VARCHAR(32), mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@9038: notes VARCHAR(256) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE infrastructure IS 'Longitudinal section of infrastructures of a river and a type' ; mschaefer@9614: COMMENT ON COLUMN infrastructure.group_id IS 'Reference to the infrastructure type group'; mschaefer@8968: COMMENT ON COLUMN infrastructure.year IS 'File header line info "Stand"' ; mschaefer@8968: COMMENT ON COLUMN infrastructure.dataprovider IS 'File header line info "Datenherkunft"' ; mschaefer@8968: COMMENT ON COLUMN infrastructure.evaluation_by IS 'File header line info "Auswerter"' ; mschaefer@8968: COMMENT ON COLUMN infrastructure.kmrange_info IS 'File header line info "Strecke"' ; mschaefer@8968: COMMENT ON COLUMN infrastructure.filename IS 'Name without type extension of the imported file' ; mschaefer@9038: COMMENT ON COLUMN infrastructure.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE INFRASTRUCTURE_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE infrastructure_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: infrastructure_id NUMERIC(9,0) CONSTRAINT cInfrastructureValuesInfrastructure REFERENCES infrastructure(id) ON DELETE CASCADE, mschaefer@8968: station NUMERIC(7,3) NOT NULL, mschaefer@8968: attribute_id integer CONSTRAINT cInfrastructureValuesAttributes REFERENCES attributes(id), mschaefer@8968: height NUMERIC(6,2) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE infrastructure_values IS 'Infrastructure at a river station' ; mschaefer@8968: COMMENT ON COLUMN infrastructure_values.station IS 'River km' ; mschaefer@8968: COMMENT ON COLUMN infrastructure_values.height IS 'Geodetic height of the top of the infrastructure in m' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE INFRASTRUCTURE_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Channel mschaefer@9008: mschaefer@8968: CREATE TABLE channel ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cChannelRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@8968: kmrange_info VARCHAR(32), mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@9038: notes VARCHAR(256), mschaefer@8968: year_from NUMERIC(4,0), mschaefer@8968: year_to NUMERIC(4,0) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE channel IS 'Longitudinal section of the navigable channel of a river' ; mschaefer@8968: COMMENT ON COLUMN channel.kmrange_info IS 'File header line info "Strecke"' ; mschaefer@8968: COMMENT ON COLUMN channel.filename IS 'Name without type extension of the imported file' ; mschaefer@9038: COMMENT ON COLUMN channel.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: COMMENT ON COLUMN channel.year_from IS 'Start year of the period for which the channel values are valid, NULL when valid for the whole past'; mschaefer@8968: COMMENT ON COLUMN channel.year_to IS 'End year of the period for which the channel values are valid, NULL when unlimited'; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE SEQUENCE CHANNEL_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE channel_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: channel_id NUMERIC(9,0) CONSTRAINT cChannelValuesChannel REFERENCES channel(id) ON DELETE CASCADE, mschaefer@8968: station NUMERIC(7,3) NOT NULL, mschaefer@8968: width NUMERIC(6,2), mschaefer@8968: depth NUMERIC(6,2) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE channel_values IS 'Nominal size of the navigable channel at a river station' ; mschaefer@8968: COMMENT ON COLUMN channel_values.station IS 'River km' ; mschaefer@8968: COMMENT ON COLUMN channel_values.width IS 'Nominal width of the channel in m' ; mschaefer@8968: COMMENT ON COLUMN channel_values.depth IS 'Nominal depth of the channel in m' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE CHANNEL_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Collision mschaefer@9008: mschaefer@8968: CREATE TABLE collision_type ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: name VARCHAR(64) NOT NULL UNIQUE mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE collision_type IS 'Type of a ship collision' ; mschaefer@8968: COMMENT ON COLUMN collision_type.name IS 'Name of the collision type' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE COLLISION_TYPE_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE collision ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cCollisionRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@8968: year NUMERIC(4,0) NOT NULL, mschaefer@8968: kmrange_info VARCHAR(32), mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@9038: notes VARCHAR(256) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE collision IS 'Longitudinal section of ship collisions with the river bed' ; mschaefer@8968: COMMENT ON COLUMN collision.year IS 'File header line info "Jahr"' ; mschaefer@8968: COMMENT ON COLUMN collision.kmrange_info IS 'File header line info "Strecke"' ; mschaefer@8968: COMMENT ON COLUMN collision.filename IS 'Name without type extension of the imported file' ; mschaefer@9038: COMMENT ON COLUMN collision.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE COLLISION_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE collision_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: collision_id NUMERIC(9,0) NOT NULL CONSTRAINT cCollisionValueCollision REFERENCES collision(id) ON DELETE CASCADE, mschaefer@8968: station NUMERIC(7,3) NOT NULL, mschaefer@8968: event_date DATE NOT NULL, mschaefer@8968: gauge_w NUMERIC(6,2), mschaefer@8968: gauge_name VARCHAR(64), mschaefer@8968: collision_type_id NUMERIC(9,0) NOT NULL CONSTRAINT cCollisionValuesCollisionType REFERENCES collision_type(id) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE collision_values IS 'Collision event' ; mschaefer@8968: COMMENT ON COLUMN collision_values.station IS 'River km' ; mschaefer@8968: COMMENT ON COLUMN collision_values.event_date IS 'Date of the collision' ; mschaefer@8968: COMMENT ON COLUMN collision_values.gauge_w IS 'Waterlevel during the collision' ; mschaefer@8968: COMMENT ON COLUMN collision_values.gauge_name IS 'Name of the gauge' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE COLLISION_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Tkh mschaefer@9008: mschaefer@8968: CREATE TABLE tkh ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cTkhRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@9008: day DATE, mschaefer@8968: kmrange_info VARCHAR(32), mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@9032: groupname VARCHAR(32) NOT NULL CHECK(groupname IN ('messung','berechnung')), mschaefer@8968: sounding_info VARCHAR(64), mschaefer@8968: evaluation_by VARCHAR(256), mschaefer@9038: notes VARCHAR(256) mschaefer@8968: ); mschaefer@8990: COMMENT ON TABLE tkh IS 'Longitudinal section of computed Transportkörperhöhe of a river' ; mschaefer@9008: COMMENT ON COLUMN tkh.day IS 'File header line info "Datum"' ; mschaefer@8968: COMMENT ON COLUMN tkh.kmrange_info IS 'File header line info "Strecke"' ; mschaefer@8968: COMMENT ON COLUMN tkh.filename IS 'Name without type extension of the imported file' ; mschaefer@9032: COMMENT ON COLUMN tkh.groupname IS 'Group the file belongs to' ; mschaefer@8968: COMMENT ON COLUMN tkh.sounding_info IS 'File header line info "Peilung"' ; mschaefer@8968: COMMENT ON COLUMN tkh.evaluation_by IS 'File header line info "Auswerter"' ; mschaefer@9038: COMMENT ON COLUMN tkh.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE TKH_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE tkh_column ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: tkh_id NUMERIC(9,0) NOT NULL CONSTRAINT cTkhColumnTkh REFERENCES tkh(id) ON DELETE CASCADE, mschaefer@8968: name VARCHAR(64) NOT NULL mschaefer@8968: ); mschaefer@8990: COMMENT ON TABLE tkh_column IS 'Longitudinal section of computed Transportkörperhöhe for a waterlevel series' ; mschaefer@8968: COMMENT ON COLUMN tkh_column.name IS 'Name of the tkh computation column' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE TKH_COLUMN_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE tkh_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: tkh_column_id NUMERIC(9,0) NOT NULL CONSTRAINT cTkhValuesTkhColumn REFERENCES tkh_column(id) ON DELETE CASCADE, mschaefer@8968: station NUMERIC(7,3) NOT NULL, mschaefer@8968: tkheight NUMERIC(7,3) mschaefer@8968: ); mschaefer@8990: COMMENT ON TABLE tkh_values IS 'Transportkörperhöhe of a river station and referenced file column' ; mschaefer@8968: COMMENT ON COLUMN tkh_values.station IS 'River km' ; mschaefer@8990: COMMENT ON COLUMN tkh_values.tkheight IS 'Transportkörperhöhe of a river station computed for a waterlevel in m' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE TKH_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Flow depth mschaefer@9008: mschaefer@8968: CREATE TABLE flow_depth ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cFlowDepthRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@8968: year NUMERIC(4,0) NOT NULL, mschaefer@8968: kmrange_info VARCHAR(32), mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@8968: sounding_info VARCHAR(64), mschaefer@8968: evaluation_by VARCHAR(255), mschaefer@9038: notes VARCHAR(256) mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON TABLE flow_depth IS 'Longitudinal section of computed flow depth of a river' ; mschaefer@8968: COMMENT ON COLUMN flow_depth.year IS 'File header line info "Bezugsjahr"' ; mschaefer@8968: COMMENT ON COLUMN flow_depth.kmrange_info IS 'File header line info "Strecke"' ; mschaefer@8968: COMMENT ON COLUMN flow_depth.filename IS 'Name without type extension of the imported file' ; mschaefer@8968: COMMENT ON COLUMN flow_depth.sounding_info IS 'File header line info "Peilung"' ; mschaefer@8968: COMMENT ON COLUMN flow_depth.evaluation_by IS 'File header line info "Auswerter"' ; mschaefer@9038: COMMENT ON COLUMN flow_depth.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE FLOW_DEPTH_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE flow_depth_column ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: flow_depth_id NUMERIC(9,0) NOT NULL CONSTRAINT cFlowDepthColumnFlowDepth REFERENCES flow_depth(id) ON DELETE CASCADE, mschaefer@8968: name VARCHAR(64) NOT NULL mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON TABLE flow_depth_column IS 'Longitudinal section of computed flow depth for a waterlevel series' ; mschaefer@8968: COMMENT ON COLUMN flow_depth_column.name IS 'Name of the flow depth computation column' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE FLOW_DEPTH_COLUMN_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE flow_depth_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: flow_depth_column_id NUMERIC(9,0) NOT NULL CONSTRAINT cFlowDepthValuesFlowDepthColumn REFERENCES flow_depth_column(id) ON DELETE CASCADE, mschaefer@8968: station NUMERIC(7,3) NOT NULL, mschaefer@8968: depth NUMERIC(7,3) mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON TABLE flow_depth_values IS 'Flow depth of a river station and referenced file column' ; mschaefer@8968: COMMENT ON COLUMN flow_depth_values.station IS 'River km' ; mschaefer@8968: COMMENT ON COLUMN flow_depth_values.depth IS 'Flow depth of a river station computed for a waterlevel in m' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE FLOW_DEPTH_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Depth evolution mschaefer@9008: mschaefer@8968: CREATE TABLE depth_evolution ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cDepthEvolutionRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@8968: reference_year NUMERIC(4,0) NOT NULL, mschaefer@8968: start_year NUMERIC(4,0) NOT NULL, mschaefer@8968: curr_sounding VARCHAR(64) NOT NULL, mschaefer@8968: old_sounding VARCHAR(64) NOT NULL, mschaefer@8968: kmrange_info VARCHAR(32), mschaefer@8968: curr_glw VARCHAR(64) NOT NULL, mschaefer@8968: old_glw VARCHAR(64) NOT NULL, mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@9032: groupname VARCHAR(32) NOT NULL CHECK(groupname IN ('aktuell','etappe')), mschaefer@9038: notes VARCHAR(256) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE depth_evolution IS 'Longitudinal section of the evolution of the flow depth of a river' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution.reference_year IS 'File header line info "Bezugsjahr" (GlW)' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution.start_year IS 'File header line info "Ausgangsjahr" (GlW)' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution.curr_sounding IS 'File header line info "Aktuelle Peilung / Epoche"' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution.old_sounding IS 'File header line info "Historische Peilung / Epoche"' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution.kmrange_info IS 'File header line info "Strecke"' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution.curr_glw IS 'File header line info "Aktuelle Wasserspiegellage"' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution.old_glw IS 'File header line info "Historische Wasserspiegellage"' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution.filename IS 'Name without type extension of the imported file' ; mschaefer@9032: COMMENT ON COLUMN depth_evolution.groupname IS 'Group the file belongs to' ; mschaefer@9038: COMMENT ON COLUMN depth_evolution.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE DEPTH_EVOLUTION_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE depth_evolution_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: depth_evolution_id NUMERIC(9,0) NOT NULL CONSTRAINT cDepthEvolutionValuesDepthEvolution REFERENCES depth_evolution(id) ON DELETE CASCADE, mschaefer@8968: station NUMERIC(7,3) NOT NULL, mschaefer@8968: total_change NUMERIC(8,4), mschaefer@8968: change_per_year NUMERIC(8,4) mschaefer@8968: ); mschaefer@8968: COMMENT ON TABLE depth_evolution_values IS 'Evolution of the flow depth of a river station in a referenced period of time' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution_values.station IS 'River km' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution_values.total_change IS 'Flow depth change of the whole period of time in m' ; mschaefer@8968: COMMENT ON COLUMN depth_evolution_values.change_per_year IS 'Average yearly flow depth change in the referenced period of time in m' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE DEPTH_EVOLUTION_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Daily discharge mschaefer@9008: mschaefer@8968: CREATE TABLE daily_discharge ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: gauge_id integer NOT NULL CONSTRAINT cDailyDischargeGauge REFERENCES gauges(id) ON DELETE CASCADE, mschaefer@8968: filename VARCHAR(256) NOT NULL mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON TABLE daily_discharge IS 'Daily discharge value series' ; mschaefer@8968: COMMENT ON COLUMN daily_discharge.filename IS 'Name without type extension of the imported file' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE DAILY_DISCHARGE_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE daily_discharge_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: daily_discharge_id NUMERIC(9,0) NOT NULL CONSTRAINT cDailyDischargeValueDailyDischarge REFERENCES daily_discharge(id) ON DELETE CASCADE, mschaefer@8968: day DATE NOT NULL, mschaefer@8968: discharge NUMERIC(8,3) NOT NULL mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON TABLE daily_discharge_values IS 'Mean daily discharge of a date and a gauge' ; mschaefer@8968: COMMENT ON COLUMN daily_discharge_values.day IS 'Date of the discharge value' ; mschaefer@8968: COMMENT ON COLUMN daily_discharge_values.discharge IS 'Mean daily discharge in m^3/s' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE DAILY_DISCHARGE_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@9008: --Salix line mschaefer@9008: mschaefer@8968: CREATE TABLE salix ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cSalixRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@8968: evaluation_by VARCHAR(255), mschaefer@8968: kmrange_info VARCHAR(32), mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@9038: notes VARCHAR(256) mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON TABLE salix IS 'Longitudinal section of the salix line parameters of a river' ; mschaefer@8968: COMMENT ON COLUMN salix.evaluation_by IS 'File header line info "Auswerter"' ; mschaefer@8968: COMMENT ON COLUMN salix.kmrange_info IS 'File header line info "Strecke"' ; mschaefer@8968: COMMENT ON COLUMN salix.filename IS 'Name without type extension of the imported file' ; mschaefer@9038: COMMENT ON COLUMN salix.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE SALIX_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE salix_values ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8990: salix_id NUMERIC(9,0) NOT NULL CONSTRAINT cSalixValuesSalix REFERENCES salix(id) ON DELETE CASCADE, mschaefer@8968: station NUMERIC(7,3) NOT NULL, mschaefer@8968: factor NUMERIC(6,2) NOT NULL, mschaefer@8968: mnw_mw_diff NUMERIC(6,2) mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON COLUMN salix_values.station IS 'River km' ; mschaefer@8968: COMMENT ON COLUMN salix_values.factor IS 'Salix "factor" of the station in m' ; mschaefer@8968: COMMENT ON COLUMN salix_values.mnw_mw_diff IS 'Difference between MNW and MW in m (less than zero)' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE SALIX_VALUES_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE salix_rank ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: min_value NUMERIC(6,2), mschaefer@8968: max_value NUMERIC(6,2), mschaefer@8968: name VARCHAR(16) NOT NULL mschaefer@8968: ); mschaefer@8968: INSERT INTO salix_rank (id, min_value, max_value, name) VALUES (1, NULL, -0.3, 'invalid'); mschaefer@8968: INSERT INTO salix_rank (id, min_value, max_value, name) VALUES (2, -0.3, 0.3, 'very good'); mschaefer@8968: INSERT INTO salix_rank (id, min_value, max_value, name) VALUES (3, 0.3, 0.5, 'good'); mschaefer@8968: INSERT INTO salix_rank (id, min_value, max_value, name) VALUES (4, 0.5, 1.0, 'moderate'); mschaefer@8968: INSERT INTO salix_rank (id, min_value, max_value, name) VALUES (5, 1.0, 1.5, 'bad'); mschaefer@8968: INSERT INTO salix_rank (id, min_value, max_value, name) VALUES (6, 1.5, NULL, 'very bad'); mschaefer@8968: mschaefer@8968: mschaefer@9008: --Vegetation zone mschaefer@9008: mschaefer@8968: CREATE TABLE vegetation_type ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@9661: name VARCHAR(256) NOT NULL, mschaefer@9661: de_name VARCHAR(256) NOT NULL mschaefer@8968: ); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (1, 'zonal forest', 'Zonaler Wald'); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (2, 'dry hartwood forest floodplain', 'Hartholzaue, trocken'); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (3, 'wet hartwood forest floodplain', 'Hartholzaue, feucht'); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (4, 'salix alba forest', 'Silberweidenwald'); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (5, 'salix shrubs', 'Weidengebüsch'); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (6, 'reed bed', 'Uferröhricht'); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (7, 'bank pioneers', 'Uferpioniere'); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (8, 'no vegetation', 'vegetationslos'); mschaefer@9661: INSERT INTO vegetation_type (id, name, de_name) VALUES (9, 'water', 'Wasserfläche'); mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE vegetation ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: river_id integer NOT NULL CONSTRAINT cVegetationRivers REFERENCES rivers(id) ON DELETE CASCADE, mschaefer@8968: name VARCHAR(256), mschaefer@8968: filename VARCHAR(256) NOT NULL, mschaefer@9038: notes VARCHAR(256) mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON TABLE vegetation IS 'Classification of the vegetation of a river' ; mschaefer@8968: COMMENT ON COLUMN vegetation.name IS 'File header line info "Einteilung"' ; mschaefer@8968: COMMENT ON COLUMN vegetation.filename IS 'Name without type extension of the imported file' ; mschaefer@9038: COMMENT ON COLUMN vegetation.notes IS 'File header line info "weitere Bemerkungen"' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE VEGETATION_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: CREATE TABLE vegetation_zone ( mschaefer@8968: id NUMERIC(9,0) PRIMARY KEY, mschaefer@8968: vegetation_id NUMERIC(9,0) NOT NULL CONSTRAINT cVegetationZoneVegetation REFERENCES vegetation(id) ON DELETE CASCADE, mschaefer@8968: vegetation_type_id NUMERIC(9,0) NOT NULL CONSTRAINT cVegetationZoneVegetationType REFERENCES vegetation_type(id) ON DELETE CASCADE, mschaefer@8968: min_overflow_days NUMERIC(3,0) NOT NULL, mschaefer@9401: max_overflow_days NUMERIC(3,0) NOT NULL, mschaefer@9401: color_r NUMERIC(3,0) NOT NULL, mschaefer@9401: color_g NUMERIC(3,0) NOT NULL, mschaefer@9401: color_b NUMERIC(3,0) NOT NULL mschaefer@8968: ); mschaefer@8968: mschaefer@8968: COMMENT ON TABLE vegetation_zone IS 'Vegetation zone of a river station' ; mschaefer@9508: COMMENT ON COLUMN vegetation_zone.min_overflow_days IS 'Minimum number (exclusive) of overflow days in a year for the zone type' ; mschaefer@9508: COMMENT ON COLUMN vegetation_zone.max_overflow_days IS 'Maximum number (inclusive) of overflow days in a year for the zone type' ; mschaefer@9401: COMMENT ON COLUMN vegetation_zone.color_r IS 'Red value (0-255) of the zone color' ; mschaefer@9401: COMMENT ON COLUMN vegetation_zone.color_g IS 'Green value (0-255) of the zone color' ; mschaefer@9401: COMMENT ON COLUMN vegetation_zone.color_b IS 'Blue value (0-255) of the zone color' ; mschaefer@8968: mschaefer@8968: CREATE SEQUENCE VEGETATION_ZONE_ID_SEQ ; mschaefer@8968: mschaefer@8968: mschaefer@8968: COMMIT;