[Lada-commits] [PATCH 08 of 14] Reordered table creation to allow inline definition of FKs
Wald Commits
scm-commit at wald.intevation.org
Fri Jul 1 19:55:00 CEST 2016
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1467389843 -7200
# Branch schema-update
# Node ID 813461e9a7beda31a7b003bb50a4da3d74cb08a8
# Parent c22a99d5c6f1295ac03f75c3b4da3ab3450e3d16
Reordered table creation to allow inline definition of FKs.
diff -r c22a99d5c6f1 -r 813461e9a7be db_schema/lada_schema.sql
--- a/db_schema/lada_schema.sql Fri Jul 01 18:11:48 2016 +0200
+++ b/db_schema/lada_schema.sql Fri Jul 01 18:17:23 2016 +0200
@@ -164,32 +164,6 @@
--
--- Name: kommentar_m; Type: TABLE; Schema: land; Owner: -; Tablespace:
---
-
-CREATE TABLE kommentar_m (
- id serial PRIMARY KEY,
- erzeuger character varying(5) NOT NULL,
- datum timestamp without time zone DEFAULT now(),
- text character varying(1024),
- messungs_id integer NOT NULL
-);
-
-
---
--- Name: kommentar_p; Type: TABLE; Schema: land; Owner: -; Tablespace:
---
-
-CREATE TABLE kommentar_p (
- id serial PRIMARY KEY,
- erzeuger character varying(5) NOT NULL,
- datum timestamp without time zone DEFAULT now(),
- text character varying(1024),
- probe_id integer NOT NULL
-);
-
-
---
-- Name: messprogramm; Type: TABLE; Schema: land; Owner: -; Tablespace:
--
@@ -244,69 +218,6 @@
--
--- Name: messung; Type: TABLE; Schema: land; Owner: -; Tablespace:
---
-
-CREATE TABLE messung (
- id serial PRIMARY KEY,
- id_alt integer DEFAULT nextval('land.messung_messung_id_alt_seq'::regclass) NOT NULL,
- probe_id integer NOT NULL,
- nebenproben_nr character varying(10),
- mmt_id character varying(2) NOT NULL,
- messdauer integer,
- messzeitpunkt timestamp with time zone,
- fertig boolean DEFAULT false NOT NULL,
- status integer,
- letzte_aenderung timestamp without time zone DEFAULT now(),
- geplant boolean DEFAULT false NOT NULL,
- tree_modified timestamp without time zone DEFAULT now()
-);
-
-
---
--- Name: messwert; Type: TABLE; Schema: land; Owner: -; Tablespace:
---
-
-CREATE TABLE messwert (
- id serial PRIMARY KEY,
- messungs_id integer NOT NULL,
- messgroesse_id integer NOT NULL,
- messwert_nwg character varying(1),
- messwert double precision NOT NULL,
- messfehler real,
- nwg_zu_messwert double precision,
- meh_id smallint NOT NULL,
- grenzwertueberschreitung boolean DEFAULT false,
- letzte_aenderung timestamp without time zone DEFAULT now(),
- tree_modified timestamp without time zone DEFAULT now(),
- UNIQUE (messungs_id, messgroesse_id)
-);
-CREATE TRIGGER letzte_aenderung_messwert BEFORE UPDATE ON messwert FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung();
-
-
---
--- Name: ortszuordnung; Type: TABLE; Schema: land; Owner: -; Tablespace:
---
-
-CREATE TABLE ortszuordnung (
- id serial PRIMARY KEY,
- probe_id integer NOT NULL,
- ort_id bigint NOT NULL,
- ortszuordnung_typ character varying(1),
- ortszusatztext character varying(100),
- letzte_aenderung timestamp without time zone DEFAULT now(),
- tree_modified timestamp without time zone DEFAULT now()
-);
-CREATE TRIGGER letzte_aenderung_ortszuordnung BEFORE UPDATE ON ortszuordnung FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung();
-
---
--- Name: COLUMN ortszuordnung.ortszuordnung_typ; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN ortszuordnung.ortszuordnung_typ IS 'E = Entnahmeport, U = Ursprungsort, Z = Ortszusatz';
-
-
---
-- Name: probe; Type: TABLE; Schema: land; Owner: -; Tablespace:
--
@@ -342,90 +253,34 @@
);
CREATE TRIGGER letzte_aenderung_probe BEFORE UPDATE ON probe FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung();
+
--
--- Name: COLUMN probe.id; Type: COMMENT; Schema: land; Owner: -
+-- Name: kommentar_p; Type: TABLE; Schema: land; Owner: -; Tablespace:
--
-COMMENT ON COLUMN probe.id IS 'interner Probenschlüssel';
-
-
---
--- Name: COLUMN probe.test; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.test IS 'Ist Testdatensatz?';
-
-
---
--- Name: COLUMN probe.mst_id; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.mst_id IS 'ID für Messstelle';
-
-
---
--- Name: COLUMN probe.labor_mst_id; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.labor_mst_id IS '-- ID für Messlabor';
-
-
---
--- Name: COLUMN probe.hauptproben_nr; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.hauptproben_nr IS 'externer Probensclüssel';
-
-
---
--- Name: COLUMN probe.ba_id; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.ba_id IS 'ID der Betriebsart (normal/Routine oder Störfall/intensiv)';
-
-
---
--- Name: COLUMN probe.probenart_id; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.probenart_id IS 'ID der Probenart(Einzel-, Sammel-, Misch- ...Probe)';
-
-
---
--- Name: COLUMN probe.media_desk; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.media_desk IS 'Mediencodierung (Deskriptoren oder ADV-Codierung)';
-
-
---
--- Name: COLUMN probe.media; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.media IS 'dekodierte Medienbezeichnung (aus media_desk abgeleitet)';
-
-
---
--- Name: COLUMN probe.umw_id; Type: COMMENT; Schema: land; Owner: -
---
-
-COMMENT ON COLUMN probe.umw_id IS 'ID für Umweltbereich';
-
-
---
--- Name: status_protokoll; Type: TABLE; Schema: land; Owner: -; Tablespace:
---
-
-CREATE TABLE status_protokoll (
+CREATE TABLE kommentar_p (
id serial PRIMARY KEY,
erzeuger character varying(5) NOT NULL,
datum timestamp without time zone DEFAULT now(),
text character varying(1024),
- messungs_id integer NOT NULL,
- status_stufe integer NOT NULL,
- status_wert integer NOT NULL,
+ probe_id integer NOT NULL
+);
+
+
+--
+-- Name: ortszuordnung; Type: TABLE; Schema: land; Owner: -; Tablespace:
+--
+
+CREATE TABLE ortszuordnung (
+ id serial PRIMARY KEY,
+ probe_id integer NOT NULL,
+ ort_id bigint NOT NULL,
+ ortszuordnung_typ character varying(1),
+ ortszusatztext character varying(100),
+ letzte_aenderung timestamp without time zone DEFAULT now(),
tree_modified timestamp without time zone DEFAULT now()
);
+CREATE TRIGGER letzte_aenderung_ortszuordnung BEFORE UPDATE ON ortszuordnung FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung();
--
@@ -447,6 +302,153 @@
--
+-- Name: COLUMN ortszuordnung.ortszuordnung_typ; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN ortszuordnung.ortszuordnung_typ IS 'E = Entnahmeport, U = Ursprungsort, Z = Ortszusatz';
+
+
+--
+-- Name: COLUMN probe.id; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.id IS 'interner Probenschlüssel';
+
+
+--
+-- Name: COLUMN probe.test; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.test IS 'Ist Testdatensatz?';
+
+
+--
+-- Name: COLUMN probe.mst_id; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.mst_id IS 'ID für Messstelle';
+
+
+--
+-- Name: COLUMN probe.labor_mst_id; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.labor_mst_id IS '-- ID für Messlabor';
+
+
+--
+-- Name: COLUMN probe.hauptproben_nr; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.hauptproben_nr IS 'externer Probensclüssel';
+
+
+--
+-- Name: COLUMN probe.ba_id; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.ba_id IS 'ID der Betriebsart (normal/Routine oder Störfall/intensiv)';
+
+
+--
+-- Name: COLUMN probe.probenart_id; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.probenart_id IS 'ID der Probenart(Einzel-, Sammel-, Misch- ...Probe)';
+
+
+--
+-- Name: COLUMN probe.media_desk; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.media_desk IS 'Mediencodierung (Deskriptoren oder ADV-Codierung)';
+
+
+--
+-- Name: COLUMN probe.media; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.media IS 'dekodierte Medienbezeichnung (aus media_desk abgeleitet)';
+
+
+--
+-- Name: COLUMN probe.umw_id; Type: COMMENT; Schema: land; Owner: -
+--
+
+COMMENT ON COLUMN probe.umw_id IS 'ID für Umweltbereich';
+
+
+--
+-- Name: messung; Type: TABLE; Schema: land; Owner: -; Tablespace:
+--
+
+CREATE TABLE messung (
+ id serial PRIMARY KEY,
+ id_alt integer DEFAULT nextval('land.messung_messung_id_alt_seq'::regclass) NOT NULL,
+ probe_id integer NOT NULL,
+ nebenproben_nr character varying(10),
+ mmt_id character varying(2) NOT NULL,
+ messdauer integer,
+ messzeitpunkt timestamp with time zone,
+ fertig boolean DEFAULT false NOT NULL,
+ status integer,
+ letzte_aenderung timestamp without time zone DEFAULT now(),
+ geplant boolean DEFAULT false NOT NULL,
+ tree_modified timestamp without time zone DEFAULT now()
+);
+
+
+--
+-- Name: kommentar_m; Type: TABLE; Schema: land; Owner: -; Tablespace:
+--
+
+CREATE TABLE kommentar_m (
+ id serial PRIMARY KEY,
+ erzeuger character varying(5) NOT NULL,
+ datum timestamp without time zone DEFAULT now(),
+ text character varying(1024),
+ messungs_id integer NOT NULL
+);
+
+
+--
+-- Name: messwert; Type: TABLE; Schema: land; Owner: -; Tablespace:
+--
+
+CREATE TABLE messwert (
+ id serial PRIMARY KEY,
+ messungs_id integer NOT NULL,
+ messgroesse_id integer NOT NULL,
+ messwert_nwg character varying(1),
+ messwert double precision NOT NULL,
+ messfehler real,
+ nwg_zu_messwert double precision,
+ meh_id smallint NOT NULL,
+ grenzwertueberschreitung boolean DEFAULT false,
+ letzte_aenderung timestamp without time zone DEFAULT now(),
+ tree_modified timestamp without time zone DEFAULT now(),
+ UNIQUE (messungs_id, messgroesse_id)
+);
+CREATE TRIGGER letzte_aenderung_messwert BEFORE UPDATE ON messwert FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung();
+
+
+--
+-- Name: status_protokoll; Type: TABLE; Schema: land; Owner: -; Tablespace:
+--
+
+CREATE TABLE status_protokoll (
+ id serial PRIMARY KEY,
+ erzeuger character varying(5) NOT NULL,
+ datum timestamp without time zone DEFAULT now(),
+ text character varying(1024),
+ messungs_id integer NOT NULL,
+ status_stufe integer NOT NULL,
+ status_wert integer NOT NULL,
+ tree_modified timestamp without time zone DEFAULT now()
+);
+
+
+--
-- Name: messung_probe_id_idx; Type: INDEX; Schema: land; Owner: -; Tablespace:
--
More information about the Lada-commits
mailing list