changeset 82:c71e43f88ae0

Add auxilliary tables.
author Tom Gottfried <tom@intevation.de>
date Thu, 31 May 2018 18:39:17 +0200
parents acaa485c0c1e
children d9d01dc58f60
files wamos.sql
diffstat 1 files changed, 37 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/wamos.sql	Thu May 31 17:54:32 2018 +0200
+++ b/wamos.sql	Thu May 31 18:39:17 2018 +0200
@@ -41,13 +41,45 @@
 --
 -- Auxilliary tables
 --
+CREATE TABLE wamos.system_config (
+       config_key varchar PRIMARY KEY,
+       config_val varchar
+       );
 
--- TODO: Add table to manage users e-mail adresses (APUC9)
--- TODO: Add table for responsibility areas and link to users
--- TODO: Store reports/statistics templates per user (APUC6, SPUC13)
+CREATE TABLE wamos.countries (
+       country_code char(2) PRIMARY KEY -- ISO 3166 country code
+       -- A smallint PK would require even less disk space i.e. on the FK side.
+       -- This might be an issue in case cache space becomes a limiting
+       -- factor when there are many FKs pointing here.
+       );
+
+CREATE TABLE wamos.responsibility_areas (
+       country char(2) PRIMARY KEY REFERENCES countries,
+       area geometry(POLYGON, 4326)
+       );
 
--- TODO: Do we need to store system config (APUC10) in database?
--- TODO: Will we store any pre-calculated cross sections in database (SPUC3)?
+CREATE TABLE wamos.user_profiles (
+       username varchar PRIMARY KEY, -- TODO: check it's in pg_roles by trigger
+       country char(2) REFERENCES countries,
+       email_adress varchar NOT NULL UNIQUE
+       );
+
+CREATE TABLE wamos.templates (
+       id int PRIMARY KEY,
+       dummy_attrib varchar,
+       "..." varchar
+       -- TODO: template attributes tbd.
+       );
+
+CREATE TABLE wamos.user_templates (
+       username varchar NOT NULL REFERENCES user_profiles,
+       template_id int NOT NULL REFERENCES templates,
+       PRIMARY KEY (username, template_id)
+       );
+
+--
+-- General river information
+--
 
 -- Eventually obsolete.
 -- See https://roundup-intern.intevation.de/wamos/issue5
@@ -64,16 +96,6 @@
 --        EXCLUDE USING GIST (stretch WITH &&)
 --        );
 
-CREATE TABLE wamos.countries (
-       country_code char(2) PRIMARY KEY -- ISO 3166 country code
-       -- A smallint PK would require even less disk space i.e. on the FK side.
-       -- This might be an issue in case cache space becomes a limiting
-       -- factor when there are many FKs pointing here.
-       );
-
---
--- General river information
---
 CREATE TABLE wamos_waterway.waterway_area (
        dummy_attrib varchar,
        "..." varchar