changeset 5207:2919cdc4e858

corrected constraints on table gauges
author Tom Gottfried <tom@intevation.de>
date Fri, 08 Mar 2013 16:51:55 +0100
parents 8667f629d238
children fb0a5285fe26
files flys-backend/doc/schema/oracle.sql flys-backend/doc/schema/postgresql.sql
diffstat 2 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/doc/schema/oracle.sql	Fri Mar 08 15:16:00 2013 +0100
+++ b/flys-backend/doc/schema/oracle.sql	Fri Mar 08 16:51:55 2013 +0100
@@ -115,14 +115,17 @@
 
 CREATE TABLE gauges (
     id                  NUMBER(38,0) NOT NULL,
-    aeo                 NUMBER(38,2),
-    datum               NUMBER(38,2), 
-    name                VARCHAR2(255),
-    station             NUMBER(38,2),
-    official_number     NUMBER(38,0),
-    range_id            NUMBER(38,0),
+    aeo                 NUMBER(38,2) NOT NULL,
+    datum               NUMBER(38,2) NOT NULL, 
+    name                VARCHAR2(255) NOT NULL,
+    station             NUMBER(38,2) NOT NULL,
+    official_number     NUMBER(38,0) UNIQUE,
+    range_id            NUMBER(38,0) NOT NULL,
+    -- remove river id here because range_id references river already
     river_id            NUMBER(38,0),
-    PRIMARY KEY         (id)
+    PRIMARY KEY         (id),
+    UNIQUE (name, river_id),
+    UNIQUE (river_id, station)
 );
 
 
--- a/flys-backend/doc/schema/postgresql.sql	Fri Mar 08 15:16:00 2013 +0100
+++ b/flys-backend/doc/schema/postgresql.sql	Fri Mar 08 16:51:55 2013 +0100
@@ -81,15 +81,16 @@
 CREATE TABLE gauges (
     id              int PRIMARY KEY NOT NULL,
     name            VARCHAR(256)    NOT NULL,
+    -- remove river id here because range_id references river already
     river_id        int             NOT NULL REFERENCES rivers(id) ON DELETE CASCADE,
-    station         NUMERIC         NOT NULL UNIQUE,
+    station         NUMERIC         NOT NULL,
     aeo             NUMERIC         NOT NULL,
-    official_number int8                     UNIQUE,
+    official_number int8            UNIQUE,
 
     -- Pegelnullpunkt
     datum    NUMERIC NOT NULL,
     -- Streckengueltigkeit
-    range_id int REFERENCES ranges (id) ON DELETE CASCADE,
+    range_id int NOT NULL REFERENCES ranges (id) ON DELETE CASCADE,
 
     UNIQUE (name, river_id),
     UNIQUE (river_id, station)

http://dive4elements.wald.intevation.org