Mercurial > dive4elements > river
diff flys-backend/doc/schema/postgresql-spatial.sql @ 2796:f3b4e32b5db6
Improved the db schema for storing existing floodmaps.
flys-backend/trunk@4125 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 06 Mar 2012 11:54:41 +0000 |
parents | 918877ee70e7 |
children | e41d03bf9807 |
line wrap: on
line diff
--- a/flys-backend/doc/schema/postgresql-spatial.sql Tue Mar 06 07:45:30 2012 +0000 +++ b/flys-backend/doc/schema/postgresql-spatial.sql Tue Mar 06 11:54:41 2012 +0000 @@ -123,4 +123,34 @@ ALTER TABLE hws ALTER COLUMN id SET DEFAULT NEXTVAL('HWS_ID_SEQ'); +--Hydrologie/UeSG +CREATE SEQUENCE FLOODMAPS_ID_SEQ; +CREATE TABLE floodmaps ( + id int PRIMARY KEY NOT NULL, + river_id int REFERENCES rivers(id), + kind int NOT NULL, + diff NUMERIC, + count int, + area NUMERIC, + perimeter NUMERIC +); +ALTER TABLE floodmaps ALTER COLUMN id SET DEFAULT NEXTVAL('FLOODMAPS_ID_SEQ'); + + +CREATE SEQUENCE POLYGONS_SEQ; +CREATE TABLE polygons ( + id int PRIMARY KEY NOT NULL +); +SELECT AddGeometryColumn('polygons', 'geom', 31466, 'POLYGON', 2); +ALTER TABLE polygons ALTER COLUMN id SET DEFAULT NEXTVAL('POLYGONS_SEQ'); + + +CREATE SEQUENCE FLOODMAP_GEOMS_SEQ; +CREATE TABLE floodmap_geoms ( + id int PRIMARY KEY NOT NULL, + floodmaps_id int NOT NULL REFERENCES floodmaps(id), + polygons_id int NOT NULL REFERENCES polygons(id) +); +ALTER TABLE floodmap_geoms ALTER COLUMN id SET DEFAULT NEXTVAL('FLOODMAP_GEOMS_SEQ'); + END;