--
-- PostgreSQL database dump Mapbender 2.4.2
--



CREATE TABLE gui (
    gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    gui_name character varying(50) DEFAULT ''::character varying NOT NULL,
    gui_description character varying(255) DEFAULT ''::character varying NOT NULL,
    gui_public integer DEFAULT 1 NOT NULL
);


--
-- TOC entry 1239 (class 1259 OID 47913127)
-- Dependencies: 1607 1608 1609 4
-- Name: gui_element; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE gui_element (
    fkey_gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    e_id character varying(50) DEFAULT ''::character varying NOT NULL,
    e_pos integer,
    e_public integer,
    e_comment text,
    e_element character varying(255) DEFAULT ''::character varying NOT NULL,
    e_src character varying(255),
    e_attributes text,
    e_left integer,
    e_top integer,
    e_width integer,
    e_height integer,
    e_z_index integer,
    e_more_styles text,
    e_content text,
    e_closetag character varying(255),
    e_js_file character varying(50),
    e_mb_mod character varying(50),
    e_target character varying(50),
    e_requires character varying(50),
    e_url character varying(255)
);


--
-- TOC entry 1240 (class 1259 OID 47913135)
-- Dependencies: 1610 1611 1612 4
-- Name: gui_element_vars; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE gui_element_vars (
    fkey_gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    fkey_e_id character varying(50) DEFAULT ''::character varying NOT NULL,
    var_name character varying(50) DEFAULT ''::character varying NOT NULL,
    var_value text,
    context text,
    var_type character varying(50)
);


--
-- TOC entry 1241 (class 1259 OID 47913143)
-- Dependencies: 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 4
-- Name: gui_layer; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE gui_layer (
    fkey_gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    fkey_layer_id integer DEFAULT 0 NOT NULL,
    gui_layer_wms_id integer DEFAULT 0,
    gui_layer_status integer DEFAULT 1,
    gui_layer_selectable integer DEFAULT 1,
    gui_layer_visible integer DEFAULT 1,
    gui_layer_queryable integer DEFAULT 0,
    gui_layer_querylayer integer DEFAULT 0,
    gui_layer_minscale integer DEFAULT 0,
    gui_layer_maxscale integer DEFAULT 0,
    gui_layer_priority integer,
    gui_layer_style character varying(50),
    gui_layer_wfs_featuretype character varying(50)
);


--
-- TOC entry 1242 (class 1259 OID 47913155)
-- Dependencies: 1623 1624 1625 4
-- Name: gui_mb_group; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE gui_mb_group (
    fkey_gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    fkey_mb_group_id integer DEFAULT 0 NOT NULL,
    mb_group_type character varying(50) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 1243 (class 1259 OID 47913160)
-- Dependencies: 1626 1627 4
-- Name: gui_mb_user; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE gui_mb_user (
    fkey_gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    fkey_mb_user_id integer DEFAULT 0 NOT NULL,
    mb_user_type character varying(50)
);


--
-- TOC entry 1245 (class 1259 OID 47913166)
-- Dependencies: 1628 1630 1631 4
-- Name: gui_treegde; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE gui_treegde (
    fkey_gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    fkey_layer_id text,
    id serial NOT NULL,
    lft integer DEFAULT 0 NOT NULL,
    rgt integer DEFAULT 0 NOT NULL,
    my_layer_title character varying(50),
    layer text,
    wms_id text
);


--
-- TOC entry 1246 (class 1259 OID 47913175)
-- Dependencies: 1632 1633 4
-- Name: gui_wfs; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE gui_wfs (
    fkey_gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    fkey_wfs_id integer DEFAULT 0 NOT NULL
);


--
-- TOC entry 1247 (class 1259 OID 47913179)
-- Dependencies: 1634 1635 1636 1637 1638 1639 1640 1641 4
-- Name: gui_wms; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE gui_wms (
    fkey_gui_id character varying(50) DEFAULT ''::character varying NOT NULL,
    fkey_wms_id integer DEFAULT 0 NOT NULL,
    gui_wms_position integer DEFAULT 0 NOT NULL,
    gui_wms_mapformat character varying(50) DEFAULT ''::character varying NOT NULL,
    gui_wms_featureinfoformat character varying(50) DEFAULT ''::character varying NOT NULL,
    gui_wms_exceptionformat character varying(50) DEFAULT ''::character varying NOT NULL,
    gui_wms_epsg character varying(50) DEFAULT ''::character varying NOT NULL,
    gui_wms_visible integer DEFAULT 1 NOT NULL
);


--
-- TOC entry 1277 (class 1259 OID 48558625)
-- Dependencies: 4
-- Name: keyword; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE keyword (
    keyword_id serial NOT NULL,
    keyword character varying(255) NOT NULL
);


--
-- TOC entry 1249 (class 1259 OID 47913191)
-- Dependencies: 1643 1644 1645 1646 1647 1648 1649 1650 4
-- Name: layer; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE layer (
    layer_id serial NOT NULL,
    fkey_wms_id integer DEFAULT 0 NOT NULL,
    layer_pos integer DEFAULT 0 NOT NULL,
    layer_parent character varying(50) DEFAULT ''::character varying NOT NULL,
    layer_name character varying(255) DEFAULT ''::character varying NOT NULL,
    layer_title character varying(255) DEFAULT ''::character varying NOT NULL,
    layer_queryable integer DEFAULT 0 NOT NULL,
    layer_minscale integer DEFAULT 0,
    layer_maxscale integer DEFAULT 0,
    layer_dataurl character varying(255),
    layer_metadataurl character varying(255),
    layer_abstract text
);


--
-- TOC entry 1250 (class 1259 OID 47913205)
-- Dependencies: 1651 1652 1653 1654 1655 1656 4
-- Name: layer_epsg; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE layer_epsg (
    fkey_layer_id integer DEFAULT 0 NOT NULL,
    epsg character varying(50) DEFAULT ''::character varying NOT NULL,
    minx double precision DEFAULT 0,
    miny double precision DEFAULT 0,
    maxx double precision DEFAULT 0,
    maxy double precision DEFAULT 0
);


--
-- TOC entry 1278 (class 1259 OID 48558633)
-- Dependencies: 4
-- Name: layer_keyword; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE layer_keyword (
    fkey_layer_id integer NOT NULL,
    fkey_keyword_id integer NOT NULL
);


--
-- TOC entry 1251 (class 1259 OID 47913213)
-- Dependencies: 1657 1658 1659 4
-- Name: layer_style; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE layer_style (
    fkey_layer_id integer DEFAULT 0 NOT NULL,
    name character varying(50) DEFAULT ''::character varying NOT NULL,
    title character varying(100) DEFAULT ''::character varying NOT NULL,
    legendurl character varying(255),
    legendurlformat character varying(50)
);


--
-- TOC entry 1253 (class 1259 OID 47913220)
-- Dependencies: 1661 1662 4
-- Name: mb_group; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE mb_group (
    mb_group_id serial NOT NULL,
    mb_group_name character varying(50) DEFAULT ''::character varying NOT NULL,
    mb_group_owner integer,
    mb_group_description character varying(255) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 1255 (class 1259 OID 47913227)
-- Dependencies: 1664 4
-- Name: mb_log; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE mb_log (
    id serial NOT NULL,
    time_client character varying(13) DEFAULT 0,
    time_server character varying(13),
    time_readable character varying(50),
    mb_session character varying(50),
    gui character varying(50),
    module character varying(50),
    ip character varying(20),
    username character varying(50),
    userid character varying(50),
    request text
);


--
-- TOC entry 1256 (class 1259 OID 47913234)
-- Dependencies: 1665 1666 1667 1668 1669 4
-- Name: mb_monitor; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE mb_monitor (
    upload_id character varying(255) DEFAULT ''::character varying NOT NULL,
    fkey_wms_id integer DEFAULT 0 NOT NULL,
    status integer NOT NULL,
    status_comment character varying(255) DEFAULT ''::character varying NOT NULL,
    timestamp_begin integer NOT NULL,
    timestamp_end integer NOT NULL,
    upload_url character varying(255) DEFAULT ''::character varying NOT NULL,
    updated character(1) DEFAULT ''::bpchar NOT NULL
);


--
-- TOC entry 1258 (class 1259 OID 47913246)
-- Dependencies: 1671 1672 1673 1674 1675 4
-- Name: mb_user; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE mb_user (
    mb_user_id serial NOT NULL,
    mb_user_name character varying(50) DEFAULT ''::character varying NOT NULL,
    mb_user_password character varying(50) DEFAULT ''::character varying NOT NULL,
    mb_user_owner integer DEFAULT 0 NOT NULL,
    mb_user_description character varying(255),
    mb_user_login_count integer DEFAULT 0 NOT NULL,
    mb_user_email character varying(50),
    mb_user_phone character varying(50),
    mb_user_department character varying(255),
    mb_user_resolution integer DEFAULT 72 NOT NULL,
    mb_user_organisation_name character varying(255),
    mb_user_position_name character varying(255),
    mb_user_phone1 character varying(255),
    mb_user_facsimile character varying(255),
    mb_user_delivery_point character varying(255),
    mb_user_city character varying(255),
    mb_user_postal_code integer,
    mb_user_country character varying(255),
    mb_user_online_resource character varying(255)
);


--
-- TOC entry 1259 (class 1259 OID 47913257)
-- Dependencies: 1676 1677 4
-- Name: mb_user_mb_group; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE mb_user_mb_group (
    fkey_mb_user_id integer DEFAULT 0 NOT NULL,
    fkey_mb_group_id integer DEFAULT 0 NOT NULL
);


--
-- TOC entry 1260 (class 1259 OID 47913261)
-- Dependencies: 1678 1679 4
-- Name: mb_user_wmc; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE mb_user_wmc (
    wmc_id character varying(20) DEFAULT ''::character varying NOT NULL,
    fkey_user_id integer DEFAULT 0 NOT NULL,
    wmc text NOT NULL,
    wmc_title character varying(50),
    wmc_timestamp integer
);


--
-- TOC entry 1280 (class 1259 OID 48558647)
-- Dependencies: 4
-- Name: md_topic_category; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE md_topic_category (
    md_topic_category_id serial NOT NULL,
    md_topic_category_code_en character varying(255),
    md_topic_category_code_de character varying(255)
);


--
-- TOC entry 1262 (class 1259 OID 47913270)
-- Dependencies: 4
-- Name: wfs; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wfs (
    wfs_id serial NOT NULL,
    wfs_version character varying(50),
    wfs_name character varying(255),
    wfs_title character varying(255),
    wfs_abstract text,
    wfs_getcapabilities character varying(255),
    wfs_describefeaturetype character varying(255),
    wfs_getfeature character varying(255),
    wfs_transaction character varying(255),
    wfs_owsproxy character varying(50)
);


--
-- TOC entry 1264 (class 1259 OID 47913278)
-- Dependencies: 1682 1683 1684 1685 4
-- Name: wfs_conf; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wfs_conf (
    wfs_conf_id serial NOT NULL,
    wfs_conf_abstract text,
    fkey_wfs_id integer DEFAULT 0 NOT NULL,
    fkey_featuretype_id integer DEFAULT 0 NOT NULL,
    g_label character varying(50),
    g_label_id character varying(50),
    g_button character varying(50),
    g_button_id character varying(50),
    g_style text,
    g_buffer double precision DEFAULT 0,
    g_res_style text,
    g_use_wzgraphics integer DEFAULT 0
);


--
-- TOC entry 1266 (class 1259 OID 47913290)
-- Dependencies: 1687 1688 1689 1690 4
-- Name: wfs_conf_element; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wfs_conf_element (
    wfs_conf_element_id serial NOT NULL,
    fkey_wfs_conf_id integer DEFAULT 0 NOT NULL,
    f_id integer DEFAULT 0 NOT NULL,
    f_geom integer DEFAULT 0,
    f_gid integer DEFAULT 0 NOT NULL,
    f_search integer,
    f_pos integer,
    f_style_id character varying(255),
    f_toupper integer,
    f_label character varying(255),
    f_label_id character varying(50),
    f_show integer,
    f_respos integer,
    f_form_element_html TEXT NULL,
    f_edit int4,
    f_mandatory int4
);


--
-- TOC entry 1268 (class 1259 OID 47913302)
-- Dependencies: 1691 4
-- Name: wfs_element; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wfs_element (
    fkey_featuretype_id integer DEFAULT 0 NOT NULL,
    element_id serial NOT NULL,
    element_name character varying(50),
    element_type character varying(50)
);


--
-- TOC entry 1270 (class 1259 OID 47913308)
-- Dependencies: 1693 1695 4
-- Name: wfs_featuretype; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wfs_featuretype (
    fkey_wfs_id integer DEFAULT 0 NOT NULL,
    featuretype_id serial NOT NULL,
    featuretype_name character varying(50) DEFAULT ''::character varying NOT NULL,
    featuretype_title character varying(50),
    featuretype_srs character varying(50)
);


--
-- TOC entry 1271 (class 1259 OID 47913313)
-- Dependencies: 1696 1697 1698 1699 4
-- Name: wfs_featuretype_namespace; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wfs_featuretype_namespace (
    fkey_wfs_id integer DEFAULT 0 NOT NULL,
    fkey_featuretype_id integer DEFAULT 0 NOT NULL,
    namespace character varying(255) DEFAULT ''::character varying NOT NULL,
    namespace_location character varying(255) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 1273 (class 1259 OID 47913324)
-- Dependencies: 1701 1702 1703 1704 1705 4
-- Name: wms; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wms (
    wms_id serial NOT NULL,
    wms_version character varying(50) DEFAULT ''::character varying NOT NULL,
    wms_title character varying(255) DEFAULT ''::character varying NOT NULL,
    wms_abstract text,
    wms_getcapabilities character varying(255) DEFAULT ''::character varying NOT NULL,
    wms_getmap character varying(255) DEFAULT ''::character varying NOT NULL,
    wms_getfeatureinfo character varying(255) DEFAULT ''::character varying NOT NULL,
    wms_getlegendurl character varying(255),
    wms_filter character varying(255),
    wms_getcapabilities_doc text,
    wms_owsproxy character varying(50),
    wms_upload_url character varying(255),
    fees character varying(255),
    accessconstraints text,
    contactperson character varying(255),
    contactposition character varying(255),
    contactorganization character varying(255),
    address character varying(255),
    city character varying(255),
    stateorprovince character varying(255),
    postcode character varying(255),
    country character varying(255),
    contactvoicetelephone character varying(255),
    contactfacsimiletelephone character varying(255),
    contactelectronicmailaddress character varying(255),
    wms_mb_getcapabilies_doc text,
    wms_owner integer,
    wms_timestamp integer
);


--
-- TOC entry 1274 (class 1259 OID 47913335)
-- Dependencies: 1706 1707 1708 4
-- Name: wms_format; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wms_format (
    fkey_wms_id integer DEFAULT 0 NOT NULL,
    data_type character varying(50) DEFAULT ''::character varying NOT NULL,
    data_format character varying(50) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 1281 (class 1259 OID 48558674)
-- Dependencies: 4
-- Name: wms_md_topic_category; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wms_md_topic_category (
    fkey_wms_id integer NOT NULL,
    fkey_md_topic_category_id integer NOT NULL
);


--
-- TOC entry 1275 (class 1259 OID 47913340)
-- Dependencies: 1709 1710 4
-- Name: wms_srs; Type: TABLE; Schema: public; Owner: admin; Tablespace: 
--

CREATE TABLE wms_srs (
    fkey_wms_id integer DEFAULT 0 NOT NULL,
    wms_srs character varying(50) DEFAULT ''::character varying NOT NULL
);


--
-- TOC entry 1745 (class 2606 OID 48558631)
-- Dependencies: 1277 1277
-- Name: keyword_keyword_key; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY keyword
    ADD CONSTRAINT keyword_keyword_key UNIQUE (keyword);


--
-- TOC entry 1749 (class 2606 OID 48558654)
-- Dependencies: 1280 1280
-- Name: md_topic_category_pkey; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY md_topic_category
    ADD CONSTRAINT md_topic_category_pkey PRIMARY KEY (md_topic_category_id);


--
-- TOC entry 1740 (class 2606 OID 47913345)
-- Dependencies: 1270 1270
-- Name: pk_featuretype_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY wfs_featuretype
    ADD CONSTRAINT pk_featuretype_id PRIMARY KEY (featuretype_id);


--
-- TOC entry 1716 (class 2606 OID 47913347)
-- Dependencies: 1239 1239 1239
-- Name: pk_fkey_gui_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY gui_element
    ADD CONSTRAINT pk_fkey_gui_id PRIMARY KEY (fkey_gui_id, e_id);


--
-- TOC entry 1718 (class 2606 OID 47913349)
-- Dependencies: 1240 1240 1240 1240
-- Name: pk_fkey_gui_id_fkey_e_id_var_name; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY gui_element_vars
    ADD CONSTRAINT pk_fkey_gui_id_fkey_e_id_var_name PRIMARY KEY (fkey_gui_id, fkey_e_id, var_name);


--
-- TOC entry 1720 (class 2606 OID 47913351)
-- Dependencies: 1242 1242 1242
-- Name: pk_fkey_mb_group_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY gui_mb_group
    ADD CONSTRAINT pk_fkey_mb_group_id PRIMARY KEY (fkey_mb_group_id, fkey_gui_id);


--
-- TOC entry 1722 (class 2606 OID 47913353)
-- Dependencies: 1243 1243 1243
-- Name: pk_fkey_mb_user_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY gui_mb_user
    ADD CONSTRAINT pk_fkey_mb_user_id PRIMARY KEY (fkey_gui_id, fkey_mb_user_id);


--
-- TOC entry 1732 (class 2606 OID 47913355)
-- Dependencies: 1259 1259 1259
-- Name: pk_fkey_mb_user_mb_group_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY mb_user_mb_group
    ADD CONSTRAINT pk_fkey_mb_user_mb_group_id PRIMARY KEY (fkey_mb_user_id, fkey_mb_group_id);


--
-- TOC entry 1724 (class 2606 OID 47913357)
-- Dependencies: 1245 1245 1245 1245 1245
-- Name: pk_fkey_treegde_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY gui_treegde
    ADD CONSTRAINT pk_fkey_treegde_id PRIMARY KEY (fkey_gui_id, id, lft, rgt);


--
-- TOC entry 1728 (class 2606 OID 47913359)
-- Dependencies: 1253 1253
-- Name: pk_group_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY mb_group
    ADD CONSTRAINT pk_group_id PRIMARY KEY (mb_group_id);


--
-- TOC entry 1714 (class 2606 OID 47913361)
-- Dependencies: 1238 1238
-- Name: pk_gui_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY gui
    ADD CONSTRAINT pk_gui_id PRIMARY KEY (gui_id);


--
-- TOC entry 1747 (class 2606 OID 48558629)
-- Dependencies: 1277 1277
-- Name: pk_keyword_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY keyword
    ADD CONSTRAINT pk_keyword_id PRIMARY KEY (keyword_id);


--
-- TOC entry 1726 (class 2606 OID 47913363)
-- Dependencies: 1249 1249
-- Name: pk_layer_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY layer
    ADD CONSTRAINT pk_layer_id PRIMARY KEY (layer_id);


--
-- TOC entry 1730 (class 2606 OID 47913365)
-- Dependencies: 1258 1258
-- Name: pk_mb_user_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY mb_user
    ADD CONSTRAINT pk_mb_user_id PRIMARY KEY (mb_user_id);


--
-- TOC entry 1738 (class 2606 OID 47913367)
-- Dependencies: 1266 1266
-- Name: pk_wfs_conf_element_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY wfs_conf_element
    ADD CONSTRAINT pk_wfs_conf_element_id PRIMARY KEY (wfs_conf_element_id);


--
-- TOC entry 1736 (class 2606 OID 47913369)
-- Dependencies: 1264 1264
-- Name: pk_wfs_conf_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY wfs_conf
    ADD CONSTRAINT pk_wfs_conf_id PRIMARY KEY (wfs_conf_id);


--
-- TOC entry 1734 (class 2606 OID 47913371)
-- Dependencies: 1262 1262
-- Name: pk_wfs_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY wfs
    ADD CONSTRAINT pk_wfs_id PRIMARY KEY (wfs_id);


--
-- TOC entry 1742 (class 2606 OID 47913373)
-- Dependencies: 1273 1273
-- Name: pk_wms_id; Type: CONSTRAINT; Schema: public; Owner: admin; Tablespace: 
--

ALTER TABLE ONLY wms
    ADD CONSTRAINT pk_wms_id PRIMARY KEY (wms_id);


--
-- TOC entry 1743 (class 1259 OID 48558632)
-- Dependencies: 1277
-- Name: ind_keyword; Type: INDEX; Schema: public; Owner: admin; Tablespace: 
--

CREATE INDEX ind_keyword ON keyword USING btree (keyword);


--
-- TOC entry 1778 (class 2606 OID 48558635)
-- Dependencies: 1746 1277 1278
-- Name: fkey_keyword_id_fkey_layer_id; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY layer_keyword
    ADD CONSTRAINT fkey_keyword_id_fkey_layer_id FOREIGN KEY (fkey_keyword_id) REFERENCES keyword(keyword_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1779 (class 2606 OID 48558640)
-- Dependencies: 1725 1249 1278
-- Name: fkey_layer_id_fkey_keyword_id; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY layer_keyword
    ADD CONSTRAINT fkey_layer_id_fkey_keyword_id FOREIGN KEY (fkey_layer_id) REFERENCES layer(layer_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1767 (class 2606 OID 47913379)
-- Dependencies: 1729 1258 1259
-- Name: fkey_mb_user_mb_group_mb_use_id; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY mb_user_mb_group
    ADD CONSTRAINT fkey_mb_user_mb_group_mb_use_id FOREIGN KEY (fkey_mb_user_id) REFERENCES mb_user(mb_user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1766 (class 2606 OID 47913374)
-- Dependencies: 1741 1273 1256
-- Name: fkey_monitor_wms_id_wms_id; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY mb_monitor
    ADD CONSTRAINT fkey_monitor_wms_id_wms_id FOREIGN KEY (fkey_wms_id) REFERENCES wms(wms_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1750 (class 2606 OID 47913384)
-- Dependencies: 1713 1238 1239
-- Name: gui_element_ibfk1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_element
    ADD CONSTRAINT gui_element_ibfk1 FOREIGN KEY (fkey_gui_id) REFERENCES gui(gui_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1751 (class 2606 OID 47913389)
-- Dependencies: 1715 1239 1239 1240 1240
-- Name: gui_element_vars_ibfk1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_element_vars
    ADD CONSTRAINT gui_element_vars_ibfk1 FOREIGN KEY (fkey_gui_id, fkey_e_id) REFERENCES gui_element(fkey_gui_id, e_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1754 (class 2606 OID 47913394)
-- Dependencies: 1713 1238 1242
-- Name: gui_mb_group_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_mb_group
    ADD CONSTRAINT gui_mb_group_ibfk_1 FOREIGN KEY (fkey_gui_id) REFERENCES gui(gui_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1755 (class 2606 OID 47913399)
-- Dependencies: 1727 1253 1242
-- Name: gui_mb_group_ibfk_2; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_mb_group
    ADD CONSTRAINT gui_mb_group_ibfk_2 FOREIGN KEY (fkey_mb_group_id) REFERENCES mb_group(mb_group_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1756 (class 2606 OID 47913404)
-- Dependencies: 1713 1238 1243
-- Name: gui_mb_user_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_mb_user
    ADD CONSTRAINT gui_mb_user_ibfk_1 FOREIGN KEY (fkey_gui_id) REFERENCES gui(gui_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1757 (class 2606 OID 47913409)
-- Dependencies: 1729 1258 1243
-- Name: gui_mb_user_ibfk_2; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_mb_user
    ADD CONSTRAINT gui_mb_user_ibfk_2 FOREIGN KEY (fkey_mb_user_id) REFERENCES mb_user(mb_user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1758 (class 2606 OID 47913414)
-- Dependencies: 1713 1238 1245
-- Name: gui_treegde_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_treegde
    ADD CONSTRAINT gui_treegde_ibfk_1 FOREIGN KEY (fkey_gui_id) REFERENCES gui(gui_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1759 (class 2606 OID 47913419)
-- Dependencies: 1713 1238 1246
-- Name: gui_wfs_ibfk_3; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_wfs
    ADD CONSTRAINT gui_wfs_ibfk_3 FOREIGN KEY (fkey_gui_id) REFERENCES gui(gui_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1760 (class 2606 OID 47913424)
-- Dependencies: 1733 1262 1246
-- Name: gui_wfs_ibfk_4; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_wfs
    ADD CONSTRAINT gui_wfs_ibfk_4 FOREIGN KEY (fkey_wfs_id) REFERENCES wfs(wfs_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1761 (class 2606 OID 47913429)
-- Dependencies: 1713 1238 1247
-- Name: gui_wms_ibfk_3; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_wms
    ADD CONSTRAINT gui_wms_ibfk_3 FOREIGN KEY (fkey_gui_id) REFERENCES gui(gui_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1762 (class 2606 OID 47913434)
-- Dependencies: 1741 1273 1247
-- Name: gui_wms_ibfk_4; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_wms
    ADD CONSTRAINT gui_wms_ibfk_4 FOREIGN KEY (fkey_wms_id) REFERENCES wms(wms_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1764 (class 2606 OID 47913439)
-- Dependencies: 1725 1249 1250
-- Name: layer_epsg_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY layer_epsg
    ADD CONSTRAINT layer_epsg_ibfk_1 FOREIGN KEY (fkey_layer_id) REFERENCES layer(layer_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1763 (class 2606 OID 47913444)
-- Dependencies: 1741 1273 1249
-- Name: layer_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY layer
    ADD CONSTRAINT layer_ibfk_1 FOREIGN KEY (fkey_wms_id) REFERENCES wms(wms_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1765 (class 2606 OID 47913449)
-- Dependencies: 1725 1249 1251
-- Name: layer_style_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY layer_style
    ADD CONSTRAINT layer_style_ibfk_1 FOREIGN KEY (fkey_layer_id) REFERENCES layer(layer_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1768 (class 2606 OID 47913454)
-- Dependencies: 1727 1253 1259
-- Name: mb_user_mb_group_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY mb_user_mb_group
    ADD CONSTRAINT mb_user_mb_group_ibfk_1 FOREIGN KEY (fkey_mb_group_id) REFERENCES mb_group(mb_group_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1769 (class 2606 OID 47913509)
-- Dependencies: 1729 1258 1260
-- Name: mb_user_wmc_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY mb_user_wmc
    ADD CONSTRAINT mb_user_wmc_ibfk_1 FOREIGN KEY (fkey_user_id) REFERENCES mb_user(mb_user_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1752 (class 2606 OID 47913459)
-- Dependencies: 1713 1238 1241
-- Name: pk_gui_layer_ifbk3; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_layer
    ADD CONSTRAINT pk_gui_layer_ifbk3 FOREIGN KEY (fkey_gui_id) REFERENCES gui(gui_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1753 (class 2606 OID 47913464)
-- Dependencies: 1725 1249 1241
-- Name: pk_gui_layer_ifbk4; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY gui_layer
    ADD CONSTRAINT pk_gui_layer_ifbk4 FOREIGN KEY (fkey_layer_id) REFERENCES layer(layer_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1771 (class 2606 OID 47913469)
-- Dependencies: 1735 1264 1266
-- Name: wfs_conf_element_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wfs_conf_element
    ADD CONSTRAINT wfs_conf_element_ibfk_1 FOREIGN KEY (fkey_wfs_conf_id) REFERENCES wfs_conf(wfs_conf_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1770 (class 2606 OID 47913474)
-- Dependencies: 1733 1262 1264
-- Name: wfs_conf_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wfs_conf
    ADD CONSTRAINT wfs_conf_ibfk_1 FOREIGN KEY (fkey_wfs_id) REFERENCES wfs(wfs_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1772 (class 2606 OID 47913479)
-- Dependencies: 1739 1270 1268
-- Name: wfs_element_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wfs_element
    ADD CONSTRAINT wfs_element_ibfk_1 FOREIGN KEY (fkey_featuretype_id) REFERENCES wfs_featuretype(featuretype_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1773 (class 2606 OID 47913484)
-- Dependencies: 1733 1262 1270
-- Name: wfs_featuretype_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wfs_featuretype
    ADD CONSTRAINT wfs_featuretype_ibfk_1 FOREIGN KEY (fkey_wfs_id) REFERENCES wfs(wfs_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1774 (class 2606 OID 47913489)
-- Dependencies: 1739 1270 1271
-- Name: wfs_featuretype_namespace_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wfs_featuretype_namespace
    ADD CONSTRAINT wfs_featuretype_namespace_ibfk_1 FOREIGN KEY (fkey_featuretype_id) REFERENCES wfs_featuretype(featuretype_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1775 (class 2606 OID 47913494)
-- Dependencies: 1733 1262 1271
-- Name: wfs_featuretype_namespace_ibfk_2; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wfs_featuretype_namespace
    ADD CONSTRAINT wfs_featuretype_namespace_ibfk_2 FOREIGN KEY (fkey_wfs_id) REFERENCES wfs(wfs_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1776 (class 2606 OID 47913499)
-- Dependencies: 1741 1273 1274
-- Name: wms_format_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wms_format
    ADD CONSTRAINT wms_format_ibfk_1 FOREIGN KEY (fkey_wms_id) REFERENCES wms(wms_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1780 (class 2606 OID 48558676)
-- Dependencies: 1748 1280 1281
-- Name: wms_md_topic_category_fkey_md_topic_category_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wms_md_topic_category
    ADD CONSTRAINT wms_md_topic_category_fkey_md_topic_category_id_fkey FOREIGN KEY (fkey_md_topic_category_id) REFERENCES md_topic_category(md_topic_category_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1781 (class 2606 OID 48558681)
-- Dependencies: 1741 1273 1281
-- Name: wms_md_topic_category_fkey_wms_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wms_md_topic_category
    ADD CONSTRAINT wms_md_topic_category_fkey_wms_id_fkey FOREIGN KEY (fkey_wms_id) REFERENCES wms(wms_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1777 (class 2606 OID 47913504)
-- Dependencies: 1741 1273 1275
-- Name: wms_srs_ibfk_1; Type: FK CONSTRAINT; Schema: public; Owner: admin
--

ALTER TABLE ONLY wms_srs
    ADD CONSTRAINT wms_srs_ibfk_1 FOREIGN KEY (fkey_wms_id) REFERENCES wms(wms_id) ON UPDATE CASCADE ON DELETE CASCADE;


 
--  
-- add missing primary keys 
--
ALTER TABLE gui_layer ADD CONSTRAINT pk_gui_layer PRIMARY KEY (fkey_gui_id,fkey_layer_id);

ALTER TABLE gui_wms ADD CONSTRAINT pk_gui_wms PRIMARY KEY (fkey_gui_id,fkey_wms_id);

ALTER TABLE layer_keyword ADD CONSTRAINT pk_layer_keyword PRIMARY KEY (fkey_layer_id,fkey_keyword_id);

ALTER TABLE mb_user_wmc ADD CONSTRAINT pk_user_wmc PRIMARY KEY (wmc_id);

ALTER TABLE wfs_element ADD CONSTRAINT pk_wfs_element PRIMARY KEY (fkey_featuretype_id,element_id);

ALTER TABLE wms_format ADD CONSTRAINT pk_wms_format PRIMARY KEY (fkey_wms_id,data_type,data_format);

ALTER TABLE wms_md_topic_category ADD CONSTRAINT pk_md_topic_category PRIMARY KEY (fkey_wms_id,fkey_md_topic_category_id);

ALTER TABLE wms_srs ADD CONSTRAINT pk_wms_srs PRIMARY KEY (fkey_wms_id,wms_srs);

ALTER TABLE wfs_featuretype_namespace ADD CONSTRAINT pk_featuretype_namespace PRIMARY KEY  (fkey_wfs_id,fkey_featuretype_id,namespace);

ALTER TABLE mb_monitor ADD CONSTRAINT pk_mb_monitor PRIMARY KEY  (upload_id,fkey_wms_id);

ALTER TABLE mb_log ADD CONSTRAINT pk_mb_log PRIMARY KEY  (id); 

