Mercurial > dive4elements > river
diff flys-backend/doc/schema/postgresql-minfo.sql @ 4991:b79eb203032d dami
SCHEMA CHANGE: added 'ON DELETE CASCADE' where necessary to delete complete rivers (only in Postgres-Schema so far)
author | Tom Gottfried <tom.gottfried@intevation.de> |
---|---|
date | Thu, 14 Feb 2013 17:36:10 +0100 |
parents | 504cd5801785 |
children | 646c154477fe |
line wrap: on
line diff
--- a/flys-backend/doc/schema/postgresql-minfo.sql Thu Feb 14 10:54:02 2013 +0100 +++ b/flys-backend/doc/schema/postgresql-minfo.sql Thu Feb 14 17:36:10 2013 +0100 @@ -46,12 +46,12 @@ evaluation_by VARCHAR(255), description VARCHAR(255), PRIMARY KEY(id), - CONSTRAINT fk_bed_single_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_bed_single_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, CONSTRAINT fk_type FOREIGN KEY (type_id) REFERENCES bed_height_type(id), CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) REFERENCES location_system(id), CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), CONSTRAINT fk_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), - CONSTRAINT fk_range FOREIGN KEY (range_id) REFERENCES ranges(id) + CONSTRAINT fk_range FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE ); @@ -72,7 +72,7 @@ CONSTRAINT fk_time_interval FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id), CONSTRAINT fk_epoch_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id), CONSTRAINT fk_epoch_old_elevation_model FOREIGN KEY (old_elevation_model_id) REFERENCES elevation_model(id), - CONSTRAINT fk_epoch_range FOREIGN KEY (range_id) REFERENCES ranges(id) + CONSTRAINT fk_epoch_range FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE ); @@ -88,7 +88,7 @@ sounding_width NUMERIC, width NUMERIC, PRIMARY KEY(id), - CONSTRAINT fk_bed_single_values_parent FOREIGN KEY (bed_height_single_id) REFERENCES bed_height_single(id) + CONSTRAINT fk_bed_single_values_parent FOREIGN KEY (bed_height_single_id) REFERENCES bed_height_single(id) ON DELETE CASCADE ); @@ -100,7 +100,7 @@ station NUMERIC NOT NULL, height NUMERIC, PRIMARY KEY(id), - CONSTRAINT fk_bed_epoch_values_parent FOREIGN KEY (bed_height_epoch_id) REFERENCES bed_height_epoch(id) + CONSTRAINT fk_bed_epoch_values_parent FOREIGN KEY (bed_height_epoch_id) REFERENCES bed_height_epoch(id) ON DELETE CASCADE ); @@ -125,7 +125,7 @@ unit_id int NOT NULL, description VARCHAR(256), PRIMARY KEY(id), - CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id), CONSTRAINT fk_sd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id) ); @@ -141,7 +141,7 @@ description VARCHAR(256), year int, PRIMARY KEY(id), - CONSTRAINT fk_sdv_sediment_density_id FOREIGN KEY(sediment_density_id) REFERENCES sediment_density(id) + CONSTRAINT fk_sdv_sediment_density_id FOREIGN KEY(sediment_density_id) REFERENCES sediment_density(id) ON DELETE CASCADE ); @@ -152,7 +152,7 @@ river_id int NOT NULL, unit_id int NOT NULL, PRIMARY KEY(id), - CONSTRAINT fk_mw_river_id FOREIGN KEY(river_id) REFERENCES rivers(id), + CONSTRAINT fk_mw_river_id FOREIGN KEY(river_id) REFERENCES rivers(id) ON DELETE CASCADE, CONSTRAINT fk_mw_unit_id FOREIGN KEY(unit_id) REFERENCES units(id) ); @@ -166,7 +166,7 @@ width NUMERIC NOT NULL, description VARCHAR(256), PRIMARY KEY(id), - CONSTRAINT fk_mwv_morphologic_width_id FOREIGN KEY (morphologic_width_id) REFERENCES morphologic_width(id) + CONSTRAINT fk_mwv_morphologic_width_id FOREIGN KEY (morphologic_width_id) REFERENCES morphologic_width(id) ON DELETE CASCADE ); @@ -180,7 +180,7 @@ lower_discharge VARCHAR(16) NOT NULL, upper_discharge VARCHAR(16), PRIMARY KEY(id), - CONSTRAINT fk_dz_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) + CONSTRAINT fk_dz_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE ); @@ -192,8 +192,8 @@ discharge_zone_id int NOT NULL, description VARCHAR(256), PRIMARY KEY (id), - CONSTRAINT fk_fvm_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), - CONSTRAINT fk_fvm_discharge_zone_id FOREIGN KEY (discharge_zone_id) REFERENCES discharge_zone (id) + CONSTRAINT fk_fvm_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, + CONSTRAINT fk_fvm_discharge_zone_id FOREIGN KEY (discharge_zone_id) REFERENCES discharge_zone (id) ON DELETE CASCADE ); @@ -208,7 +208,7 @@ main_channel NUMERIC NOT NULL, shear_stress NUMERIC NOT NULL, PRIMARY KEY(id), - CONSTRAINT fk_fvv_flow_velocity_model_id FOREIGN KEY (flow_velocity_model_id) REFERENCES flow_velocity_model(id) + CONSTRAINT fk_fvv_flow_velocity_model_id FOREIGN KEY (flow_velocity_model_id) REFERENCES flow_velocity_model(id) ON DELETE CASCADE ); @@ -220,7 +220,7 @@ river_id int NOT NULL, description VARCHAR(256), PRIMARY KEY (id), - CONSTRAINT fk_fvm_rivers_id FOREIGN KEY (river_id) REFERENCES rivers(id) + CONSTRAINT fk_fvm_rivers_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE ); CREATE SEQUENCE FV_MEASURE_VALUES_ID_SEQ; @@ -235,7 +235,7 @@ v NUMERIC NOT NULL, description VARCHAR(256), PRIMARY KEY (id), - CONSTRAINT fk_fvmv_measurements_id FOREIGN KEY (measurements_id) REFERENCES flow_velocity_measurements (id) + CONSTRAINT fk_fvmv_measurements_id FOREIGN KEY (measurements_id) REFERENCES flow_velocity_measurements (id) ON DELETE CASCADE ); @@ -262,7 +262,7 @@ time_interval_id int NOT NULL, description VARCHAR(256), PRIMARY KEY (id), - CONSTRAINT fk_sy_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_sy_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, CONSTRAINT fk_sy_grain_fraction_id FOREIGN KEY (grain_fraction_id) REFERENCES grain_fraction(id), CONSTRAINT fk_sy_unit_id FOREIGN KEY (unit_id) REFERENCES units(id), CONSTRAINT fk_sy_time_interval_id FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id) @@ -277,7 +277,7 @@ station NUMERIC NOT NULL, value NUMERIC NOT NULL, PRIMARY KEY (id), - CONSTRAINT fk_syv_sediment_yield_id FOREIGN KEY (sediment_yield_id) REFERENCES sediment_yield(id) + CONSTRAINT fk_syv_sediment_yield_id FOREIGN KEY (sediment_yield_id) REFERENCES sediment_yield(id) ON DELETE CASCADE ); @@ -289,7 +289,7 @@ unit_id int NOT NULL, description VARCHAR(256), PRIMARY KEY (id), - CONSTRAINT fk_w_river_id FOREIGN KEY (river_id) REFERENCES rivers(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) ); @@ -301,7 +301,7 @@ waterlevel_id int NOT NULL, q NUMERIC NOT NULL, PRIMARY KEY (id), - CONSTRAINT fk_wqr_waterlevel_id FOREIGN KEY (waterlevel_id) REFERENCES waterlevel(id) + CONSTRAINT fk_wqr_waterlevel_id FOREIGN KEY (waterlevel_id) REFERENCES waterlevel(id) ON DELETE CASCADE ); @@ -313,7 +313,7 @@ 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) + CONSTRAINT fk_wv_waterlevel_q_range_id FOREIGN KEY (waterlevel_q_range_id) REFERENCES waterlevel_q_range(id) ON DELETE CASCADE ); @@ -325,7 +325,7 @@ unit_id int NOT NULL, description VARCHAR(256), PRIMARY KEY (id), - CONSTRAINT fk_wd_river_id FOREIGN KEY (river_id) REFERENCES rivers (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) ); @@ -337,7 +337,7 @@ difference_id int NOT NULL, description VARCHAR(256), PRIMARY KEY (id), - CONSTRAINT fk_wdc_difference_id FOREIGN KEY (difference_id) REFERENCES waterlevel_difference (id) + CONSTRAINT fk_wdc_difference_id FOREIGN KEY (difference_id) REFERENCES waterlevel_difference (id) ON DELETE CASCADE ); @@ -349,7 +349,7 @@ 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) + CONSTRAINT fk_wdv_column_id FOREIGN KEY (column_id) REFERENCES waterlevel_difference_column (id) ON DELETE CASCADE ); @@ -367,9 +367,9 @@ operator VARCHAR(64), comment VARCHAR(512), PRIMARY KEY (id), - CONSTRAINT fk_ms_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), - CONSTRAINT fk_ms_range_id FOREIGN KEY (range_id) REFERENCES ranges(id), - CONSTRAINT fk_ms_reference_gauge_id FOREIGN KEY (reference_gauge_id) REFERENCES gauges(id), + CONSTRAINT fk_ms_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, + CONSTRAINT fk_ms_range_id FOREIGN KEY (range_id) REFERENCES ranges(id) ON DELETE CASCADE, + CONSTRAINT fk_ms_reference_gauge_id FOREIGN KEY (reference_gauge_id) REFERENCES gauges(id) ON DELETE CASCADE, CONSTRAINT fk_ms_observation_timerange_id FOREIGN KEY (observation_timerange_id) REFERENCES time_intervals(id), UNIQUE (river_id, station) ); @@ -383,7 +383,7 @@ time_interval_id int NOT NULL, description VARCHAR(256), PRIMARY KEY (id), - CONSTRAINT fk_sqr_river_id FOREIGN KEY (river_id) REFERENCES rivers(id), + CONSTRAINT fk_sqr_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE, CONSTRAINT fk_sqr_tinterval_id FOREIGN KEY (time_interval_id) REFERENCES time_intervals(id) ); @@ -400,6 +400,6 @@ a NUMERIC NOT NULL, b NUMERIC NOT NULL, PRIMARY KEY (id), - CONSTRAINT fk_sqr_id FOREIGN KEY (sq_relation_id) REFERENCES sq_relation(id) + CONSTRAINT fk_sqr_id FOREIGN KEY (sq_relation_id) REFERENCES sq_relation(id) ON DELETE CASCADE ); COMMIT;