--
--

-- Started on 2012-06-18 17:48:03

SET escape_string_warning = off;

--
-- TOC entry 6 (class 2615 OID 20410)
-- Name: map; Type: SCHEMA; Schema: -; Owner: -
--

CREATE SCHEMA map;



--
-- TOC entry 483 (class 1247 OID 20411)
-- Dependencies: 484 6
-- Name: map_set_type_domain; Type: DOMAIN; Schema: map; Owner: -
--

CREATE DOMAIN map_set_type_domain AS character varying(20)
	CONSTRAINT map_set_type_domain_check CHECK (((((VALUE)::text = 'document'::text) OR ((VALUE)::text = 'knowledge_chunk'::text)) OR ((VALUE)::text = 'mapping_set'::text) OR ((VALUE)::text = 'property'::text)));


--
-- TOC entry 175 (class 1255 OID 20413)
-- Dependencies: 6
-- Name: renew_map_db(); Type: FUNCTION; Schema: map; Owner: -
--

CREATE FUNCTION renew_map_db() RETURNS void
    LANGUAGE sql
    AS $$ALTER SEQUENCE map.configuration_id_seq RESTART 1;
ALTER SEQUENCE map.mapping_id_seq RESTART 1;
ALTER SEQUENCE map.mapping_set_id_seq RESTART 1;

DELETE FROM map.mapping;
DELETE FROM map.mapping_set;
DELETE FROM map.configuration;
DELETE FROM map.hmatch_user;
DELETE FROM map.relation;

$$;




--
-- TOC entry 154 (class 1259 OID 20416)
-- Dependencies: 1836 6
-- Name: configuration; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

CREATE TABLE configuration (
    id serial NOT NULL,
    matcher character varying,
    map_cardinality character(3),
    l_treshold double precision,
    l_use_wn boolean,
    l_wn_metric character varying,
    l_use_stringmatch boolean,
    l_string_metric character varying,
    c_treshold double precision,
    c_l_weight double precision,
    c_inheritance boolean,
    c_match_model character varying,
    c_empty_context_strategy character varying,
    c_match_strategy character varying,
    i_treshold double precision,
    i_use_reasoner boolean,
    i_reasoner character varying,
    i_maximize_undef_weights_prop boolean,
    i_use_match_selector boolean
);


--
-- TOC entry 155 (class 1259 OID 20423)
-- Dependencies: 6
-- Name: hmatch_user; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

CREATE TABLE hmatch_user (
    username character varying(16) NOT NULL,
    password character varying(32),
    name character varying,
    default_configuration integer
);


--
-- TOC entry 157 (class 1259 OID 20431)
-- Dependencies: 1837 1838 1839 6
-- Name: mapping; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

CREATE TABLE mapping (
    id serial NOT NULL,
    source_element character varying NOT NULL,
    target_element character varying NOT NULL,
    relation character varying DEFAULT '='::character varying,
    comment character varying,
    similarity double precision NOT NULL,
    confidence double precision,
    is_user_valid boolean DEFAULT false,
    belongs integer,
    has_matching_axioms integer
);



--
-- TOC entry 159 (class 1259 OID 20442)
-- Dependencies: 1840 1841 6 483
-- Name: mapping_set; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

CREATE TABLE mapping_set (
    id serial NOT NULL,
    source character varying NOT NULL,
    target character varying NOT NULL,
    source_connectionstring character varying,
    target_connectionstring character varying,
    creation_timestamp timestamp without time zone DEFAULT now() NOT NULL,
    comment character varying,
    type map_set_type_domain,
    affinity double precision,
    hmatch_user character varying(16),
    configuration integer
);


--
-- TOC entry 160 (class 1259 OID 20450)
-- Dependencies: 6
-- Name: relation; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

CREATE TABLE relation (
    symbol character varying NOT NULL,
    description character varying
);


--
-- TOC entry 1843 (class 2606 OID 20457)
-- Dependencies: 154 154
-- Name: configuration_pkey; Type: CONSTRAINT; Schema: map; Owner: -; Tablespace: 
--

ALTER TABLE ONLY configuration
    ADD CONSTRAINT configuration_pkey PRIMARY KEY (id);


--
-- TOC entry 1845 (class 2606 OID 20459)
-- Dependencies: 155 155
-- Name: hmatch_user_pkey; Type: CONSTRAINT; Schema: map; Owner: -; Tablespace: 
--

ALTER TABLE ONLY hmatch_user
    ADD CONSTRAINT hmatch_user_pkey PRIMARY KEY (username);


--
-- TOC entry 1847 (class 2606 OID 20461)
-- Dependencies: 157 157
-- Name: mapping_pkey; Type: CONSTRAINT; Schema: map; Owner: -; Tablespace: 
--

ALTER TABLE ONLY mapping
    ADD CONSTRAINT mapping_pkey PRIMARY KEY (id);


--
-- TOC entry 1849 (class 2606 OID 20463)
-- Dependencies: 159 159
-- Name: mapping_set_pkey; Type: CONSTRAINT; Schema: map; Owner: -; Tablespace: 
--

ALTER TABLE ONLY mapping_set
    ADD CONSTRAINT mapping_set_pkey PRIMARY KEY (id);


--
-- TOC entry 1851 (class 2606 OID 20465)
-- Dependencies: 160 160
-- Name: relation_pkey; Type: CONSTRAINT; Schema: map; Owner: -; Tablespace: 
--

ALTER TABLE ONLY relation
    ADD CONSTRAINT relation_pkey PRIMARY KEY (symbol);


--
-- TOC entry 1852 (class 2606 OID 20466)
-- Dependencies: 1842 154 155
-- Name: hmatch_user_default_configuration_fkey; Type: FK CONSTRAINT; Schema: map; Owner: -
--

ALTER TABLE ONLY hmatch_user
    ADD CONSTRAINT hmatch_user_default_configuration_fkey FOREIGN KEY (default_configuration) REFERENCES configuration(id) ON UPDATE CASCADE;


--
-- TOC entry 1853 (class 2606 OID 20471)
-- Dependencies: 1848 159 157
-- Name: mapping_belongs_fkey; Type: FK CONSTRAINT; Schema: map; Owner: -
--

ALTER TABLE ONLY mapping
    ADD CONSTRAINT mapping_belongs_fkey FOREIGN KEY (belongs) REFERENCES mapping_set(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1854 (class 2606 OID 20476)
-- Dependencies: 1848 157 159
-- Name: mapping_has_matching_axioms_fkey; Type: FK CONSTRAINT; Schema: map; Owner: -
--

ALTER TABLE ONLY mapping
    ADD CONSTRAINT mapping_has_matching_axioms_fkey FOREIGN KEY (has_matching_axioms) REFERENCES mapping_set(id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- TOC entry 1855 (class 2606 OID 20481)
-- Dependencies: 157 1850 160
-- Name: mapping_relation_fkey; Type: FK CONSTRAINT; Schema: map; Owner: -
--

ALTER TABLE ONLY mapping
    ADD CONSTRAINT mapping_relation_fkey FOREIGN KEY (relation) REFERENCES relation(symbol);


--
-- TOC entry 1856 (class 2606 OID 20486)
-- Dependencies: 154 159 1842
-- Name: mapping_set_configuration_fkey; Type: FK CONSTRAINT; Schema: map; Owner: -
--

ALTER TABLE ONLY mapping_set
    ADD CONSTRAINT mapping_set_configuration_fkey FOREIGN KEY (configuration) REFERENCES configuration(id) ON UPDATE CASCADE;


--
-- TOC entry 1857 (class 2606 OID 20491)
-- Dependencies: 1844 159 155
-- Name: mapping_set_hmatch_user_fkey; Type: FK CONSTRAINT; Schema: map; Owner: -
--

ALTER TABLE ONLY mapping_set
    ADD CONSTRAINT mapping_set_hmatch_user_fkey FOREIGN KEY (hmatch_user) REFERENCES hmatch_user(username) ON UPDATE CASCADE;


-- Completed on 2012-06-18 17:48:03

--
--

