--
--

-- Started on 2012-02-27 10:23:43

SET escape_string_warning = off;

--
-- TOC entry 8 (class 2615 OID 17831)
-- Name: ic; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA ic;


ALTER SCHEMA ic OWNER TO postgres;


--
-- TOC entry 185 (class 1255 OID 17838)
-- Dependencies: 8
-- Name: renew_cloud_db(); Type: FUNCTION; Schema: ic; Owner: postgres
--

CREATE FUNCTION renew_cloud_db() RETURNS void
    LANGUAGE sql
    AS $$ALTER SEQUENCE ic.cluster_keyword_sequence RESTART 1;
ALTER SEQUENCE ic.cluster_id_sequence RESTART 1;
ALTER SEQUENCE ic.cluster_resource_sequence RESTART 1;
ALTER SEQUENCE ic.cluster_type_sequence RESTART 1;
ALTER SEQUENCE ic.link_sequence RESTART 1;
ALTER SEQUENCE ic.web_data_cloud_sequence RESTART 1;

DELETE FROM ic.link;
DELETE FROM ic.cluster_keyword;
DELETE FROM ic.cluster_type;
DELETE FROM ic.cluster_resource;
DELETE FROM ic.cluster;
DELETE FROM ic.web_data_cloud;$$;


ALTER FUNCTION ic.renew_cloud_db() OWNER TO postgres;

--
-- TOC entry 142 (class 1259 OID 17839)
-- Dependencies: 8
-- Name: cluster_id_sequence; Type: SEQUENCE; Schema: ic; Owner: postgres
--

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


ALTER TABLE ic.cluster_id_sequence OWNER TO postgres;



--
-- TOC entry 143 (class 1259 OID 17841)
-- Dependencies: 1861 8
-- Name: cluster; Type: TABLE; Schema: ic; Owner: postgres; Tablespace: 
--

CREATE TABLE cluster (
    id integer DEFAULT nextval('cluster_id_sequence'::regclass) NOT NULL,
    prominence double precision,
    incloud integer
);


ALTER TABLE ic.cluster OWNER TO postgres;

--
-- TOC entry 144 (class 1259 OID 17845)
-- Dependencies: 8
-- Name: cluster_keyword_sequence; Type: SEQUENCE; Schema: ic; Owner: postgres
--

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


ALTER TABLE ic.cluster_keyword_sequence OWNER TO postgres;

--
-- TOC entry 145 (class 1259 OID 17847)
-- Dependencies: 1862 8
-- Name: cluster_keyword; Type: TABLE; Schema: ic; Owner: postgres; Tablespace: 
--

CREATE TABLE cluster_keyword (
    cluster integer NOT NULL,
    keyword_id integer NOT NULL,
    term character varying(45),
    relevance double precision,
    id integer DEFAULT nextval('cluster_keyword_sequence'::regclass) NOT NULL
);


ALTER TABLE ic.cluster_keyword OWNER TO postgres;

--
-- TOC entry 146 (class 1259 OID 17851)
-- Dependencies: 8
-- Name: cluster_resource_sequence; Type: SEQUENCE; Schema: ic; Owner: postgres
--

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


ALTER TABLE ic.cluster_resource_sequence OWNER TO postgres;

--
-- TOC entry 147 (class 1259 OID 17853)
-- Dependencies: 1863 8
-- Name: cluster_resource; Type: TABLE; Schema: ic; Owner: postgres; Tablespace: 
--

CREATE TABLE cluster_resource (
    resource character varying(255) NOT NULL,
    relevance double precision,
    cluster integer NOT NULL,
    id integer DEFAULT nextval('cluster_resource_sequence'::regclass) NOT NULL
);


ALTER TABLE ic.cluster_resource OWNER TO postgres;

--
-- TOC entry 148 (class 1259 OID 17857)
-- Dependencies: 8
-- Name: cluster_type_sequence; Type: SEQUENCE; Schema: ic; Owner: postgres
--

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


ALTER TABLE ic.cluster_type_sequence OWNER TO postgres;

--
-- TOC entry 149 (class 1259 OID 17859)
-- Dependencies: 1864 8
-- Name: cluster_type; Type: TABLE; Schema: ic; Owner: postgres; Tablespace: 
--

CREATE TABLE cluster_type (
    class character varying(255) NOT NULL,
    cluster integer NOT NULL,
    relevance double precision,
    id integer DEFAULT nextval('cluster_type_sequence'::regclass) NOT NULL
);


ALTER TABLE ic.cluster_type OWNER TO postgres;

--
-- TOC entry 150 (class 1259 OID 17863)
-- Dependencies: 8
-- Name: link_sequence; Type: SEQUENCE; Schema: ic; Owner: postgres
--

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


ALTER TABLE ic.link_sequence OWNER TO postgres;

--
-- TOC entry 151 (class 1259 OID 17865)
-- Dependencies: 1865 8
-- Name: link; Type: TABLE; Schema: ic; Owner: postgres; Tablespace: 
--

CREATE TABLE link (
    source integer NOT NULL,
    target integer NOT NULL,
    proximity double precision,
    id integer DEFAULT nextval('link_sequence'::regclass) NOT NULL,
    incloud integer
);


ALTER TABLE ic.link OWNER TO postgres;

--
-- TOC entry 152 (class 1259 OID 17869)
-- Dependencies: 8
-- Name: web_data_cloud_sequence; Type: SEQUENCE; Schema: ic; Owner: postgres
--

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


ALTER TABLE ic.web_data_cloud_sequence OWNER TO postgres;

--
-- TOC entry 153 (class 1259 OID 17871)
-- Dependencies: 1866 8
-- Name: web_data_cloud; Type: TABLE; Schema: ic; Owner: postgres; Tablespace: 
--

CREATE TABLE web_data_cloud (
    id integer DEFAULT nextval('web_data_cloud_sequence'::regclass) NOT NULL,
    target_entity character varying(255),
    direct boolean
);


ALTER TABLE ic.web_data_cloud OWNER TO postgres;

--
-- TOC entry 1870 (class 2606 OID 17876)
-- Dependencies: 145 145
-- Name: cl_ess_pkey; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY cluster_keyword
    ADD CONSTRAINT cl_ess_pkey PRIMARY KEY (id);


--
-- TOC entry 1872 (class 2606 OID 17878)
-- Dependencies: 145 145 145
-- Name: cl_ess_unique; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY cluster_keyword
    ADD CONSTRAINT cl_ess_unique UNIQUE (cluster, keyword_id);


--
-- TOC entry 1868 (class 2606 OID 17880)
-- Dependencies: 143 143
-- Name: cluster_pkey; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY cluster
    ADD CONSTRAINT cluster_pkey PRIMARY KEY (id);


--
-- TOC entry 1874 (class 2606 OID 17882)
-- Dependencies: 147 147
-- Name: cr_pkey; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY cluster_resource
    ADD CONSTRAINT cr_pkey PRIMARY KEY (id);


--
-- TOC entry 1876 (class 2606 OID 17884)
-- Dependencies: 147 147 147
-- Name: cr_unique; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY cluster_resource
    ADD CONSTRAINT cr_unique UNIQUE (resource, cluster);


--
-- TOC entry 1878 (class 2606 OID 17886)
-- Dependencies: 149 149
-- Name: ctype_pkey; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY cluster_type
    ADD CONSTRAINT ctype_pkey PRIMARY KEY (id);


--
-- TOC entry 1880 (class 2606 OID 17888)
-- Dependencies: 149 149 149
-- Name: ctype_unique_cluster_class; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY cluster_type
    ADD CONSTRAINT ctype_unique_cluster_class UNIQUE (cluster, class);


--
-- TOC entry 1882 (class 2606 OID 17890)
-- Dependencies: 151 151
-- Name: proximity_pkey; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY link
    ADD CONSTRAINT proximity_pkey PRIMARY KEY (id);


--
-- TOC entry 1884 (class 2606 OID 17892)
-- Dependencies: 151 151 151
-- Name: source_target_unique; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY link
    ADD CONSTRAINT source_target_unique UNIQUE (source, target);


--
-- TOC entry 1886 (class 2606 OID 17894)
-- Dependencies: 153 153
-- Name: wdc_primary_key; Type: CONSTRAINT; Schema: ic; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY web_data_cloud
    ADD CONSTRAINT wdc_primary_key PRIMARY KEY (id);


--
-- TOC entry 1887 (class 2606 OID 17895)
-- Dependencies: 143 1885 153
-- Name: cluster_cloud_fkey; Type: FK CONSTRAINT; Schema: ic; Owner: postgres
--

ALTER TABLE ONLY cluster
    ADD CONSTRAINT cluster_cloud_fkey FOREIGN KEY (incloud) REFERENCES web_data_cloud(id) ON UPDATE CASCADE;


--
-- TOC entry 1889 (class 2606 OID 17900)
-- Dependencies: 147 143 1867
-- Name: cluster_fkey; Type: FK CONSTRAINT; Schema: ic; Owner: postgres
--

ALTER TABLE ONLY cluster_resource
    ADD CONSTRAINT cluster_fkey FOREIGN KEY (cluster) REFERENCES cluster(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 1888 (class 2606 OID 17905)
-- Dependencies: 143 145 1867
-- Name: cluster_fkey; Type: FK CONSTRAINT; Schema: ic; Owner: postgres
--

ALTER TABLE ONLY cluster_keyword
    ADD CONSTRAINT cluster_fkey FOREIGN KEY (cluster) REFERENCES cluster(id);


--
-- TOC entry 1890 (class 2606 OID 17910)
-- Dependencies: 149 1867 143
-- Name: ctype_cluster_fkey; Type: FK CONSTRAINT; Schema: ic; Owner: postgres
--

ALTER TABLE ONLY cluster_type
    ADD CONSTRAINT ctype_cluster_fkey FOREIGN KEY (cluster) REFERENCES cluster(id);


--
-- TOC entry 1891 (class 2606 OID 17915)
-- Dependencies: 153 1885 151
-- Name: incloud_fk; Type: FK CONSTRAINT; Schema: ic; Owner: postgres
--

ALTER TABLE ONLY link
    ADD CONSTRAINT incloud_fk FOREIGN KEY (incloud) REFERENCES web_data_cloud(id);


--
-- TOC entry 1892 (class 2606 OID 17920)
-- Dependencies: 1867 151 143
-- Name: p_source_fkey; Type: FK CONSTRAINT; Schema: ic; Owner: postgres
--

ALTER TABLE ONLY link
    ADD CONSTRAINT p_source_fkey FOREIGN KEY (source) REFERENCES cluster(id);


--
-- TOC entry 1893 (class 2606 OID 17925)
-- Dependencies: 151 1867 143
-- Name: prox_target_fkey; Type: FK CONSTRAINT; Schema: ic; Owner: postgres
--

ALTER TABLE ONLY link
    ADD CONSTRAINT prox_target_fkey FOREIGN KEY (target) REFERENCES cluster(id);


-- Completed on 2012-02-27 10:23:44

--
--

