--
--

-- Started on 2013-02-05 17:08:38

SET escape_string_warning = off;

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

CREATE SCHEMA map;



--
-- TOC entry 519 (class 1247 OID 36800)
-- Dependencies: 520 8
-- 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 189 (class 1255 OID 36802)
-- Dependencies: 8
-- 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 168 (class 1259 OID 36805)
-- Dependencies: 8
-- Name: configuration; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

CREATE TABLE configuration (
    id integer 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 167 (class 1259 OID 36803)
-- Dependencies: 168 8
-- Name: configuration_id_seq; Type: SEQUENCE; Schema: map; Owner: -
--

CREATE SEQUENCE configuration_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 1894 (class 0 OID 0)
-- Dependencies: 167
-- Name: configuration_id_seq; Type: SEQUENCE OWNED BY; Schema: map; Owner: -
--

ALTER SEQUENCE configuration_id_seq OWNED BY configuration.id;


--
-- TOC entry 169 (class 1259 OID 36812)
-- Dependencies: 8
-- 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 171 (class 1259 OID 36820)
-- Dependencies: 1872 1873 8
-- Name: mapping; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

CREATE TABLE mapping (
    id integer 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 170 (class 1259 OID 36818)
-- Dependencies: 171 8
-- Name: mapping_id_seq; Type: SEQUENCE; Schema: map; Owner: -
--

CREATE SEQUENCE mapping_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 1895 (class 0 OID 0)
-- Dependencies: 170
-- Name: mapping_id_seq; Type: SEQUENCE OWNED BY; Schema: map; Owner: -
--

ALTER SEQUENCE mapping_id_seq OWNED BY mapping.id;


--
-- TOC entry 173 (class 1259 OID 36831)
-- Dependencies: 1875 8 519
-- Name: mapping_set; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

CREATE TABLE mapping_set (
    id integer 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 172 (class 1259 OID 36829)
-- Dependencies: 8 173
-- Name: mapping_set_id_seq; Type: SEQUENCE; Schema: map; Owner: -
--

CREATE SEQUENCE mapping_set_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- TOC entry 1896 (class 0 OID 0)
-- Dependencies: 172
-- Name: mapping_set_id_seq; Type: SEQUENCE OWNED BY; Schema: map; Owner: -
--

ALTER SEQUENCE mapping_set_id_seq OWNED BY mapping_set.id;


--
-- TOC entry 174 (class 1259 OID 36839)
-- Dependencies: 8
-- Name: relation; Type: TABLE; Schema: map; Owner: -; Tablespace: 
--

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


--
-- TOC entry 1870 (class 2604 OID 36808)
-- Dependencies: 167 168 168
-- Name: id; Type: DEFAULT; Schema: map; Owner: -
--

ALTER TABLE configuration ALTER COLUMN id SET DEFAULT nextval('configuration_id_seq'::regclass);


--
-- TOC entry 1871 (class 2604 OID 36823)
-- Dependencies: 170 171 171
-- Name: id; Type: DEFAULT; Schema: map; Owner: -
--

ALTER TABLE mapping ALTER COLUMN id SET DEFAULT nextval('mapping_id_seq'::regclass);


--
-- TOC entry 1874 (class 2604 OID 36834)
-- Dependencies: 172 173 173
-- Name: id; Type: DEFAULT; Schema: map; Owner: -
--

ALTER TABLE mapping_set ALTER COLUMN id SET DEFAULT nextval('mapping_set_id_seq'::regclass);


--
-- TOC entry 1877 (class 2606 OID 36846)
-- Dependencies: 168 168
-- Name: configuration_pkey; Type: CONSTRAINT; Schema: map; Owner: -; Tablespace: 
--

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


--
-- TOC entry 1879 (class 2606 OID 36848)
-- Dependencies: 169 169
-- 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 1881 (class 2606 OID 36850)
-- Dependencies: 171 171
-- Name: mapping_pkey; Type: CONSTRAINT; Schema: map; Owner: -; Tablespace: 
--

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


--
-- TOC entry 1883 (class 2606 OID 36852)
-- Dependencies: 173 173
-- 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 1885 (class 2606 OID 36854)
-- Dependencies: 174 174
-- Name: relation_pkey; Type: CONSTRAINT; Schema: map; Owner: -; Tablespace: 
--

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


--
-- TOC entry 1886 (class 2606 OID 36855)
-- Dependencies: 168 1876 169
-- 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 1887 (class 2606 OID 36860)
-- Dependencies: 173 1882 171
-- 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 1888 (class 2606 OID 36865)
-- Dependencies: 1882 173 171
-- 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 1889 (class 2606 OID 36870)
-- Dependencies: 174 171 1884
-- 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 1890 (class 2606 OID 36875)
-- Dependencies: 168 1876 173
-- 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 1891 (class 2606 OID 36880)
-- Dependencies: 169 173 1878
-- 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 2013-02-05 17:08:38

--
--

