diff flys-backend/doc/schema/postgresql.sql @ 2347:0acf28a3d28a

Removed the Unit from Wsts - added a WstUnit column to rivers. flys-backend/trunk@2884 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 04 Oct 2011 15:28:19 +0000
parents f834b411ca57
children fe89d6cf55fb
line wrap: on
line diff
--- a/flys-backend/doc/schema/postgresql.sql	Tue Oct 04 06:47:00 2011 +0000
+++ b/flys-backend/doc/schema/postgresql.sql	Tue Oct 04 15:28:19 2011 +0000
@@ -1,12 +1,20 @@
 BEGIN;
 
+CREATE SEQUENCE UNITS_ID_SEQ;
+
+CREATE TABLE units (
+    id   int PRIMARY KEY NOT NULL,
+    name VARCHAR(32)     NOT NULL UNIQUE
+);
+
 -- Gewaesser
 CREATE SEQUENCE RIVERS_ID_SEQ;
 
 CREATE TABLE rivers (
-    id    int PRIMARY KEY NOT NULL,
-    name  VARCHAR(256)    NOT NULL UNIQUE,
-    km_up BOOLEAN         NOT NULL DEFAULT true
+    id          int PRIMARY KEY NOT NULL,
+    name        VARCHAR(256)    NOT NULL UNIQUE,
+    km_up       BOOLEAN         NOT NULL DEFAULT true,
+    wst_unit_id int             NOT NULL REFERENCES units(id)
 );
 
 -- Bruecke, Haefen, etc.
@@ -17,13 +25,6 @@
     value VARCHAR(256)    NOT NULL UNIQUE
 );
 
-CREATE SEQUENCE UNITS_ID_SEQ;
-
-CREATE TABLE units (
-    id   int PRIMARY KEY NOT NULL,
-    name VARCHAR(32)     NOT NULL UNIQUE
-);
-
 -- segments from/to at a river
 CREATE SEQUENCE RANGES_ID_SEQ;
 
@@ -169,7 +170,6 @@
     river_id    int NOT NULL REFERENCES rivers(id),
     description VARCHAR(256) NOT NULL,
     kind        int NOT NULL DEFAULT 0,
-    unit_id     int NOT NULL REFERENCES units(id),
     -- TODO: more meta infos
     UNIQUE (river_id, description)
 );

http://dive4elements.wald.intevation.org