diff flys-backend/doc/schema/postgresql.sql @ 1203:3c01bef43a98

Querprofile: Added a table to map the points to a given km. flys-backend/trunk@2308 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 07 Jul 2011 15:59:24 +0000
parents 44581b40b968
children 5f1506fc7636
line wrap: on
line diff
--- a/flys-backend/doc/schema/postgresql.sql	Thu Jul 07 15:20:19 2011 +0000
+++ b/flys-backend/doc/schema/postgresql.sql	Thu Jul 07 15:59:24 2011 +0000
@@ -266,21 +266,29 @@
 
 CREATE TABLE cross_sections (
     id               int PRIMARY KEY NOT NULL,
-    km               NUMERIC         NOT NULL,
     river_id         int             NOT NULL REFERENCES rivers(id),
-    time_interval_id int             REFERENCES time_intervals(id),
+    time_interval_id int                      REFERENCES time_intervals(id),
     description      VARCHAR(256)
 );
 
+CREATE SEQUENCE CROSS_SECTION_LINES_SEQ;
+
+CREATE TABLE cross_section_lines (
+    id               int PRIMARY KEY NOT NULL,
+    km               NUMERIC         NOT NULL,
+    cross_section_id int             NOT NULL REFERENCES cross_sections(id),
+    UNIQUE (km, cross_section_id)
+);
+
 CREATE SEQUENCE CROSS_SECTION_POINTS_ID_SEQ;
 
 CREATE TABLE cross_section_points (
-    id               int PRIMARY KEY NOT NULL,
-    cross_section_id int NOT NULL REFERENCES cross_sections(id),
-    col_pos          int NOT NULL,
-    x                NUMERIC NOT NULL,
-    y                NUMERIC NOT NULL
-    UNIQUE (cross_section_id, col_pos)
+    id                    int PRIMARY KEY NOT NULL,
+    cross_section_line_id int             NOT NULL REFERENCES cross_section_lines(id),
+    col_pos               int             NOT NULL,
+    x                     NUMERIC         NOT NULL,
+    y                     NUMERIC         NOT NULL,
+    UNIQUE (cross_section_line_id, col_pos)
 );
 
 COMMIT;

http://dive4elements.wald.intevation.org