tom@797: \set ON_ERROR_STOP on tom@797: tom@797: BEGIN; tom@797: tom@741: tom@741: SET statement_timeout = 0; tom@741: SET lock_timeout = 0; tom@741: SET client_encoding = 'UTF8'; tom@741: SET standard_conforming_strings = on; tom@741: SET check_function_bodies = false; tom@741: SET client_min_messages = warning; tom@741: tom@741: -- tom@741: -- Name: bund; Type: SCHEMA; Schema: -; Owner: - tom@741: -- tom@741: tom@741: CREATE SCHEMA bund; tom@741: tom@741: tom@741: -- tom@741: -- Name: land; Type: SCHEMA; Schema: -; Owner: - tom@741: -- tom@741: tom@741: CREATE SCHEMA land; tom@741: tom@741: tom@741: SET search_path = bund, pg_catalog; tom@741: tom@741: -- raimund@751: -- Name: update_time_status(); Type: FUNCTION; Schema: bund; Owner: - raimund@751: -- raimund@751: raimund@751: CREATE FUNCTION update_time_status() RETURNS trigger tom@741: LANGUAGE plpgsql tom@741: AS $$ tom@741: BEGIN raimund@751: NEW.tree_modified = now(); raimund@751: RETURN NEW; tom@741: END; tom@741: $$; tom@741: raimund@926: CREATE FUNCTION update_letzte_aenderung() RETURNS trigger raimund@926: LANGUAGE plpgsql raimund@926: AS $$ raimund@926: BEGIN raimund@926: NEW.letzte_aenderung = now(); raimund@926: RETURN NEW; raimund@926: END; raimund@926: $$; tom@741: tom@741: SET search_path = land, pg_catalog; tom@741: raimund@926: CREATE FUNCTION update_letzte_aenderung() RETURNS trigger raimund@926: LANGUAGE plpgsql raimund@926: AS $$ raimund@926: BEGIN raimund@926: NEW.letzte_aenderung = now(); raimund@926: RETURN NEW; raimund@926: END; raimund@926: $$; raimund@926: tom@741: -- tom@741: -- Name: is_probe_fertig(integer); Type: FUNCTION; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE FUNCTION is_probe_fertig(i1 integer) RETURNS boolean tom@741: LANGUAGE plpgsql STABLE SECURITY DEFINER tom@741: AS $_$ tom@741: DECLARE result BOOLEAN; tom@741: BEGIN tom@741: SELECT (count(id) > 0) INTO result from land.messung where probe_id = $1 and fertig = TRUE; tom@741: RETURN result; tom@741: END; tom@741: $_$; tom@741: tom@741: tom@741: -- tom@741: -- Name: update_time_messung(); Type: FUNCTION; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE FUNCTION update_time_messung() RETURNS trigger tom@741: LANGUAGE plpgsql tom@741: AS $$ tom@741: BEGIN tom@741: RAISE NOTICE 'messung is %',NEW.id; tom@741: NEW.tree_modified = now(); tom@741: UPDATE land.messwert SET tree_modified = now() WHERE messungs_id = NEW.id; raimund@751: UPDATE bund.status_protokoll SET tree_modified = now() WHERE messungs_id = NEW.id; tom@741: RETURN NEW; tom@741: END; tom@741: $$; tom@741: tom@741: tom@741: -- tom@741: -- Name: update_time_messwert(); Type: FUNCTION; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE FUNCTION update_time_messwert() RETURNS trigger tom@741: LANGUAGE plpgsql tom@741: AS $$ tom@741: BEGIN tom@741: NEW.tree_modified = now(); tom@741: RETURN NEW; tom@741: END; tom@741: $$; tom@741: tom@741: tom@741: -- tom@741: -- Name: update_time_ort(); Type: FUNCTION; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE FUNCTION update_time_ort() RETURNS trigger tom@741: LANGUAGE plpgsql tom@741: AS $$ tom@741: BEGIN tom@741: NEW.tree_modified = now(); tom@741: RETURN NEW; tom@741: END; tom@741: $$; tom@741: tom@741: tom@741: -- tom@741: -- Name: update_time_probe(); Type: FUNCTION; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE FUNCTION update_time_probe() RETURNS trigger tom@741: LANGUAGE plpgsql tom@741: AS $$ tom@741: BEGIN tom@741: RAISE NOTICE 'probe is %',NEW.id; tom@741: NEW.tree_modified = now(); tom@741: RAISE NOTICE 'updating other rows'; tom@741: UPDATE land.messung SET tree_modified = now() WHERE probe_id = NEW.id; raimund@824: UPDATE land.ortszuordnung SET tree_modified = now() WHERE probe_id = NEW.id; tom@741: UPDATE land.zusatz_wert SET tree_modified = now() WHERE probe_id = NEW.id; tom@741: RETURN NEW; tom@741: END; tom@741: $$; tom@741: tom@741: tom@741: -- tom@741: -- Name: update_time_zusatzwert(); Type: FUNCTION; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE FUNCTION update_time_zusatzwert() RETURNS trigger tom@741: LANGUAGE plpgsql tom@741: AS $$ tom@741: BEGIN tom@741: NEW.tree_modified = now(); tom@741: RETURN NEW; tom@741: END; tom@741: $$; tom@741: tom@741: tom@741: SET search_path = bund, pg_catalog; tom@741: tom@741: -- tom@741: -- Name: kommentar_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE kommentar_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: SET default_tablespace = ''; tom@741: tom@741: SET default_with_oids = false; tom@741: tom@741: -- tom@799: -- Name: kommentar; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE kommentar ( tom@741: id integer DEFAULT nextval('kommentar_id_seq'::regclass) NOT NULL, tom@741: erzeuger character varying(5) NOT NULL, tom@741: datum timestamp without time zone DEFAULT now(), tom@741: text character varying(1024) tom@741: ); tom@741: tom@741: tom@741: -- tom@799: -- Name: kommentar_m; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE kommentar_m ( tom@741: messungs_id integer NOT NULL tom@741: ) tom@741: INHERITS (kommentar); tom@741: tom@741: tom@741: -- tom@799: -- Name: kommentar_p; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE kommentar_p ( tom@741: probe_id integer NOT NULL tom@741: ) tom@741: INHERITS (kommentar); tom@741: tom@741: tom@741: -- tom@799: -- Name: list; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE list ( tom@741: id integer NOT NULL, tom@741: typ character(1) NOT NULL, tom@741: bezeichnung character varying(20) NOT NULL, tom@741: beschreibuing character varying(512), tom@741: letzte_aenderung timestamp with time zone NOT NULL, tom@741: gueltig_bis timestamp with time zone tom@741: ); raimund@926: CREATE TRIGGER letzte_aenderung_list BEFORE UPDATE ON list FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); tom@741: tom@741: tom@741: -- tom@741: -- Name: list_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE list_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@741: -- Name: list_id_seq; Type: SEQUENCE OWNED BY; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER SEQUENCE list_id_seq OWNED BY list.id; tom@741: tom@741: tom@741: -- tom@799: -- Name: list_zuordnung; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE list_zuordnung ( tom@741: list_id integer NOT NULL, tom@741: probe_id integer tom@741: ); tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE messung_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@799: -- Name: messung; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE messung ( tom@741: id integer DEFAULT nextval('messung_id_seq'::regclass) NOT NULL, tom@741: probe_id integer NOT NULL, tom@741: nebenproben_nr character varying(10), tom@741: mmt_id character varying(2) NOT NULL, tom@741: messdauer integer, tom@741: messzeitpunkt timestamp with time zone, tom@741: fertig boolean DEFAULT false NOT NULL, raimund@751: status integer, tom@741: letzte_aenderung timestamp without time zone DEFAULT now() tom@741: ); raimund@926: CREATE TRIGGER letzte_aenderung_messung BEFORE UPDATE ON messung FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_messung_id_alt_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE messung_messung_id_alt_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_messungs_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE messung_messungs_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@741: -- Name: messwert_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE messwert_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@799: -- Name: messwert; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE messwert ( tom@741: id integer DEFAULT nextval('messwert_id_seq'::regclass) NOT NULL, tom@741: messungs_id integer NOT NULL, tom@741: messgroesse_id integer NOT NULL, tom@741: messwert_nwg character varying(1), tom@914: messwert double precision NOT NULL, tom@741: messfehler real, tom@914: nwg_zu_messwert double precision, tom@741: meh_id smallint NOT NULL, tom@741: grenzwertueberschreitung boolean DEFAULT false, tom@741: letzte_aenderung timestamp without time zone DEFAULT now() tom@741: ); raimund@926: CREATE TRIGGER letzte_aenderung_messwert BEFORE UPDATE ON messwert FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); tom@741: tom@741: tom@741: -- tom@741: -- Name: ort_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE ort_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- raimund@808: -- Name: ortszuordnung; Type: TABLE; Schema: bund; Owner: -; Tablespace: raimund@808: -- raimund@808: raimund@808: CREATE TABLE ortszuordnung ( tom@741: id integer DEFAULT nextval('ort_id_seq'::regclass) NOT NULL, tom@741: probe_id integer NOT NULL, tom@741: ort_id bigint NOT NULL, raimund@808: ortszuordnung_typ character varying(1), tom@741: ortszusatztext character varying(100), tom@741: letzte_aenderung timestamp without time zone DEFAULT now() tom@741: ); raimund@926: CREATE TRIGGER letzte_aenderung_ortszuordnung BEFORE UPDATE ON ortszuordnung FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); tom@741: tom@741: tom@741: -- raimund@808: -- Name: COLUMN ortszuordnung.ortszuordnung_typ; Type: COMMENT; Schema: bund; Owner: - raimund@808: -- raimund@808: raimund@808: COMMENT ON COLUMN ortszuordnung.ortszuordnung_typ IS 'E = Entnahmeport, U = Ursprungsort, Z = Ortszusatz'; tom@741: tom@741: tom@741: -- tom@741: -- Name: probe_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE probe_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@799: -- Name: probe; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE probe ( tom@899: id integer PRIMARY KEY DEFAULT nextval('probe_id_seq'::regclass), tom@741: test boolean DEFAULT false NOT NULL, tom@899: netzbetreiber_id character varying(2) REFERENCES stammdaten.netz_betreiber, tom@901: mst_id character varying(5) NOT NULL tom@901: REFERENCES stammdaten.mess_stelle, tom@901: labor_mst_id character varying(5) NOT NULL tom@901: REFERENCES stammdaten.mess_stelle, tom@741: hauptproben_nr character varying(20), tom@899: datenbasis_id smallint REFERENCES stammdaten.datenbasis, tom@991: ba_id integer, tom@899: probenart_id smallint NOT NULL REFERENCES stammdaten.probenart, tom@741: media_desk character varying(100), tom@741: media character varying(100), tom@899: umw_id character varying(3) REFERENCES stammdaten.umwelt, tom@741: probeentnahme_beginn timestamp with time zone, tom@741: probeentnahme_ende timestamp with time zone, tom@741: mittelungsdauer bigint, tom@924: letzte_aenderung timestamp without time zone DEFAULT now(), tom@924: UNIQUE (mst_id, hauptproben_nr) tom@741: ); tom@741: raimund@926: CREATE TRIGGER letzte_aenderung_probe BEFORE UPDATE ON probe FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); raimund@926: tom@741: -- tom@741: -- Name: COLUMN probe.id; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: COMMENT ON COLUMN probe.id IS 'interner Probenschlüssel'; tom@741: tom@741: tom@741: -- tom@741: -- Name: COLUMN probe.test; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: COMMENT ON COLUMN probe.test IS 'Ist Testdatensatz?'; tom@741: tom@741: tom@741: -- tom@741: -- Name: COLUMN probe.mst_id; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: raimund@751: COMMENT ON COLUMN probe.mst_id IS 'ID für Messstelle'; raimund@751: raimund@751: raimund@751: -- raimund@751: -- Name: COLUMN probe.labor_mst_id; Type: COMMENT; Schema: bund; Owner: - raimund@751: -- raimund@751: raimund@751: COMMENT ON COLUMN probe.labor_mst_id IS '-- ID für Messlabor'; tom@741: tom@741: tom@741: -- tom@741: -- Name: COLUMN probe.hauptproben_nr; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: COMMENT ON COLUMN probe.hauptproben_nr IS 'externer Probensclüssel'; tom@741: tom@741: tom@741: -- tom@741: -- Name: COLUMN probe.ba_id; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: COMMENT ON COLUMN probe.ba_id IS 'ID der Betriebsart (normal/Routine oder Störfall/intensiv)'; tom@741: tom@741: tom@741: -- tom@741: -- Name: COLUMN probe.probenart_id; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: COMMENT ON COLUMN probe.probenart_id IS 'ID der Probenart(Einzel-, Sammel-, Misch- ...Probe)'; tom@741: tom@741: tom@741: -- tom@741: -- Name: COLUMN probe.media_desk; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: COMMENT ON COLUMN probe.media_desk IS 'Mediencodierung (Deskriptoren oder ADV-Codierung)'; tom@741: tom@741: tom@741: -- tom@741: -- Name: COLUMN probe.media; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: COMMENT ON COLUMN probe.media IS 'dekodierte Medienbezeichnung (aus media_desk abgeleitet)'; tom@741: tom@741: tom@741: -- tom@741: -- Name: COLUMN probe.umw_id; Type: COMMENT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: COMMENT ON COLUMN probe.umw_id IS 'ID für Umweltbereich'; tom@741: tom@741: tom@741: -- tom@741: -- Name: probe_probe_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE probe_probe_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@799: -- Name: status_protokoll; Type: TABLE; Schema: bund; Owner: -; Tablespace: raimund@751: -- raimund@751: raimund@751: CREATE TABLE status_protokoll ( raimund@751: status_stufe integer NOT NULL, raimund@751: status_wert integer NOT NULL, raimund@751: tree_modified timestamp without time zone DEFAULT now() raimund@751: ) raimund@751: INHERITS (kommentar_m); tom@741: tom@741: tom@741: -- tom@741: -- Name: zusatz_wert_id_seq; Type: SEQUENCE; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE zusatz_wert_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@799: -- Name: zusatz_wert; Type: TABLE; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE zusatz_wert ( tom@741: id integer DEFAULT nextval('zusatz_wert_id_seq'::regclass) NOT NULL, tom@741: probe_id integer NOT NULL, tom@741: pzs_id character varying(3) NOT NULL, tom@914: messwert_pzs double precision, tom@741: messfehler real, tom@741: letzte_aenderung timestamp without time zone DEFAULT now(), tom@914: nwg_zu_messwert double precision tom@741: ); raimund@926: CREATE TRIGGER letzte_aenderung_zusatzwert BEFORE UPDATE ON zusatz_wert FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); tom@741: tom@741: tom@741: SET search_path = land, pg_catalog; tom@741: tom@741: -- tom@799: -- Name: kommentar_m; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE kommentar_m ( tom@741: ) tom@741: INHERITS (bund.kommentar_m); tom@741: tom@741: tom@741: -- tom@799: -- Name: kommentar_p; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE kommentar_p ( tom@741: ) tom@741: INHERITS (bund.kommentar_p); tom@741: tom@741: tom@741: -- tom@741: -- Name: messprogramm_id_seq; Type: SEQUENCE; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE messprogramm_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@900: -- Name: messprogramm; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@900: -- tom@900: tom@900: CREATE TABLE messprogramm ( tom@900: id integer PRIMARY KEY DEFAULT nextval('messprogramm_id_seq'::regclass), tom@900: name character varying(256), tom@900: test boolean DEFAULT false NOT NULL, tom@900: netzbetreiber_id character varying(2) NOT NULL tom@900: REFERENCES stammdaten.netz_betreiber, tom@900: mst_id character varying(5) NOT NULL REFERENCES stammdaten.mess_stelle, tom@901: labor_mst_id character varying(5) NOT NULL tom@901: REFERENCES stammdaten.mess_stelle, tom@900: datenbasis_id integer NOT NULL REFERENCES stammdaten.datenbasis, tom@1019: ba_id integer DEFAULT 1, tom@900: gem_id character varying(8), tom@989: ort_id integer NOT NULL REFERENCES stammdaten.ort, tom@900: media_desk character varying(100), tom@900: umw_id character varying(3) REFERENCES stammdaten.umwelt, tom@900: probenart_id integer NOT NULL REFERENCES stammdaten.probenart, tom@989: probenintervall character varying(2) NOT NULL, tom@989: teilintervall_von integer NOT NULL, tom@989: teilintervall_bis integer NOT NULL, tom@900: intervall_offset integer, tom@989: gueltig_von integer NOT NULL, tom@989: gueltig_bis integer NOT NULL, tom@900: probe_nehmer_id integer, tom@900: probe_kommentar character varying(80), tom@1044: letzte_aenderung timestamp without time zone DEFAULT now() NOT NULL, tom@1044: CHECK (gueltig_von <= gueltig_bis) tom@900: ); raimund@926: CREATE TRIGGER letzte_aenderung_messprogramm BEFORE UPDATE ON messprogramm FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); tom@900: tom@900: -- tom@741: -- Name: messprogramm_id_seq; Type: SEQUENCE OWNED BY; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER SEQUENCE messprogramm_id_seq OWNED BY messprogramm.id; tom@741: tom@741: tom@741: -- tom@900: -- Name: COLUMN messprogramm.media_desk; Type: COMMENT; Schema: land; Owner: - tom@900: -- tom@900: tom@900: COMMENT ON COLUMN messprogramm.media_desk IS 'dekodierte Medienbezeichnung (aus media_desk abgeleitet)'; tom@900: tom@900: tom@900: -- tom@799: -- Name: messprogramm_mmt; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE messprogramm_mmt ( tom@741: id integer NOT NULL, tom@741: messprogramm_id integer NOT NULL, tom@741: mmt_id character varying(2) NOT NULL, tom@741: messgroessen integer[], tom@741: letzte_aenderung timestamp without time zone DEFAULT now() tom@741: ); raimund@926: CREATE TRIGGER letzte_aenderung_messprogramm_mmt BEFORE UPDATE ON messprogramm_mmt FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung(); tom@741: tom@741: tom@741: -- tom@741: -- Name: messprogramm_mmt_id_seq; Type: SEQUENCE; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE messprogramm_mmt_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@741: -- Name: messprogramm_mmt_id_seq; Type: SEQUENCE OWNED BY; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER SEQUENCE messprogramm_mmt_id_seq OWNED BY messprogramm_mmt.id; tom@741: tom@741: tom@741: -- tom@799: -- Name: messung; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE messung ( tom@741: geplant boolean DEFAULT false NOT NULL, tom@741: tree_modified timestamp without time zone DEFAULT now() tom@741: ) tom@741: INHERITS (bund.messung); tom@741: tom@741: tom@741: -- tom@799: -- Name: messung_translation; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE messung_translation ( tom@741: id integer NOT NULL, tom@741: messungs_id integer NOT NULL, tom@741: messungs_id_alt integer DEFAULT nextval('bund.messung_messung_id_alt_seq'::regclass) NOT NULL tom@741: ); tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_translation_id_seq; Type: SEQUENCE; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE messung_translation_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_translation_id_seq; Type: SEQUENCE OWNED BY; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER SEQUENCE messung_translation_id_seq OWNED BY messung_translation.id; tom@741: tom@741: tom@741: -- tom@799: -- Name: messwert; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE messwert ( tom@741: tree_modified timestamp without time zone DEFAULT now() tom@741: ) tom@741: INHERITS (bund.messwert); tom@741: tom@741: tom@741: -- raimund@808: -- Name: ortszuordnung; Type: TABLE; Schema: land; Owner: -; Tablespace: raimund@808: -- raimund@808: raimund@808: CREATE TABLE ortszuordnung ( tom@741: tree_modified timestamp without time zone DEFAULT now() tom@741: ) raimund@808: INHERITS (bund.ortszuordnung); tom@741: tom@741: tom@741: -- tom@799: -- Name: probe; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE probe ( tom@741: erzeuger_id integer, tom@741: probe_nehmer_id integer, tom@741: mp_kat character(1), tom@741: mpl_id character varying(3), tom@741: mpr_id integer, tom@741: solldatum_beginn timestamp without time zone, tom@741: solldatum_ende timestamp without time zone, tom@741: tree_modified timestamp without time zone DEFAULT now() tom@741: ) tom@741: INHERITS (bund.probe); tom@741: tom@899: ALTER TABLE ONLY probe tom@899: ADD CONSTRAINT probe_pkey PRIMARY KEY (id); tom@899: tom@899: ALTER TABLE ONLY probe tom@899: ADD CONSTRAINT probe_datenbasis_id_fkey tom@899: FOREIGN KEY (datenbasis_id) REFERENCES stammdaten.datenbasis(id); tom@899: tom@899: ALTER TABLE ONLY probe tom@899: ADD CONSTRAINT probe_mst_id_fkey tom@899: FOREIGN KEY (mst_id) REFERENCES stammdaten.mess_stelle(id); tom@899: tom@899: ALTER TABLE ONLY probe tom@899: ADD CONSTRAINT probe_labor_mst_id_fkey tom@899: FOREIGN KEY (labor_mst_id) REFERENCES stammdaten.mess_stelle(id); tom@899: tom@899: ALTER TABLE ONLY probe tom@899: ADD CONSTRAINT probe_netzbetreiber_id_fkey tom@899: FOREIGN KEY (netzbetreiber_id) REFERENCES stammdaten.netz_betreiber(id); tom@899: tom@899: ALTER TABLE ONLY probe tom@899: ADD CONSTRAINT probe_probenart_id_fkey tom@899: FOREIGN KEY (probenart_id) REFERENCES stammdaten.probenart(id); tom@899: tom@899: ALTER TABLE ONLY probe tom@899: ADD CONSTRAINT probe_umw_id_fkey tom@899: FOREIGN KEY (umw_id) REFERENCES stammdaten.umwelt(id); tom@899: tom@741: tom@741: -- tom@799: -- Name: probe_translation; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE probe_translation ( tom@741: id integer NOT NULL, tom@741: probe_id integer NOT NULL, tom@741: probe_id_alt character varying(20) DEFAULT (('sss'::text || lpad(((nextval('bund.probe_probe_id_seq'::regclass))::character varying)::text, 12, '0'::text)) || 'Y'::text) NOT NULL tom@741: ); tom@741: tom@741: tom@741: -- tom@741: -- Name: probe_translation_id_seq; Type: SEQUENCE; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE SEQUENCE probe_translation_id_seq tom@741: START WITH 1 tom@741: INCREMENT BY 1 tom@741: NO MINVALUE tom@741: NO MAXVALUE tom@741: CACHE 1; tom@741: tom@741: tom@741: -- tom@741: -- Name: probe_translation_id_seq; Type: SEQUENCE OWNED BY; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER SEQUENCE probe_translation_id_seq OWNED BY probe_translation.id; tom@741: tom@741: tom@741: -- tom@799: -- Name: status_protokoll; Type: TABLE; Schema: land; Owner: -; Tablespace: raimund@751: -- raimund@751: raimund@751: CREATE TABLE status_protokoll ( tom@741: ) raimund@751: INHERITS (bund.status_protokoll); tom@741: tom@741: tom@741: -- tom@799: -- Name: zusatz_wert; Type: TABLE; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE TABLE zusatz_wert ( tom@741: tree_modified timestamp without time zone DEFAULT now() tom@741: ) tom@741: INHERITS (bund.zusatz_wert); tom@741: tom@741: tom@741: SET search_path = bund, pg_catalog; tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_m ALTER COLUMN id SET DEFAULT nextval('kommentar_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: datum; Type: DEFAULT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_m ALTER COLUMN datum SET DEFAULT now(); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_p ALTER COLUMN id SET DEFAULT nextval('kommentar_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: datum; Type: DEFAULT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_p ALTER COLUMN datum SET DEFAULT now(); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY list ALTER COLUMN id SET DEFAULT nextval('list_id_seq'::regclass); tom@741: tom@741: raimund@751: -- raimund@751: -- Name: id; Type: DEFAULT; Schema: bund; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll ALTER COLUMN id SET DEFAULT nextval('kommentar_id_seq'::regclass); raimund@751: raimund@751: raimund@751: -- raimund@751: -- Name: datum; Type: DEFAULT; Schema: bund; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll ALTER COLUMN datum SET DEFAULT now(); raimund@751: raimund@751: tom@741: SET search_path = land, pg_catalog; tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_m ALTER COLUMN id SET DEFAULT nextval('bund.kommentar_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: datum; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_m ALTER COLUMN datum SET DEFAULT now(); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_p ALTER COLUMN id SET DEFAULT nextval('bund.kommentar_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: datum; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_p ALTER COLUMN datum SET DEFAULT now(); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messprogramm_mmt ALTER COLUMN id SET DEFAULT nextval('messprogramm_mmt_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung ALTER COLUMN id SET DEFAULT nextval('bund.messung_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: fertig; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung ALTER COLUMN fertig SET DEFAULT false; tom@741: tom@741: tom@741: -- tom@741: -- Name: letzte_aenderung; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung ALTER COLUMN letzte_aenderung SET DEFAULT now(); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung_translation ALTER COLUMN id SET DEFAULT nextval('messung_translation_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert ALTER COLUMN id SET DEFAULT nextval('bund.messwert_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: grenzwertueberschreitung; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert ALTER COLUMN grenzwertueberschreitung SET DEFAULT false; tom@741: tom@741: tom@741: -- tom@741: -- Name: letzte_aenderung; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert ALTER COLUMN letzte_aenderung SET DEFAULT now(); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: raimund@808: ALTER TABLE ONLY ortszuordnung ALTER COLUMN id SET DEFAULT nextval('bund.ort_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: letzte_aenderung; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: raimund@808: ALTER TABLE ONLY ortszuordnung ALTER COLUMN letzte_aenderung SET DEFAULT now(); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY probe_translation ALTER COLUMN id SET DEFAULT nextval('probe_translation_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: raimund@751: ALTER TABLE ONLY status_protokoll ALTER COLUMN id SET DEFAULT nextval('bund.kommentar_id_seq'::regclass); raimund@751: raimund@751: raimund@751: -- raimund@751: -- Name: datum; Type: DEFAULT; Schema: land; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll ALTER COLUMN datum SET DEFAULT now(); raimund@751: raimund@751: raimund@751: -- raimund@751: -- Name: tree_modified; Type: DEFAULT; Schema: land; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll ALTER COLUMN tree_modified SET DEFAULT now(); tom@741: tom@741: tom@741: -- tom@741: -- Name: id; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert ALTER COLUMN id SET DEFAULT nextval('bund.zusatz_wert_id_seq'::regclass); tom@741: tom@741: tom@741: -- tom@741: -- Name: letzte_aenderung; Type: DEFAULT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert ALTER COLUMN letzte_aenderung SET DEFAULT now(); tom@741: tom@741: tom@741: SET search_path = bund, pg_catalog; tom@741: tom@741: -- tom@799: -- Name: kommentar_pkey; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar tom@741: ADD CONSTRAINT kommentar_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: list_pkey; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY list tom@741: ADD CONSTRAINT list_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messung_pkey; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung tom@741: ADD CONSTRAINT messung_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messwert_messungs_id_messgroesse_id_key; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_messungs_id_messgroesse_id_key UNIQUE (messungs_id, messgroesse_id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messwert_pkey; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- raimund@808: -- Name: ortszuordnung_pkey; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: raimund@808: -- raimund@808: raimund@808: ALTER TABLE ONLY ortszuordnung raimund@808: ADD CONSTRAINT ortszuordnung_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: status_protokoll_pkey; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll raimund@751: ADD CONSTRAINT status_protokoll_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: zusatz_wert_pkey; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert tom@741: ADD CONSTRAINT zusatz_wert_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: zusatz_wert_probe_id_pzs_id_key; Type: CONSTRAINT; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert tom@741: ADD CONSTRAINT zusatz_wert_probe_id_pzs_id_key UNIQUE (probe_id, pzs_id); tom@741: tom@741: tom@741: SET search_path = land, pg_catalog; tom@741: tom@741: -- tom@799: -- Name: kommentar_m_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_m tom@741: ADD CONSTRAINT kommentar_m_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: kommentar_p_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_p tom@741: ADD CONSTRAINT kommentar_p_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messprogramm_mmt_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messprogramm_mmt tom@741: ADD CONSTRAINT messprogramm_mmt_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messung_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung tom@741: ADD CONSTRAINT messung_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messung_translation_messungs_id_key; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung_translation tom@741: ADD CONSTRAINT messung_translation_messungs_id_key UNIQUE (messungs_id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messung_translation_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung_translation tom@741: ADD CONSTRAINT messung_translation_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messwert_messungs_id_messgroesse_id_key; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_messungs_id_messgroesse_id_key UNIQUE (messungs_id, messgroesse_id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messwert_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- raimund@808: -- Name: ortszuordnung_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: raimund@808: -- raimund@808: raimund@808: ALTER TABLE ONLY ortszuordnung raimund@808: ADD CONSTRAINT ortszuordnung_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: probe_translation_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY probe_translation tom@741: ADD CONSTRAINT probe_translation_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: probe_translation_probe_id_key; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY probe_translation tom@741: ADD CONSTRAINT probe_translation_probe_id_key UNIQUE (probe_id); tom@741: tom@741: tom@741: -- tom@799: -- Name: status_protokoll_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll raimund@751: ADD CONSTRAINT status_protokoll_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: zusatz_wert_pkey; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert tom@741: ADD CONSTRAINT zusatz_wert_pkey PRIMARY KEY (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: zusatz_wert_probe_id_pzs_id_key; Type: CONSTRAINT; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert tom@741: ADD CONSTRAINT zusatz_wert_probe_id_pzs_id_key UNIQUE (probe_id, pzs_id); tom@741: tom@741: tom@741: SET search_path = bund, pg_catalog; tom@741: tom@741: -- tom@799: -- Name: p_list_zuord1; Type: INDEX; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE INDEX p_list_zuord1 ON list_zuordnung USING btree (list_id); tom@741: tom@741: tom@741: -- tom@799: -- Name: p_list_zuord2; Type: INDEX; Schema: bund; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE INDEX p_list_zuord2 ON list_zuordnung USING hash (list_id); tom@741: tom@741: tom@741: SET search_path = land, pg_catalog; tom@741: tom@741: -- tom@799: -- Name: messung_probe_id_idx; Type: INDEX; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE INDEX messung_probe_id_idx ON messung USING btree (probe_id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messung_translation_messungs_id_idx; Type: INDEX; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE INDEX messung_translation_messungs_id_idx ON messung_translation USING btree (messungs_id); tom@741: tom@741: tom@741: -- tom@799: -- Name: messwert_messungs_id_idx; Type: INDEX; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE INDEX messwert_messungs_id_idx ON messwert USING btree (messungs_id); tom@741: tom@741: tom@741: -- tom@799: -- Name: probe_id_idx; Type: INDEX; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE INDEX probe_id_idx ON probe USING btree (id); tom@741: tom@741: tom@741: -- tom@799: -- Name: probe_translation_probe_id_idx; Type: INDEX; Schema: land; Owner: -; Tablespace: tom@741: -- tom@741: tom@741: CREATE INDEX probe_translation_probe_id_idx ON probe_translation USING btree (probe_id); tom@741: tom@741: raimund@751: SET search_path = bund, pg_catalog; raimund@751: raimund@751: -- raimund@751: -- Name: tree_timestamp_status; Type: TRIGGER; Schema: bund; Owner: - raimund@751: -- raimund@751: raimund@751: CREATE TRIGGER tree_timestamp_status BEFORE UPDATE ON status_protokoll FOR EACH ROW EXECUTE PROCEDURE update_time_status(); raimund@751: raimund@751: tom@741: SET search_path = land, pg_catalog; tom@741: tom@741: -- tom@741: -- Name: tree_timestamp_messung; Type: TRIGGER; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE TRIGGER tree_timestamp_messung BEFORE UPDATE ON messung FOR EACH ROW EXECUTE PROCEDURE update_time_messung(); tom@741: tom@741: tom@741: -- tom@741: -- Name: tree_timestamp_messwert; Type: TRIGGER; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE TRIGGER tree_timestamp_messwert BEFORE UPDATE ON messwert FOR EACH ROW EXECUTE PROCEDURE update_time_messwert(); tom@741: tom@741: tom@741: -- tom@741: -- Name: tree_timestamp_ort; Type: TRIGGER; Schema: land; Owner: - tom@741: -- tom@741: raimund@808: CREATE TRIGGER tree_timestamp_ort BEFORE UPDATE ON ortszuordnung FOR EACH ROW EXECUTE PROCEDURE update_time_ort(); tom@741: tom@741: tom@741: -- tom@741: -- Name: tree_timestamp_probe; Type: TRIGGER; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE TRIGGER tree_timestamp_probe BEFORE UPDATE ON probe FOR EACH ROW EXECUTE PROCEDURE update_time_probe(); tom@741: tom@741: tom@741: -- tom@741: -- Name: tree_timestamp_zusatzwert; Type: TRIGGER; Schema: land; Owner: - tom@741: -- tom@741: tom@741: CREATE TRIGGER tree_timestamp_zusatzwert BEFORE UPDATE ON zusatz_wert FOR EACH ROW EXECUTE PROCEDURE update_time_zusatzwert(); tom@741: tom@741: tom@741: SET search_path = bund, pg_catalog; tom@741: tom@741: -- tom@741: -- Name: kommentar_m_messungs_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_m tom@741: ADD CONSTRAINT kommentar_m_messungs_id_fkey FOREIGN KEY (messungs_id) REFERENCES messung(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: kommentar_p_probe_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_p tom@741: ADD CONSTRAINT kommentar_p_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_mmt_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung tom@741: ADD CONSTRAINT messung_mmt_id_fkey FOREIGN KEY (mmt_id) REFERENCES stammdaten.mess_methode(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_probe_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung tom@741: ADD CONSTRAINT messung_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id); tom@741: tom@741: tom@741: -- raimund@751: -- Name: messung_status_protokoll_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY messung raimund@751: ADD CONSTRAINT messung_status_protokoll_id_fkey FOREIGN KEY (status) REFERENCES status_protokoll(id); raimund@751: raimund@751: raimund@751: -- tom@741: -- Name: messwert_meh_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_meh_id_fkey FOREIGN KEY (meh_id) REFERENCES stammdaten.mess_einheit(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: messwert_messgroesse_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_messgroesse_id_fkey FOREIGN KEY (messgroesse_id) REFERENCES stammdaten.messgroesse(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: messwert_messungs_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_messungs_id_fkey FOREIGN KEY (messungs_id) REFERENCES messung(id); tom@741: tom@741: tom@741: -- raimund@808: -- Name: ortszuordnung_ort_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - raimund@808: -- raimund@808: raimund@808: ALTER TABLE ONLY ortszuordnung raimund@808: ADD CONSTRAINT ortszuordnung_ort_id_fkey FOREIGN KEY (ort_id) REFERENCES stammdaten.ort(id); raimund@808: raimund@808: raimund@808: -- raimund@808: -- Name: ortszuordnung_ortszuordnung_typ_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - raimund@808: -- raimund@808: raimund@808: ALTER TABLE ONLY ortszuordnung raimund@808: ADD CONSTRAINT ortszuordnung_ortszuordnung_typ_fkey FOREIGN KEY (ortszuordnung_typ) REFERENCES stammdaten.ortszuordnung_typ(id); raimund@808: raimund@808: raimund@808: -- raimund@808: -- Name: ortszuordnung_probe_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - raimund@808: -- raimund@808: raimund@808: ALTER TABLE ONLY ortszuordnung raimund@808: ADD CONSTRAINT ortszuordnung_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id); tom@741: tom@741: tom@741: -- raimund@751: -- Name: status_protokoll_status_stufe_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll raimund@751: ADD CONSTRAINT status_protokoll_status_stufe_fkey FOREIGN KEY (status_stufe) REFERENCES stammdaten.status_stufe(id); raimund@751: raimund@751: raimund@751: -- raimund@751: -- Name: status_protokoll_status_wert_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll raimund@751: ADD CONSTRAINT status_protokoll_status_wert_fkey FOREIGN KEY (status_wert) REFERENCES stammdaten.status_wert(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: zusatz_wert_probe_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert tom@741: ADD CONSTRAINT zusatz_wert_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: zusatz_wert_pzs_id_fkey; Type: FK CONSTRAINT; Schema: bund; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert tom@741: ADD CONSTRAINT zusatz_wert_pzs_id_fkey FOREIGN KEY (pzs_id) REFERENCES stammdaten.proben_zusatz(id); tom@741: tom@741: tom@741: SET search_path = land, pg_catalog; tom@741: tom@741: -- tom@741: -- Name: kommentar_m_messungs_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_m tom@741: ADD CONSTRAINT kommentar_m_messungs_id_fkey FOREIGN KEY (messungs_id) REFERENCES messung(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- tom@741: -- Name: kommentar_p_probe_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY kommentar_p tom@741: ADD CONSTRAINT kommentar_p_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- tom@741: -- Name: messprogramm_mmt_messprogramm_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messprogramm_mmt tom@741: ADD CONSTRAINT messprogramm_mmt_messprogramm_id_fkey FOREIGN KEY (messprogramm_id) REFERENCES messprogramm(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- tom@741: -- Name: messprogramm_mmt_mmt_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messprogramm_mmt tom@741: ADD CONSTRAINT messprogramm_mmt_mmt_id_fkey FOREIGN KEY (mmt_id) REFERENCES stammdaten.mess_methode(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_mmt_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung tom@741: ADD CONSTRAINT messung_mmt_id_fkey FOREIGN KEY (mmt_id) REFERENCES stammdaten.mess_methode(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- tom@741: -- Name: messung_probe_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung tom@741: ADD CONSTRAINT messung_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- raimund@751: -- Name: messung_status_protokoll_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY messung raimund@751: ADD CONSTRAINT messung_status_protokoll_id_fkey FOREIGN KEY (status) REFERENCES status_protokoll(id); raimund@751: raimund@751: raimund@751: -- tom@741: -- Name: messung_translation_messungs_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messung_translation tom@741: ADD CONSTRAINT messung_translation_messungs_id_fkey FOREIGN KEY (messungs_id) REFERENCES messung(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- tom@741: -- Name: messwert_meh_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_meh_id_fkey FOREIGN KEY (meh_id) REFERENCES stammdaten.mess_einheit(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: messwert_messgroesse_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_messgroesse_id_fkey FOREIGN KEY (messgroesse_id) REFERENCES stammdaten.messgroesse(id); tom@741: tom@741: tom@741: -- tom@741: -- Name: messwert_messungs_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY messwert tom@741: ADD CONSTRAINT messwert_messungs_id_fkey FOREIGN KEY (messungs_id) REFERENCES messung(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- raimund@808: -- Name: ortszuordnung_ort_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - raimund@808: -- raimund@808: raimund@808: ALTER TABLE ONLY ortszuordnung raimund@808: ADD CONSTRAINT ortszuordnung_ort_id_fkey FOREIGN KEY (ort_id) REFERENCES stammdaten.ort(id); raimund@808: raimund@808: raimund@808: -- raimund@808: -- Name: ortszuordnung_ortszuordnung_typ_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - raimund@808: -- raimund@808: raimund@808: ALTER TABLE ONLY ortszuordnung raimund@808: ADD CONSTRAINT ortszuordnung_ortszuordnung_typ_fkey FOREIGN KEY (ortszuordnung_typ) REFERENCES stammdaten.ortszuordnung_typ(id); raimund@808: raimund@808: raimund@808: -- raimund@808: -- Name: ortszuordnung_probe_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - raimund@808: -- raimund@808: raimund@808: ALTER TABLE ONLY ortszuordnung raimund@808: ADD CONSTRAINT ortszuordnung_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- tom@741: -- Name: probe_translation_probe_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY probe_translation tom@741: ADD CONSTRAINT probe_translation_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- raimund@751: -- Name: status_protokoll_messungs_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - raimund@751: -- raimund@751: raimund@751: ALTER TABLE ONLY status_protokoll raimund@751: ADD CONSTRAINT status_protokoll_messungs_id_fkey FOREIGN KEY (messungs_id) REFERENCES messung(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- tom@741: -- Name: zusatz_wert_probe_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert tom@741: ADD CONSTRAINT zusatz_wert_probe_id_fkey FOREIGN KEY (probe_id) REFERENCES probe(id) ON DELETE CASCADE; tom@741: tom@741: tom@741: -- tom@741: -- Name: zusatz_wert_pzs_id_fkey; Type: FK CONSTRAINT; Schema: land; Owner: - tom@741: -- tom@741: tom@741: ALTER TABLE ONLY zusatz_wert tom@741: ADD CONSTRAINT zusatz_wert_pzs_id_fkey FOREIGN KEY (pzs_id) REFERENCES stammdaten.proben_zusatz(id); tom@741: tom@741: tom@797: COMMIT;