--
--

-- Started on 2012-09-28 18:42:34 CEST


--
-- TOC entry 262 (class 3079 OID 11907)
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- TOC entry 3020 (class 0 OID 0)
-- Dependencies: 262
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';



--
-- TOC entry 607 (class 1247 OID 34364)
-- Dependencies: 5
-- Name: access_rights_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE access_rights_enum AS ENUM (
    'r',
    'ru',
    'rud'
);


--
-- TOC entry 610 (class 1247 OID 34372)
-- Dependencies: 5
-- Name: administration_status_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE administration_status_enum AS ENUM (
    'private',
    'submission',
    'pre-evaluation',
    'evaluation',
    'rejected-TDG',
    'accepted-TDG',
    'pre-validation',
    'validation',
    'accepted',
    'rejected-DCRB',
    'external',
    'finished'
);


--
-- TOC entry 613 (class 1247 OID 34398)
-- Dependencies: 5
-- Name: check_result_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE check_result_enum AS ENUM (
    'unchecked',
    'fatal',
    'error',
    'warning',
    'ok'
);


--
-- TOC entry 616 (class 1247 OID 34410)
-- Dependencies: 5
-- Name: lock_type_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE lock_type_enum AS ENUM (
    'data category'
);


--
-- TOC entry 619 (class 1247 OID 34414)
-- Dependencies: 5
-- Name: member_status_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE member_status_enum AS ENUM (
    'invite',
    'invited',
    'accepted',
    'declined'
);


--
-- TOC entry 622 (class 1247 OID 34424)
-- Dependencies: 5
-- Name: member_type_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE member_type_enum AS ENUM (
    'member',
    'chair'
);


--
-- TOC entry 625 (class 1247 OID 34430)
-- Dependencies: 5
-- Name: message_status_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE message_status_enum AS ENUM (
    'valid',
    'read',
    'obsolete',
    'deleted'
);


--
-- TOC entry 628 (class 1247 OID 34440)
-- Dependencies: 5
-- Name: message_type_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE message_type_enum AS ENUM (
    'message',
    'invitation',
    'request',
    'news',
    'broadcast'
);


--
-- TOC entry 631 (class 1247 OID 34452)
-- Dependencies: 5
-- Name: name_status_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE name_status_enum AS ENUM (
    'standardized name',
    'preferred name',
    'admitted name',
    'deprecated name',
    'superseded name'
);


--
-- TOC entry 634 (class 1247 OID 34464)
-- Dependencies: 5
-- Name: name_type_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE name_type_enum AS ENUM (
    'name section',
    'data element name'
);


--
-- TOC entry 637 (class 1247 OID 34470)
-- Dependencies: 5
-- Name: owner_type_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE owner_type_enum AS ENUM (
    'data category',
    'language section',
    'linguistic section',
    'text',
    'change request'
);


--
-- TOC entry 640 (class 1247 OID 34482)
-- Dependencies: 5
-- Name: registration_status_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE registration_status_enum AS ENUM (
    'private',
    'candidate',
    'standard',
    'deprecated',
    'superseded'
);


--
-- TOC entry 643 (class 1247 OID 34494)
-- Dependencies: 5
-- Name: text_type_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE text_type_enum AS ENUM (
    'text',
    'explanatory comment',
    'unresolved issue',
    'change',
    'explanation',
    'linguistic explanation',
    'definition',
    'example',
    'linguistic example',
    'note',
    'administration note'
);


--
-- TOC entry 646 (class 1247 OID 34518)
-- Dependencies: 5
-- Name: user_type_enum; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE user_type_enum AS ENUM (
    'basic',
    'expert',
    'admin'
);


--
-- TOC entry 274 (class 1255 OID 34525)
-- Dependencies: 5
-- Name: concat(text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION concat(text, text) RETURNS text
    LANGUAGE sql IMMUTABLE
    AS $_$
SELECT CASE WHEN $1 = '' THEN $2 ELSE $1 || ' ' || $2 END
$_$;


--
-- TOC entry 275 (class 1255 OID 34526)
-- Dependencies: 5 921
-- Name: dc_profiles(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION dc_profiles(dcid integer) RETURNS SETOF integer
    LANGUAGE plpgsql
    AS $$
DECLARE
    profile RECORD;
    path RECORD;
BEGIN
    FOR profile IN SELECT DISTINCT link_profile_members.profile FROM link_profile_members WHERE link_profile_members.dc = dcid LOOP
       FOR path IN SELECT * FROM profile_path(profile.profile) LOOP
          RETURN NEXT path.profile_path;
       END LOOP;
    END LOOP;
END;
$$;


--
-- TOC entry 276 (class 1255 OID 34527)
-- Dependencies: 5 921
-- Name: dc_super_cycle(integer[], integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION dc_super_cycle(path integer[], super integer) RETURNS boolean
    LANGUAGE plpgsql
    AS $$
DECLARE
    isa RECORD;
BEGIN
    IF
        (path @> ARRAY[super])
    THEN
RAISE NOTICE 'dc_super_cycle(path[%],super[%]) found a cycle',path,super;
        RETURN true;
    ELSE
        SELECT
  *
        FROM
  link_simple_data_category_super
        WHERE
  dc = super
INTO
  isa
;
IF
   isa IS NULL
THEN
   RETURN false;
ELSE
   RETURN dc_super_cycle(path || super,isa.super);
END IF;
    END IF;
END;
$$;


--
-- TOC entry 277 (class 1255 OID 34528)
-- Dependencies: 5 921
-- Name: dcs_self_or_descendants(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION dcs_self_or_descendants(dcs integer) RETURNS SETOF integer
    LANGUAGE plpgsql
    AS $$
DECLARE
    child RECORD;
    descendant RECORD;
BEGIN
    FOR child IN SELECT * FROM core_data_category_selection WHERE parent=dcs LOOP
       FOR descendant IN SELECT * FROM dcs_self_or_descendants(child.id) LOOP
          RETURN NEXT descendant.dcs_self_or_descendants;
       END LOOP;
    END LOOP;
    RETURN NEXT dcs;
END;
$$;


--
-- TOC entry 278 (class 1255 OID 34529)
-- Dependencies: 921 5
-- Name: delete_generic_name(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION delete_generic_name() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    DECLARE
        id integer;
        tp owner_type_enum;
    BEGIN

        IF (TG_OP = 'DELETE') THEN
        
            IF (TG_TABLE_NAME = 'core_data_category') THEN

                tp = 'data category';
            
            ELSIF (TG_TABLE_NAME = 'core_language_section') THEN
            
                tp = 'language section';

            END IF;
            
            id = OLD.id;
            
            DELETE FROM
                generic_name
             WHERE
                generic_name.owner = id
              AND
                generic_name.owner_type = tp
              ;

        END IF;

        RETURN NULL;

    END;
$$;


--
-- TOC entry 279 (class 1255 OID 34530)
-- Dependencies: 921 5
-- Name: delete_generic_text(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION delete_generic_text() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    DECLARE
        id integer;
        tp owner_type_enum;
    BEGIN

        IF (TG_OP = 'DELETE') THEN
        
            IF (TG_TABLE_NAME = 'core_data_category') THEN

                tp = 'data category';
            
            ELSIF (TG_TABLE_NAME = 'core_language_section') THEN
            
                tp = 'language section';

            ELSIF (TG_TABLE_NAME = 'core_linguistic_section') THEN
            
                tp = 'linguistic section';

            ELSIF (TG_TABLE_NAME = 'generic_text') THEN
            
                tp = 'text';

            END IF;
            
            id = OLD.id;
            
            DELETE FROM
                generic_text
             WHERE
                 generic_text.owner = id
              AND
                 generic_text.owner_type = tp
              ;

        END IF;

        RETURN NULL;

    END;
$$;


--
-- TOC entry 280 (class 1255 OID 34531)
-- Dependencies: 921 5
-- Name: get_dc_identifier(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION get_dc_identifier(dcid integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
DECLARE
	dc RECORD;
BEGIN
	SELECT
		*
	INTO
		dc
	FROM
		core_data_category
	WHERE
		core_data_category.id = dcid
	;
	RETURN dc.identifier;
END;
$$;


--
-- TOC entry 281 (class 1255 OID 34532)
-- Dependencies: 921 5
-- Name: get_dc_name(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION get_dc_name(dcid integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
DECLARE
	datcat RECORD;
BEGIN
	SELECT
		core_data_category.id AS dc,
		COALESCE(get_dc_name_status_language(dcid,'preferred name','en'), get_dc_name_status_language(dcid,'standardized name','en'), get_dc_name_status_language(dcid,'admitted name','en'), identifier, 'ERROR') AS name
	INTO
		datcat
	FROM
		core_data_category
	WHERE
		core_data_category.id = dcid
	;
	RETURN datcat.name;
END;
$$;


--
-- TOC entry 282 (class 1255 OID 34533)
-- Dependencies: 921 5
-- Name: get_dc_name_status(integer, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION get_dc_name_status(dcid integer, dcstatus character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
DECLARE
	dc RECORD;
BEGIN
	SELECT
		*
	INTO
		dc
	FROM
		view_dc_name
	WHERE
		view_dc_name.id = dcid
	  AND
		view_dc_name.status = dcstatus::name_status_enum
	  AND
		view_dc_name.name IS NOT NULL
	  AND
		view_dc_name.name != ''
	;
	RETURN dc.name;
END;
$$;


--
-- TOC entry 283 (class 1255 OID 34534)
-- Dependencies: 5 921
-- Name: get_dc_name_status_language(integer, character varying, character varying); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION get_dc_name_status_language(dcid integer, dcstatus character varying, lang character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
DECLARE
	dc RECORD;
BEGIN
	SELECT
		*
	INTO
		dc
	FROM
		view_dc_name
	WHERE
		view_dc_name.id = dcid
	  AND
		view_dc_name.status = dcstatus::name_status_enum
	  AND
		view_dc_name.name IS NOT NULL
	  AND
		view_dc_name.name != ''
	  AND
		view_dc_name.tag = lang
	;
	RETURN dc.name;
END;
$$;


--
-- TOC entry 284 (class 1255 OID 34535)
-- Dependencies: 921 5
-- Name: get_dc_type(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION get_dc_type(dc integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
DECLARE
	datcat RECORD;
BEGIN
	SELECT
		id
	FROM
		core_simple_data_category
	WHERE
		id =  dc
	INTO
		datcat
	;
	IF
		datcat IS NULL
	THEN
		SELECT
			id
		FROM
			core_container_data_category
		WHERE
			id =  dc
		INTO
			datcat
		;
		IF
			datcat IS NULL
		THEN
			SELECT
				id
			FROM
				core_closed_data_category
			WHERE
				id = dc
			INTO
				datcat
			;
			IF
				datcat IS NULL
			THEN
				SELECT
					id
				FROM
					core_constrained_data_category
				WHERE
					id = dc
				INTO
					datcat
				;
				IF
					datcat IS NULL
				THEN
					SELECT
						id
					FROM
						core_open_data_category
					WHERE
						id = dc
					INTO
						datcat
					;
					IF
						datcat IS NULL
					THEN
						RETURN 'unknown';
					ELSE
						RETURN 'open';
					END IF;
				ELSE
					RETURN 'constrained';
				END IF;
			ELSE
				RETURN 'closed';
			END IF;
		ELSE
			RETURN 'container';
		END IF;
	ELSE
		RETURN 'simple';
	END IF;
END;
$$;


--
-- TOC entry 285 (class 1255 OID 34536)
-- Dependencies: 921 5
-- Name: merge_accounts(integer, integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION merge_accounts(keep integer, remove integer) RETURNS integer
    LANGUAGE plpgsql
    AS $$
DECLARE
BEGIN
	-- owned DCs
	UPDATE core_data_category SET owner = keep WHERE owner = remove;
	-- owned DCSs
	UPDATE core_data_category_selection SET owner = keep WHERE owner = remove;
	-- owned groups
	UPDATE core_adhoc_group SET owner = keep WHERE owner = remove;
	-- owned submissions
	UPDATE core_submission_group SET owner = keep WHERE owner = remove;
	-- shared DCs
	DELETE FROM
		link_dc_access
	USING
		link_dc_access AS checker
	WHERE
		link_dc_access.dc = checker.dc
	AND
		checker.account = keep
	AND
		link_dc_access.account = remove
	;
	UPDATE link_dc_access SET account = keep WHERE account = remove;
	-- shared DCSs
	DELETE FROM
		link_dcs_access
	USING
		link_dcs_access AS checker
	WHERE
		link_dcs_access.dcs = checker.dcs
	AND
		checker.account = keep
	AND
		link_dcs_access.account = remove
	;
	UPDATE link_dcs_access SET account = keep WHERE account = remove;
	-- votes
	UPDATE core_change_request_vote SET judge = keep WHERE judge = remove;
	-- DC status changes
	UPDATE core_dc_status_log SET "user" = keep WHERE "user" = remove;
	-- messages send
	UPDATE core_message SET "from" = keep WHERE "from" = remove;
	-- messages received
	UPDATE core_message SET "to" = keep WHERE "to" = remove;
	-- texts
	UPDATE generic_text SET "user" = keep WHERE "user" = remove;
	-- group memberships
	DELETE FROM
		link_group_members
	USING
		link_group_members AS checker
	WHERE
		link_group_members."group" = checker."group"
	AND
		checker.member= keep
	AND
		link_group_members.member = remove
	;
	UPDATE link_group_members SET member = keep WHERE member = remove;

	-- SYNTAX residu
	UPDATE link_data_category_selection_users SET "user" = keep WHERE "user" = remove;

	-- delete owner
	DELETE FROM core_owner WHERE id = remove;
	-- delete account
	DELETE FROM core_account WHERE id = remove;
	RETURN keep;
END;
$$;


--
-- TOC entry 286 (class 1255 OID 34537)
-- Dependencies: 5 921
-- Name: pid(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION pid(dcid integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
DECLARE
    dc RECORD;
BEGIN
    SELECT
       *
    INTO
       dc
    FROM
       core_data_category
    WHERE
       id =  dcid
    ;
    IF 
       dc.registration_status = 2 
    THEN
	RETURN 'http://www.isocat.org/datcat/ISO-DC-' || dc.id;
    ELSE
	RETURN 'http://www.isocat.org/datcat/DC-' || dc.id;
    END IF;
END;
$$;


--
-- TOC entry 287 (class 1255 OID 34538)
-- Dependencies: 921 5
-- Name: prevent_super_cycle(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION prevent_super_cycle() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    DECLARE
    BEGIN
    
    IF (dc_super_cycle(ARRAY[NEW.dc],NEW.super))
    THEN
        RAISE EXCEPTION 'Making DC[%] the super of simple DC[%] would create a cycle, so the insert was canceled!', NEW.super, NEW.dc;
    END IF;

RETURN NEW;

    END;
$$;


--
-- TOC entry 288 (class 1255 OID 34539)
-- Dependencies: 5 921
-- Name: profile_ancestors(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION profile_ancestors(prof integer) RETURNS SETOF integer
    LANGUAGE plpgsql
    AS $$
DECLARE
    parent RECORD;
    ancestor RECORD;
BEGIN
    SELECT
       *
    INTO
       parent
    FROM
       core_profile
    WHERE
       id =  prof;
    IF 
       parent.parent IS NOT NULL
    THEN
       FOR ancestor IN SELECT * FROM profile_ancestors(parent.parent) LOOP
          RETURN NEXT ancestor.profile_ancestors;
       END LOOP;
       RETURN NEXT parent.parent;
    END IF;
END;
$$;


--
-- TOC entry 289 (class 1255 OID 34540)
-- Dependencies: 921 5
-- Name: profile_path(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION profile_path(prof integer) RETURNS SETOF integer
    LANGUAGE plpgsql
    AS $$
DECLARE
    parent RECORD;
    ancestor RECORD;
BEGIN
    SELECT
       *
    INTO
       parent
    FROM
       core_profile
    WHERE
       id =  prof
    ;
    IF 
       parent.parent IS NOT NULL
    THEN
       FOR ancestor IN SELECT * FROM profile_path(parent.parent) LOOP
          RETURN NEXT ancestor.profile_path;
       END LOOP;
    END IF;
    RETURN NEXT prof;
END;
$$;


--
-- TOC entry 290 (class 1255 OID 34541)
-- Dependencies: 5 921
-- Name: profile_self_or_descendants(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION profile_self_or_descendants(prof integer) RETURNS SETOF integer
    LANGUAGE plpgsql
    AS $$
DECLARE
    child RECORD;
    descendant RECORD;
BEGIN
    FOR child IN SELECT * FROM core_profile WHERE parent=prof LOOP
       FOR descendant IN SELECT * FROM profile_self_or_descendants(child.id) LOOP
          RETURN NEXT descendant.profile_self_or_descendants;
       END LOOP;
    END LOOP;
    RETURN NEXT prof;
END;
$$;


--
-- TOC entry 291 (class 1255 OID 34542)
-- Dependencies: 921 5
-- Name: update_search_identifier(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION update_search_identifier() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    DECLARE
	lang RECORD;
    BEGIN

	-- update the language independent search vector
	NEW.search = to_tsvector('simple',NEW.identifier);

	-- update the language specific search vector
	NEW.search_language = to_tsvector('english',NEW.identifier);

	RETURN NEW;

    END;
$$;


--
-- TOC entry 292 (class 1255 OID 34543)
-- Dependencies: 5 921
-- Name: update_search_name(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION update_search_name() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    DECLARE
	lang RECORD;
    BEGIN

	SELECT
		*
	INTO
		lang
	FROM
		core_language
	WHERE
		id = NEW.language
	;

	-- update the language independent search vector
	NEW.search = to_tsvector('simple',NEW.name);

	-- update the language specific search vector
	NEW.search_language = to_tsvector(CAST(lang.search AS regconfig),NEW.name);

	RETURN NEW;

    END;
$$;


--
-- TOC entry 293 (class 1255 OID 34544)
-- Dependencies: 5 921
-- Name: update_search_text(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION update_search_text() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    DECLARE
	lang RECORD;
    BEGIN

	SELECT
		*
	INTO
		lang
	FROM
		core_language
	WHERE
		id = NEW.language
	;

	-- update the language independent search vector
	NEW.search = to_tsvector('simple',NEW.text);

	-- update the language specific search vector
	NEW.search_language = to_tsvector(CAST(lang.search AS regconfig),NEW.text);

	RETURN NEW;

    END;
$$;


--
-- TOC entry 294 (class 1255 OID 34545)
-- Dependencies: 5 921
-- Name: user_name(integer); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION user_name(uid integer) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
DECLARE
    profile RECORD;
    ancestor RECORD;
BEGIN
    SELECT
       *
    INTO
       profile
    FROM
       core_user
    WHERE
       id =  uid
    ;
    IF
    	profile.last_name IS NOT NULL AND TRIM(profile.last_name) != ''
    THEN
	    IF 
	       profile.first_name IS NOT NULL AND TRIM(profile.first_name) != '' 
	    THEN
	    	RETURN TRIM(profile.last_name) || ', ' || TRIM(profile.first_name);
	    ELSE
	    	RETURN TRIM(profile.last_name);
	    END IF;
    ELSE
    	RETURN profile.login;
    END IF;
END;
$$;


--
-- TOC entry 295 (class 1255 OID 34546)
-- Dependencies: 5
-- Name: xpath_list(text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION xpath_list(text, text) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    AS $_$SELECT xpath_list($1,$2,',')$_$;


--
-- TOC entry 296 (class 1255 OID 34547)
-- Dependencies: 5
-- Name: xpath_nodeset(text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION xpath_nodeset(text, text) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    AS $_$SELECT xpath_nodeset($1,$2,'','')$_$;


--
-- TOC entry 297 (class 1255 OID 34548)
-- Dependencies: 5
-- Name: xpath_nodeset(text, text, text); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION xpath_nodeset(text, text, text) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    AS $_$SELECT xpath_nodeset($1,$2,'',$3)$_$;


--
-- TOC entry 922 (class 1255 OID 34549)
-- Dependencies: 5 274
-- Name: concat(text); Type: AGGREGATE; Schema: public; Owner: -
--

CREATE AGGREGATE concat(text) (
    SFUNC = public.concat,
    STYPE = text,
    INITCOND = ''
);




--
-- TOC entry 163 (class 1259 OID 34550)
-- Dependencies: 5
-- Name: core_account; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_account (
    id integer NOT NULL
);


--
-- TOC entry 3021 (class 0 OID 0)
-- Dependencies: 163
-- Name: TABLE core_account; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_account IS 'The core data table for accounts';


--
-- TOC entry 164 (class 1259 OID 34553)
-- Dependencies: 163 5
-- Name: core_account_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3022 (class 0 OID 0)
-- Dependencies: 164
-- Name: core_account_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_account_id_seq OWNED BY core_account.id;


--
-- TOC entry 165 (class 1259 OID 34555)
-- Dependencies: 5
-- Name: core_adhoc_group; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_adhoc_group (
    id integer NOT NULL,
    owner integer NOT NULL,
    description character varying,
    name character varying NOT NULL
);


--
-- TOC entry 3023 (class 0 OID 0)
-- Dependencies: 165
-- Name: TABLE core_adhoc_group; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_adhoc_group IS 'The core table for adhoc groups.';


--
-- TOC entry 166 (class 1259 OID 34561)
-- Dependencies: 2568 5 610
-- Name: core_change_request; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_change_request (
    id integer NOT NULL,
    name character varying NOT NULL,
    tdg integer NOT NULL,
    submission_group integer NOT NULL,
    decision_group_tdg integer,
    forum integer,
    forum_group integer,
    decision_group_dcrb integer,
    dcs integer NOT NULL,
    status administration_status_enum DEFAULT 'submission'::administration_status_enum NOT NULL,
    start timestamp with time zone,
    stop timestamp with time zone
);


--
-- TOC entry 3024 (class 0 OID 0)
-- Dependencies: 166
-- Name: TABLE core_change_request; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_change_request IS 'The core data table for change requests.';


--
-- TOC entry 167 (class 1259 OID 34568)
-- Dependencies: 5 166
-- Name: core_change_request_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3025 (class 0 OID 0)
-- Dependencies: 167
-- Name: core_change_request_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_change_request_id_seq OWNED BY core_change_request.id;


--
-- TOC entry 168 (class 1259 OID 34570)
-- Dependencies: 2570 5 610
-- Name: core_change_request_vote; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_change_request_vote (
    id integer NOT NULL,
    cr integer NOT NULL,
    judge integer NOT NULL,
    dc integer NOT NULL,
    accept boolean,
    status administration_status_enum NOT NULL,
    "when" timestamp with time zone DEFAULT ('now'::text)::timestamp with time zone NOT NULL
);


--
-- TOC entry 169 (class 1259 OID 34574)
-- Dependencies: 168 5
-- Name: core_change_request_vote_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3026 (class 0 OID 0)
-- Dependencies: 169
-- Name: core_change_request_vote_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_change_request_vote_id_seq OWNED BY core_change_request_vote.id;


--
-- TOC entry 170 (class 1259 OID 34576)
-- Dependencies: 5
-- Name: core_closed_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_closed_data_category (
    id integer NOT NULL
);


--
-- TOC entry 3027 (class 0 OID 0)
-- Dependencies: 170
-- Name: TABLE core_closed_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_closed_data_category IS 'The core data table for closed Data Categories.';


--
-- TOC entry 171 (class 1259 OID 34579)
-- Dependencies: 5
-- Name: core_closed_linguistic_section; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_closed_linguistic_section (
    id integer NOT NULL,
    cd integer,
    dc integer NOT NULL
);


--
-- TOC entry 3028 (class 0 OID 0)
-- Dependencies: 171
-- Name: TABLE core_closed_linguistic_section; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_closed_linguistic_section IS 'The core data table for closed linguistic sections.';


--
-- TOC entry 3029 (class 0 OID 0)
-- Dependencies: 171
-- Name: COLUMN core_closed_linguistic_section.cd; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_closed_linguistic_section.cd IS 'The value domain of this closed linguistic section.';


--
-- TOC entry 172 (class 1259 OID 34582)
-- Dependencies: 5
-- Name: core_complex_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_complex_data_category (
    id integer NOT NULL
);


--
-- TOC entry 3030 (class 0 OID 0)
-- Dependencies: 172
-- Name: TABLE core_complex_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_complex_data_category IS 'The core data table for complex Data Categories.';


--
-- TOC entry 3031 (class 0 OID 0)
-- Dependencies: 172
-- Name: COLUMN core_complex_data_category.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_complex_data_category.id IS 'The id of this complex Data Category.';


--
-- TOC entry 173 (class 1259 OID 34585)
-- Dependencies: 2572 5
-- Name: core_conceptual_domain; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_conceptual_domain (
    id integer NOT NULL,
    data_type integer DEFAULT 1 NOT NULL
);


--
-- TOC entry 3032 (class 0 OID 0)
-- Dependencies: 173
-- Name: TABLE core_conceptual_domain; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_conceptual_domain IS 'The core data table for conceptual domains.';


--
-- TOC entry 3033 (class 0 OID 0)
-- Dependencies: 173
-- Name: COLUMN core_conceptual_domain.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_conceptual_domain.id IS 'The id of this conceptual domain.';


--
-- TOC entry 3034 (class 0 OID 0)
-- Dependencies: 173
-- Name: COLUMN core_conceptual_domain.data_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_conceptual_domain.data_type IS 'The data type of this conceptual domain.';


--
-- TOC entry 174 (class 1259 OID 34589)
-- Dependencies: 5 173
-- Name: core_conceptual_domain_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3035 (class 0 OID 0)
-- Dependencies: 174
-- Name: core_conceptual_domain_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_conceptual_domain_id_seq OWNED BY core_conceptual_domain.id;


--
-- TOC entry 175 (class 1259 OID 34591)
-- Dependencies: 5
-- Name: core_conceptual_domain_rule; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_conceptual_domain_rule (
    id integer NOT NULL,
    rule_type integer NOT NULL
);


--
-- TOC entry 3036 (class 0 OID 0)
-- Dependencies: 175
-- Name: TABLE core_conceptual_domain_rule; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_conceptual_domain_rule IS 'A constrained conceptual domain consists of rules in a specific rule language.';


--
-- TOC entry 176 (class 1259 OID 34594)
-- Dependencies: 5
-- Name: core_constrained_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_constrained_data_category (
    id integer NOT NULL
);


--
-- TOC entry 3037 (class 0 OID 0)
-- Dependencies: 176
-- Name: TABLE core_constrained_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_constrained_data_category IS 'The core data table for constrained Data Categories.';


--
-- TOC entry 3038 (class 0 OID 0)
-- Dependencies: 176
-- Name: COLUMN core_constrained_data_category.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_constrained_data_category.id IS 'The id of this constained Data Category.';


--
-- TOC entry 177 (class 1259 OID 34597)
-- Dependencies: 5
-- Name: core_constrained_linguistic_section; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_constrained_linguistic_section (
    id integer NOT NULL,
    dc integer NOT NULL
);


--
-- TOC entry 3039 (class 0 OID 0)
-- Dependencies: 177
-- Name: TABLE core_constrained_linguistic_section; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_constrained_linguistic_section IS 'The core data table for the constrained linguistic sections.';


--
-- TOC entry 178 (class 1259 OID 34600)
-- Dependencies: 5
-- Name: core_container_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_container_data_category (
    id integer NOT NULL
);


--
-- TOC entry 179 (class 1259 OID 34603)
-- Dependencies: 2574 2575 2576 2577 2578 2579 2580 2581 613 610 5 640
-- Name: core_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_data_category (
    id integer NOT NULL,
    owner integer NOT NULL,
    administration_status administration_status_enum DEFAULT 'private'::administration_status_enum NOT NULL,
    registration_status registration_status_enum DEFAULT 'private'::registration_status_enum NOT NULL,
    origin character varying,
    effective_date date,
    until_date date,
    identifier character varying NOT NULL,
    version character varying DEFAULT '1:0'::character varying NOT NULL,
    previous integer,
    private boolean DEFAULT true NOT NULL,
    "check" check_result_enum DEFAULT 'unchecked'::check_result_enum NOT NULL,
    justification character varying,
    search tsvector,
    search_language tsvector,
    next integer,
    branch character varying DEFAULT '0'::character varying NOT NULL,
    revision integer DEFAULT 1 NOT NULL,
    sidebranches integer DEFAULT 0 NOT NULL,
    pid character varying,
    name character varying,
    type character varying
);


--
-- TOC entry 3040 (class 0 OID 0)
-- Dependencies: 179
-- Name: TABLE core_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_data_category IS 'The core data table for Data Categories.';


--
-- TOC entry 3041 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.id IS 'The id of this Data Category.';


--
-- TOC entry 3042 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.owner; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.owner IS 'The owner of this Data Category.';


--
-- TOC entry 3043 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.administration_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.administration_status IS 'The administration status of this Data Category.';


--
-- TOC entry 3044 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.registration_status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.registration_status IS 'The registration status of this Data Category.';


--
-- TOC entry 3045 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.origin; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.origin IS 'The origin of this Data Category.';


--
-- TOC entry 3046 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.effective_date; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.effective_date IS 'The date this Data Category will become available to users.';


--
-- TOC entry 3047 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.until_date; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.until_date IS 'The date this Data Category is no longer effective.';


--
-- TOC entry 3048 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.identifier; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.identifier IS 'The human readable identifier of the Data Category.';


--
-- TOC entry 3049 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.version; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.version IS 'The version of the Data Category.';


--
-- TOC entry 3050 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.previous; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.previous IS 'The id of the previous version of this Data Category.';


--
-- TOC entry 3051 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.private; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.private IS 'The private flag of this Data Category.';


--
-- TOC entry 3052 (class 0 OID 0)
-- Dependencies: 179
-- Name: COLUMN core_data_category.justification; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category.justification IS 'The justification for this Data Category.';


--
-- TOC entry 180 (class 1259 OID 34617)
-- Dependencies: 179 5
-- Name: core_data_category_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3053 (class 0 OID 0)
-- Dependencies: 180
-- Name: core_data_category_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_data_category_id_seq OWNED BY core_data_category.id;


--
-- TOC entry 181 (class 1259 OID 34619)
-- Dependencies: 2583 5
-- Name: core_data_category_selection; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_data_category_selection (
    id integer NOT NULL,
    name character varying NOT NULL,
    owner integer NOT NULL,
    parent integer,
    private boolean DEFAULT true NOT NULL
);


--
-- TOC entry 3054 (class 0 OID 0)
-- Dependencies: 181
-- Name: TABLE core_data_category_selection; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_data_category_selection IS 'The core data table for Data Category Selections.';


--
-- TOC entry 3055 (class 0 OID 0)
-- Dependencies: 181
-- Name: COLUMN core_data_category_selection.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category_selection.id IS 'The id of this Data Category Selection.';


--
-- TOC entry 3056 (class 0 OID 0)
-- Dependencies: 181
-- Name: COLUMN core_data_category_selection.name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category_selection.name IS 'The name of this Data Category Selection.';


--
-- TOC entry 3057 (class 0 OID 0)
-- Dependencies: 181
-- Name: COLUMN core_data_category_selection.owner; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category_selection.owner IS 'The owner of this Data Category Selection.';


--
-- TOC entry 3058 (class 0 OID 0)
-- Dependencies: 181
-- Name: COLUMN core_data_category_selection.parent; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category_selection.parent IS 'The parent Data Category Selection of this Data Category Selection.';


--
-- TOC entry 3059 (class 0 OID 0)
-- Dependencies: 181
-- Name: COLUMN core_data_category_selection.private; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_category_selection.private IS 'The private flag of this Data Category Selection.';


--
-- TOC entry 182 (class 1259 OID 34626)
-- Dependencies: 5 181
-- Name: core_data_category_selection_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3060 (class 0 OID 0)
-- Dependencies: 182
-- Name: core_data_category_selection_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_data_category_selection_id_seq OWNED BY core_data_category_selection.id;


--
-- TOC entry 183 (class 1259 OID 34628)
-- Dependencies: 5
-- Name: core_data_type; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_data_type (
    id integer NOT NULL,
    data_type character varying NOT NULL,
    super integer
);


--
-- TOC entry 3061 (class 0 OID 0)
-- Dependencies: 183
-- Name: TABLE core_data_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_data_type IS 'The core data table for data types.';


--
-- TOC entry 3062 (class 0 OID 0)
-- Dependencies: 183
-- Name: COLUMN core_data_type.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_type.id IS 'The id of this data type.';


--
-- TOC entry 3063 (class 0 OID 0)
-- Dependencies: 183
-- Name: COLUMN core_data_type.data_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_type.data_type IS 'The data type.';


--
-- TOC entry 3064 (class 0 OID 0)
-- Dependencies: 183
-- Name: COLUMN core_data_type.super; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_data_type.super IS 'The super data type of this data type.';


--
-- TOC entry 184 (class 1259 OID 34634)
-- Dependencies: 183 5
-- Name: core_data_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3065 (class 0 OID 0)
-- Dependencies: 184
-- Name: core_data_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_data_type_id_seq OWNED BY core_data_type.id;


--
-- TOC entry 185 (class 1259 OID 34636)
-- Dependencies: 2586 5 640 610
-- Name: core_dc_status_log; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_dc_status_log (
    id integer NOT NULL,
    dc integer NOT NULL,
    administration_status administration_status_enum NOT NULL,
    registration_status registration_status_enum NOT NULL,
    comment character varying,
    "user" integer,
    "timestamp" timestamp with time zone DEFAULT '2010-07-05 13:11:02.959+02'::timestamp with time zone NOT NULL
);


--
-- TOC entry 186 (class 1259 OID 34643)
-- Dependencies: 2588 5
-- Name: core_dcr_board; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_dcr_board (
    id integer NOT NULL,
    name character varying DEFAULT 'DCR Board'::character varying NOT NULL,
    description character varying
);


--
-- TOC entry 187 (class 1259 OID 34650)
-- Dependencies: 5
-- Name: core_decision_group; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_decision_group (
    id integer NOT NULL,
    owner integer NOT NULL,
    decision_date date,
    dc integer NOT NULL
);


--
-- TOC entry 3066 (class 0 OID 0)
-- Dependencies: 187
-- Name: TABLE core_decision_group; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_decision_group IS 'The core data table for Decision Groups.';


--
-- TOC entry 3067 (class 0 OID 0)
-- Dependencies: 187
-- Name: COLUMN core_decision_group.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_decision_group.id IS 'The id of this Decision Group.';


--
-- TOC entry 3068 (class 0 OID 0)
-- Dependencies: 187
-- Name: COLUMN core_decision_group.owner; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_decision_group.owner IS 'The owner of this Descision Group.';


--
-- TOC entry 3069 (class 0 OID 0)
-- Dependencies: 187
-- Name: COLUMN core_decision_group.decision_date; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_decision_group.decision_date IS 'The date this Decision Group reached a decision.';


--
-- TOC entry 3070 (class 0 OID 0)
-- Dependencies: 187
-- Name: COLUMN core_decision_group.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_decision_group.dc IS 'The Data Category this Decision Group decides upon.';


--
-- TOC entry 188 (class 1259 OID 34653)
-- Dependencies: 2589 5
-- Name: core_group; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_group (
    id integer NOT NULL,
    forum_public integer,
    forum_private integer,
    forum_group integer,
    sync boolean DEFAULT true NOT NULL
);


--
-- TOC entry 189 (class 1259 OID 34657)
-- Dependencies: 2590 2591 5
-- Name: core_language; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_language (
    id integer NOT NULL,
    name character varying NOT NULL,
    tag character varying,
    search character varying DEFAULT 'simple'::character varying NOT NULL,
    direction character varying DEFAULT 'ltr'::character varying NOT NULL,
    tags character varying
);


--
-- TOC entry 3071 (class 0 OID 0)
-- Dependencies: 189
-- Name: TABLE core_language; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_language IS 'The core data table for languages.';


--
-- TOC entry 3072 (class 0 OID 0)
-- Dependencies: 189
-- Name: COLUMN core_language.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_language.id IS 'The id of this language.';


--
-- TOC entry 3073 (class 0 OID 0)
-- Dependencies: 189
-- Name: COLUMN core_language.name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_language.name IS 'The full name of this language.';


--
-- TOC entry 3074 (class 0 OID 0)
-- Dependencies: 189
-- Name: COLUMN core_language.tag; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_language.tag IS 'The tag for this language as used by the xml:lang attribute (see IETF RFC 3066).';


--
-- TOC entry 190 (class 1259 OID 34665)
-- Dependencies: 5 189
-- Name: core_language_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3075 (class 0 OID 0)
-- Dependencies: 190
-- Name: core_language_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_language_id_seq OWNED BY core_language.id;


--
-- TOC entry 191 (class 1259 OID 34667)
-- Dependencies: 2593 5
-- Name: core_language_section; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_language_section (
    id integer NOT NULL,
    dc integer NOT NULL,
    language integer DEFAULT 1 NOT NULL
);


--
-- TOC entry 3076 (class 0 OID 0)
-- Dependencies: 191
-- Name: TABLE core_language_section; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_language_section IS 'The core data table for language sections.';


--
-- TOC entry 3077 (class 0 OID 0)
-- Dependencies: 191
-- Name: COLUMN core_language_section.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_language_section.id IS 'The id of the language section.';


--
-- TOC entry 3078 (class 0 OID 0)
-- Dependencies: 191
-- Name: COLUMN core_language_section.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_language_section.dc IS 'The Data Category of this language section.';


--
-- TOC entry 3079 (class 0 OID 0)
-- Dependencies: 191
-- Name: COLUMN core_language_section.language; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_language_section.language IS 'The language of this language section.';


--
-- TOC entry 192 (class 1259 OID 34671)
-- Dependencies: 5 191
-- Name: core_language_section_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3080 (class 0 OID 0)
-- Dependencies: 192
-- Name: core_language_section_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_language_section_id_seq OWNED BY core_language_section.id;


--
-- TOC entry 193 (class 1259 OID 34673)
-- Dependencies: 2595 5
-- Name: core_linguistic_section; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_linguistic_section (
    id integer NOT NULL,
    language integer DEFAULT 1 NOT NULL
);


--
-- TOC entry 3081 (class 0 OID 0)
-- Dependencies: 193
-- Name: TABLE core_linguistic_section; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_linguistic_section IS 'The core data table for linguistic sections.';


--
-- TOC entry 3082 (class 0 OID 0)
-- Dependencies: 193
-- Name: COLUMN core_linguistic_section.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_linguistic_section.id IS 'The id of this linguistic section.';


--
-- TOC entry 3083 (class 0 OID 0)
-- Dependencies: 193
-- Name: COLUMN core_linguistic_section.language; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_linguistic_section.language IS 'The language of this linguistic section.';


--
-- TOC entry 194 (class 1259 OID 34677)
-- Dependencies: 5 193
-- Name: core_linguistic_section_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3084 (class 0 OID 0)
-- Dependencies: 194
-- Name: core_linguistic_section_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_linguistic_section_id_seq OWNED BY core_linguistic_section.id;


--
-- TOC entry 195 (class 1259 OID 34679)
-- Dependencies: 2597 2598 2599 2600 625 5 628
-- Name: core_message; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_message (
    id integer NOT NULL,
    "from" integer NOT NULL,
    "to" integer,
    message character varying NOT NULL,
    created timestamp with time zone DEFAULT ('now'::text)::timestamp with time zone NOT NULL,
    read timestamp with time zone,
    status message_status_enum DEFAULT 'valid'::message_status_enum NOT NULL,
    type message_type_enum DEFAULT 'message'::message_type_enum NOT NULL,
    subject character varying DEFAULT '(no subject)'::character varying NOT NULL,
    action character varying,
    token character varying
);


--
-- TOC entry 196 (class 1259 OID 34689)
-- Dependencies: 5 195
-- Name: core_message_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3085 (class 0 OID 0)
-- Dependencies: 196
-- Name: core_message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_message_id_seq OWNED BY core_message.id;


--
-- TOC entry 197 (class 1259 OID 34691)
-- Dependencies: 5
-- Name: core_open_conceptual_domain; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_open_conceptual_domain (
    id integer NOT NULL
);


--
-- TOC entry 3086 (class 0 OID 0)
-- Dependencies: 197
-- Name: TABLE core_open_conceptual_domain; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_open_conceptual_domain IS 'The core data table for open conceptual domains.';


--
-- TOC entry 198 (class 1259 OID 34694)
-- Dependencies: 5
-- Name: core_open_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_open_data_category (
    id integer NOT NULL
);


--
-- TOC entry 3087 (class 0 OID 0)
-- Dependencies: 198
-- Name: TABLE core_open_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_open_data_category IS 'The core data table for open Data Categories.';


--
-- TOC entry 199 (class 1259 OID 34697)
-- Dependencies: 5
-- Name: core_owner; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_owner (
    id integer NOT NULL
);


--
-- TOC entry 3088 (class 0 OID 0)
-- Dependencies: 199
-- Name: TABLE core_owner; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_owner IS 'The core data table for owners.';


--
-- TOC entry 3089 (class 0 OID 0)
-- Dependencies: 199
-- Name: COLUMN core_owner.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_owner.id IS 'The id of this owner.';


--
-- TOC entry 200 (class 1259 OID 34700)
-- Dependencies: 5
-- Name: core_profile; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_profile (
    id integer NOT NULL,
    name character varying NOT NULL,
    tdg integer,
    parent integer,
    "order" integer
);


--
-- TOC entry 3090 (class 0 OID 0)
-- Dependencies: 200
-- Name: TABLE core_profile; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_profile IS 'The core data table for profiles.';


--
-- TOC entry 3091 (class 0 OID 0)
-- Dependencies: 200
-- Name: COLUMN core_profile.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_profile.id IS 'The id of this profile.';


--
-- TOC entry 3092 (class 0 OID 0)
-- Dependencies: 200
-- Name: COLUMN core_profile.name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_profile.name IS 'The name of this profile.';


--
-- TOC entry 3093 (class 0 OID 0)
-- Dependencies: 200
-- Name: COLUMN core_profile.tdg; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_profile.tdg IS 'The Thematic Domain Group this profile belongs to.';


--
-- TOC entry 3094 (class 0 OID 0)
-- Dependencies: 200
-- Name: COLUMN core_profile.parent; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_profile.parent IS 'The parent profile of this profile.';


--
-- TOC entry 201 (class 1259 OID 34706)
-- Dependencies: 5 200
-- Name: core_profile_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3095 (class 0 OID 0)
-- Dependencies: 201
-- Name: core_profile_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_profile_id_seq OWNED BY core_profile.id;


--
-- TOC entry 202 (class 1259 OID 34708)
-- Dependencies: 5
-- Name: core_profile_value_domain; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_profile_value_domain (
    id integer NOT NULL,
    profile integer NOT NULL
);


--
-- TOC entry 3096 (class 0 OID 0)
-- Dependencies: 202
-- Name: TABLE core_profile_value_domain; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_profile_value_domain IS 'The core data table for profile value domains.';


--
-- TOC entry 3097 (class 0 OID 0)
-- Dependencies: 202
-- Name: COLUMN core_profile_value_domain.profile; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_profile_value_domain.profile IS 'The profile of this profile value domain.';


--
-- TOC entry 261 (class 1259 OID 57344)
-- Dependencies: 5
-- Name: core_recommendation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_recommendation (
    dc integer NOT NULL,
    "group" integer NOT NULL
);


--
-- TOC entry 203 (class 1259 OID 34711)
-- Dependencies: 5
-- Name: core_registration_authority; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_registration_authority (
    id integer NOT NULL,
    registration_authority character varying NOT NULL
);


--
-- TOC entry 3098 (class 0 OID 0)
-- Dependencies: 203
-- Name: TABLE core_registration_authority; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_registration_authority IS 'The core data table for registration authorities.';


--
-- TOC entry 3099 (class 0 OID 0)
-- Dependencies: 203
-- Name: COLUMN core_registration_authority.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_registration_authority.id IS 'The id of the registration authority.';


--
-- TOC entry 3100 (class 0 OID 0)
-- Dependencies: 203
-- Name: COLUMN core_registration_authority.registration_authority; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_registration_authority.registration_authority IS 'The name of the registration authority.';


--
-- TOC entry 204 (class 1259 OID 34717)
-- Dependencies: 203 5
-- Name: core_registration_authority_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3101 (class 0 OID 0)
-- Dependencies: 204
-- Name: core_registration_authority_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_registration_authority_id_seq OWNED BY core_registration_authority.id;


--
-- TOC entry 205 (class 1259 OID 34719)
-- Dependencies: 2604 5
-- Name: core_registration_group; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_registration_group (
    id integer NOT NULL,
    dc integer NOT NULL,
    registration_authority integer DEFAULT 1 NOT NULL
);


--
-- TOC entry 3102 (class 0 OID 0)
-- Dependencies: 205
-- Name: TABLE core_registration_group; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_registration_group IS 'The core data table for Registration Groups.';


--
-- TOC entry 3103 (class 0 OID 0)
-- Dependencies: 205
-- Name: COLUMN core_registration_group.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_registration_group.id IS 'The id of this Registration Group.';


--
-- TOC entry 3104 (class 0 OID 0)
-- Dependencies: 205
-- Name: COLUMN core_registration_group.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_registration_group.dc IS 'The Data Category this Registration Group registers.';


--
-- TOC entry 3105 (class 0 OID 0)
-- Dependencies: 205
-- Name: COLUMN core_registration_group.registration_authority; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_registration_group.registration_authority IS 'The Registration Authority of this registration group.';


--
-- TOC entry 206 (class 1259 OID 34723)
-- Dependencies: 5
-- Name: core_rule; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_rule (
    id integer NOT NULL,
    rule character varying NOT NULL,
    cd integer NOT NULL
);


--
-- TOC entry 3106 (class 0 OID 0)
-- Dependencies: 206
-- Name: TABLE core_rule; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_rule IS 'The rules in the constrained conceptual domains.';


--
-- TOC entry 207 (class 1259 OID 34729)
-- Dependencies: 206 5
-- Name: core_rule_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3107 (class 0 OID 0)
-- Dependencies: 207
-- Name: core_rule_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_rule_id_seq OWNED BY core_rule.id;


--
-- TOC entry 208 (class 1259 OID 34731)
-- Dependencies: 5
-- Name: core_rule_type; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_rule_type (
    id integer NOT NULL,
    rule_type character varying NOT NULL,
    xml boolean
);


--
-- TOC entry 209 (class 1259 OID 34737)
-- Dependencies: 208 5
-- Name: core_rule_type_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3108 (class 0 OID 0)
-- Dependencies: 209
-- Name: core_rule_type_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_rule_type_id_seq OWNED BY core_rule_type.id;


--
-- TOC entry 210 (class 1259 OID 34739)
-- Dependencies: 5
-- Name: core_selected_complex_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_selected_complex_data_category (
    id integer NOT NULL,
    dc integer NOT NULL
);


--
-- TOC entry 3109 (class 0 OID 0)
-- Dependencies: 210
-- Name: TABLE core_selected_complex_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_selected_complex_data_category IS 'The core data table for selected complex Data Categories.';


--
-- TOC entry 211 (class 1259 OID 34742)
-- Dependencies: 5
-- Name: core_selected_container_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_selected_container_data_category (
    id integer NOT NULL,
    dc integer NOT NULL
);


--
-- TOC entry 212 (class 1259 OID 34745)
-- Dependencies: 5
-- Name: core_selected_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_selected_data_category (
    id integer NOT NULL,
    dcs integer NOT NULL
);


--
-- TOC entry 3110 (class 0 OID 0)
-- Dependencies: 212
-- Name: TABLE core_selected_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_selected_data_category IS 'The core data table for selected Data Categories.';


--
-- TOC entry 3111 (class 0 OID 0)
-- Dependencies: 212
-- Name: COLUMN core_selected_data_category.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_selected_data_category.id IS 'The id of this selected Data Category.';


--
-- TOC entry 3112 (class 0 OID 0)
-- Dependencies: 212
-- Name: COLUMN core_selected_data_category.dcs; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_selected_data_category.dcs IS 'The Data Category Selection this Data Category belongs to.';


--
-- TOC entry 213 (class 1259 OID 34748)
-- Dependencies: 212 5
-- Name: core_selected_data_category_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3113 (class 0 OID 0)
-- Dependencies: 213
-- Name: core_selected_data_category_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_selected_data_category_id_seq OWNED BY core_selected_data_category.id;


--
-- TOC entry 214 (class 1259 OID 34750)
-- Dependencies: 5
-- Name: core_selected_simple_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_selected_simple_data_category (
    id integer NOT NULL,
    dc integer NOT NULL
);


--
-- TOC entry 3114 (class 0 OID 0)
-- Dependencies: 214
-- Name: TABLE core_selected_simple_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_selected_simple_data_category IS 'The core data table for selected simple Data Categories.';


--
-- TOC entry 215 (class 1259 OID 34753)
-- Dependencies: 2608 5
-- Name: core_session; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_session (
    id integer NOT NULL,
    "user" integer NOT NULL,
    first_access timestamp with time zone DEFAULT ('now'::text)::timestamp with time zone NOT NULL,
    last_access timestamp with time zone
);


--
-- TOC entry 216 (class 1259 OID 34757)
-- Dependencies: 5 215
-- Name: core_session_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3115 (class 0 OID 0)
-- Dependencies: 216
-- Name: core_session_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_session_id_seq OWNED BY core_session.id;


--
-- TOC entry 217 (class 1259 OID 34759)
-- Dependencies: 5
-- Name: core_simple_data_category; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_simple_data_category (
    id integer NOT NULL
);


--
-- TOC entry 3116 (class 0 OID 0)
-- Dependencies: 217
-- Name: TABLE core_simple_data_category; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_simple_data_category IS 'The core data table for simple Data Categories.';


--
-- TOC entry 218 (class 1259 OID 34762)
-- Dependencies: 5 185
-- Name: core_status_log_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3117 (class 0 OID 0)
-- Dependencies: 218
-- Name: core_status_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE core_status_log_id_seq OWNED BY core_dc_status_log.id;


--
-- TOC entry 219 (class 1259 OID 34764)
-- Dependencies: 5
-- Name: core_submission_group; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_submission_group (
    id integer NOT NULL,
    dc integer NOT NULL,
    owner integer NOT NULL,
    submission_date date
);


--
-- TOC entry 3118 (class 0 OID 0)
-- Dependencies: 219
-- Name: TABLE core_submission_group; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_submission_group IS 'The core data table for Submission Groups.';


--
-- TOC entry 3119 (class 0 OID 0)
-- Dependencies: 219
-- Name: COLUMN core_submission_group.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_submission_group.id IS 'The id of this Submission Group.';


--
-- TOC entry 3120 (class 0 OID 0)
-- Dependencies: 219
-- Name: COLUMN core_submission_group.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_submission_group.dc IS 'The Data Category this Submission Group submitted.';


--
-- TOC entry 3121 (class 0 OID 0)
-- Dependencies: 219
-- Name: COLUMN core_submission_group.owner; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_submission_group.owner IS 'The owner of this Submission Group.';


--
-- TOC entry 3122 (class 0 OID 0)
-- Dependencies: 219
-- Name: COLUMN core_submission_group.submission_date; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_submission_group.submission_date IS 'The date this Submission Group submitted the Data Category.';


--
-- TOC entry 220 (class 1259 OID 34767)
-- Dependencies: 5
-- Name: core_thematic_domain_group; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_thematic_domain_group (
    id integer NOT NULL,
    name character varying NOT NULL,
    description character varying,
    "order" integer NOT NULL,
    status character varying,
    activity character varying
);


--
-- TOC entry 3123 (class 0 OID 0)
-- Dependencies: 220
-- Name: TABLE core_thematic_domain_group; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_thematic_domain_group IS 'The core data table for Thematic Domain Groups.';


--
-- TOC entry 3124 (class 0 OID 0)
-- Dependencies: 220
-- Name: COLUMN core_thematic_domain_group.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_thematic_domain_group.id IS 'The id of this Thematic Domain Group.';


--
-- TOC entry 3125 (class 0 OID 0)
-- Dependencies: 220
-- Name: COLUMN core_thematic_domain_group.name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_thematic_domain_group.name IS 'The name of this Thematic Domain Group.';


--
-- TOC entry 221 (class 1259 OID 34773)
-- Dependencies: 2610 2611 2612 2613 646 5
-- Name: core_user; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_user (
    id integer NOT NULL,
    login character varying NOT NULL,
    last_name character varying,
    email character varying NOT NULL,
    organization character varying,
    phone character varying,
    post character varying,
    access_count integer DEFAULT 0 NOT NULL,
    first_access date,
    last_access date,
    password character varying NOT NULL,
    type user_type_enum DEFAULT 'basic'::user_type_enum NOT NULL,
    first_name character varying,
    disclaimer boolean DEFAULT false NOT NULL,
    sync boolean DEFAULT true NOT NULL,
    forum integer,
    shib_principal character varying
);


--
-- TOC entry 3126 (class 0 OID 0)
-- Dependencies: 221
-- Name: TABLE core_user; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_user IS 'The core data table for users.';


--
-- TOC entry 3127 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.login; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.login IS 'The login of this user.';


--
-- TOC entry 3128 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.last_name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.last_name IS 'The last name of this user.';


--
-- TOC entry 3129 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.email; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.email IS 'The email address of this user.';


--
-- TOC entry 3130 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.organization; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.organization IS 'The organization this user is a member of.';


--
-- TOC entry 3131 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.phone; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.phone IS 'The phone number of this user.';


--
-- TOC entry 3132 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.post; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.post IS 'The postal address of this user.';


--
-- TOC entry 3133 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.access_count; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.access_count IS 'The access count of this user.';


--
-- TOC entry 3134 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.first_access; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.first_access IS 'The date of the first access of this user.';


--
-- TOC entry 3135 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.last_access; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.last_access IS 'The date of the last access of this user.';


--
-- TOC entry 3136 (class 0 OID 0)
-- Dependencies: 221
-- Name: COLUMN core_user.password; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN core_user.password IS 'The password of this user.';


--
-- TOC entry 222 (class 1259 OID 34783)
-- Dependencies: 5
-- Name: core_value_domain; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE core_value_domain (
    id integer NOT NULL
);


--
-- TOC entry 3137 (class 0 OID 0)
-- Dependencies: 222
-- Name: TABLE core_value_domain; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE core_value_domain IS 'The core data table for value domains.';


--
-- TOC entry 223 (class 1259 OID 34786)
-- Dependencies: 2614 616 5
-- Name: generic_lock; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE generic_lock (
    id integer NOT NULL,
    session integer NOT NULL,
    type lock_type_enum NOT NULL,
    lock integer NOT NULL,
    first_access timestamp with time zone DEFAULT ('now'::text)::timestamp with time zone NOT NULL,
    last_access timestamp with time zone
);


--
-- TOC entry 224 (class 1259 OID 34790)
-- Dependencies: 5 223
-- Name: generic_lock_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3138 (class 0 OID 0)
-- Dependencies: 224
-- Name: generic_lock_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE generic_lock_id_seq OWNED BY generic_lock.id;


--
-- TOC entry 225 (class 1259 OID 34792)
-- Dependencies: 2616 5 637 634 631
-- Name: generic_name; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE generic_name (
    id integer NOT NULL,
    owner integer NOT NULL,
    name_type name_type_enum NOT NULL,
    source character varying,
    status name_status_enum,
    name character varying NOT NULL,
    owner_type owner_type_enum NOT NULL,
    search tsvector,
    search_language tsvector,
    language integer DEFAULT 1 NOT NULL
);


--
-- TOC entry 3139 (class 0 OID 0)
-- Dependencies: 225
-- Name: TABLE generic_name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE generic_name IS 'The generic data table for names.';


--
-- TOC entry 3140 (class 0 OID 0)
-- Dependencies: 225
-- Name: COLUMN generic_name.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_name.id IS 'The id of this name.';


--
-- TOC entry 3141 (class 0 OID 0)
-- Dependencies: 225
-- Name: COLUMN generic_name.owner; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_name.owner IS 'The owner of this name.';


--
-- TOC entry 3142 (class 0 OID 0)
-- Dependencies: 225
-- Name: COLUMN generic_name.name_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_name.name_type IS 'The type of this name.';


--
-- TOC entry 3143 (class 0 OID 0)
-- Dependencies: 225
-- Name: COLUMN generic_name.source; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_name.source IS 'The source of this name.';


--
-- TOC entry 3144 (class 0 OID 0)
-- Dependencies: 225
-- Name: COLUMN generic_name.status; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_name.status IS 'The status of this name.';


--
-- TOC entry 3145 (class 0 OID 0)
-- Dependencies: 225
-- Name: COLUMN generic_name.name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_name.name IS 'The actual name.';


--
-- TOC entry 226 (class 1259 OID 34799)
-- Dependencies: 225 5
-- Name: generic_name_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3146 (class 0 OID 0)
-- Dependencies: 226
-- Name: generic_name_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE generic_name_id_seq OWNED BY generic_name.id;


--
-- TOC entry 227 (class 1259 OID 34801)
-- Dependencies: 2618 2619 2620 2621 643 5 637
-- Name: generic_text; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE generic_text (
    id integer NOT NULL,
    owner integer NOT NULL,
    owner_type owner_type_enum NOT NULL,
    language integer DEFAULT 1 NOT NULL,
    date date DEFAULT ('now'::text)::date NOT NULL,
    source character varying,
    text character varying NOT NULL,
    text_type text_type_enum DEFAULT 'text'::text_type_enum NOT NULL,
    "user" integer,
    "timestamp" timestamp with time zone DEFAULT ('now'::text)::timestamp with time zone NOT NULL,
    search tsvector,
    search_language tsvector
);


--
-- TOC entry 3147 (class 0 OID 0)
-- Dependencies: 227
-- Name: TABLE generic_text; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE generic_text IS 'The generic data table for texts.';


--
-- TOC entry 3148 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text.id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text.id IS 'The id of this text.';


--
-- TOC entry 3149 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text.owner; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text.owner IS 'The owner of this text.';


--
-- TOC entry 3150 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text.owner_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text.owner_type IS 'The type of the owner.';


--
-- TOC entry 3151 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text.language; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text.language IS 'The language used by this text.';


--
-- TOC entry 3152 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text.date; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text.date IS 'When was this text entered.';


--
-- TOC entry 3153 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text.source; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text.source IS 'The source of this text.';


--
-- TOC entry 3154 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text.text; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text.text IS 'The actual text.';


--
-- TOC entry 3155 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text.text_type; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text.text_type IS 'The type of this text.';


--
-- TOC entry 3156 (class 0 OID 0)
-- Dependencies: 227
-- Name: COLUMN generic_text."user"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN generic_text."user" IS 'The user who wrote this text.';


--
-- TOC entry 228 (class 1259 OID 34811)
-- Dependencies: 5 227
-- Name: generic_text_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- TOC entry 3157 (class 0 OID 0)
-- Dependencies: 228
-- Name: generic_text_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE generic_text_id_seq OWNED BY generic_text.id;


--
-- TOC entry 229 (class 1259 OID 34813)
-- Dependencies: 5
-- Name: link_closed_data_category_conceptual_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_closed_data_category_conceptual_domains (
    dc integer NOT NULL,
    cd integer NOT NULL
);


--
-- TOC entry 3158 (class 0 OID 0)
-- Dependencies: 229
-- Name: TABLE link_closed_data_category_conceptual_domains; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_closed_data_category_conceptual_domains IS 'The link table between closed Data Categories and profile value domains.';


--
-- TOC entry 3159 (class 0 OID 0)
-- Dependencies: 229
-- Name: COLUMN link_closed_data_category_conceptual_domains.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_closed_data_category_conceptual_domains.dc IS 'The closed Data Category.';


--
-- TOC entry 3160 (class 0 OID 0)
-- Dependencies: 229
-- Name: COLUMN link_closed_data_category_conceptual_domains.cd; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_closed_data_category_conceptual_domains.cd IS 'The profile value domain.';


--
-- TOC entry 230 (class 1259 OID 34816)
-- Dependencies: 5
-- Name: link_constrained_data_category_conceptual_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_constrained_data_category_conceptual_domains (
    dc integer NOT NULL,
    cd integer NOT NULL
);


--
-- TOC entry 3161 (class 0 OID 0)
-- Dependencies: 230
-- Name: TABLE link_constrained_data_category_conceptual_domains; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_constrained_data_category_conceptual_domains IS 'The link table between constrained Data Categories and schema specific domains.';


--
-- TOC entry 3162 (class 0 OID 0)
-- Dependencies: 230
-- Name: COLUMN link_constrained_data_category_conceptual_domains.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_constrained_data_category_conceptual_domains.dc IS 'The constrained Data Category.';


--
-- TOC entry 3163 (class 0 OID 0)
-- Dependencies: 230
-- Name: COLUMN link_constrained_data_category_conceptual_domains.cd; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_constrained_data_category_conceptual_domains.cd IS 'The Schema Specifc Domain.';


--
-- TOC entry 231 (class 1259 OID 34819)
-- Dependencies: 5
-- Name: link_constrained_linguistic_section_conceptual_domains; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_constrained_linguistic_section_conceptual_domains (
    ls integer NOT NULL,
    cd integer NOT NULL
);


--
-- TOC entry 232 (class 1259 OID 34822)
-- Dependencies: 5
-- Name: link_data_category_selection_users; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_data_category_selection_users (
    dcs integer NOT NULL,
    "user" integer NOT NULL
);


--
-- TOC entry 3164 (class 0 OID 0)
-- Dependencies: 232
-- Name: TABLE link_data_category_selection_users; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_data_category_selection_users IS 'The link table between Data Category Selection and its users.';


--
-- TOC entry 3165 (class 0 OID 0)
-- Dependencies: 232
-- Name: COLUMN link_data_category_selection_users.dcs; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_data_category_selection_users.dcs IS 'The Data Category Selection.';


--
-- TOC entry 3166 (class 0 OID 0)
-- Dependencies: 232
-- Name: COLUMN link_data_category_selection_users."user"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_data_category_selection_users."user" IS 'The user.';


--
-- TOC entry 233 (class 1259 OID 34825)
-- Dependencies: 2623 5 607
-- Name: link_dc_access; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_dc_access (
    dc integer NOT NULL,
    account integer NOT NULL,
    rights access_rights_enum DEFAULT 'r'::access_rights_enum NOT NULL
);


--
-- TOC entry 234 (class 1259 OID 34829)
-- Dependencies: 2624 2625 5 607 607
-- Name: link_dcs_access; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_dcs_access (
    dcs integer NOT NULL,
    account integer NOT NULL,
    rights access_rights_enum DEFAULT 'r'::access_rights_enum NOT NULL,
    propagate access_rights_enum DEFAULT 'r'::access_rights_enum NOT NULL
);


--
-- TOC entry 235 (class 1259 OID 34834)
-- Dependencies: 2626 2627 622 5 619
-- Name: link_group_members; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_group_members (
    "group" integer NOT NULL,
    member integer NOT NULL,
    role member_type_enum DEFAULT 'member'::member_type_enum NOT NULL,
    status member_status_enum DEFAULT 'invite'::member_status_enum NOT NULL
);


--
-- TOC entry 236 (class 1259 OID 34839)
-- Dependencies: 5
-- Name: link_open_data_category_conceptual_domain; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_open_data_category_conceptual_domain (
    dc integer NOT NULL,
    cd integer NOT NULL
);


--
-- TOC entry 3167 (class 0 OID 0)
-- Dependencies: 236
-- Name: TABLE link_open_data_category_conceptual_domain; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_open_data_category_conceptual_domain IS 'The link table between open Data Categories and a open conceptual domain.';


--
-- TOC entry 3168 (class 0 OID 0)
-- Dependencies: 236
-- Name: COLUMN link_open_data_category_conceptual_domain.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_open_data_category_conceptual_domain.dc IS 'The open data category.';


--
-- TOC entry 3169 (class 0 OID 0)
-- Dependencies: 236
-- Name: COLUMN link_open_data_category_conceptual_domain.cd; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_open_data_category_conceptual_domain.cd IS 'The open conceptual domain.';


--
-- TOC entry 237 (class 1259 OID 34842)
-- Dependencies: 5
-- Name: link_profile_members; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_profile_members (
    profile integer NOT NULL,
    dc integer NOT NULL
);


--
-- TOC entry 3170 (class 0 OID 0)
-- Dependencies: 237
-- Name: TABLE link_profile_members; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_profile_members IS 'The link table between Profile and Data Category.';


--
-- TOC entry 3171 (class 0 OID 0)
-- Dependencies: 237
-- Name: COLUMN link_profile_members.profile; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_profile_members.profile IS 'The profile of this Data Category.';


--
-- TOC entry 3172 (class 0 OID 0)
-- Dependencies: 237
-- Name: COLUMN link_profile_members.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_profile_members.dc IS 'The Data Category which is a member of this profile.';


--
-- TOC entry 238 (class 1259 OID 34845)
-- Dependencies: 5
-- Name: link_selected_data_category_picklist; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_selected_data_category_picklist (
    cdc integer NOT NULL,
    sdc integer NOT NULL
);


--
-- TOC entry 3173 (class 0 OID 0)
-- Dependencies: 238
-- Name: TABLE link_selected_data_category_picklist; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_selected_data_category_picklist IS 'The link table between selected complex Data Categories and the selected simple Data Categories in its picklist.';


--
-- TOC entry 3174 (class 0 OID 0)
-- Dependencies: 238
-- Name: COLUMN link_selected_data_category_picklist.cdc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_selected_data_category_picklist.cdc IS 'The selected complex Data Category.';


--
-- TOC entry 3175 (class 0 OID 0)
-- Dependencies: 238
-- Name: COLUMN link_selected_data_category_picklist.sdc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_selected_data_category_picklist.sdc IS 'The selected simple Data Category.';


--
-- TOC entry 239 (class 1259 OID 34848)
-- Dependencies: 5
-- Name: link_selected_data_category_profiles; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_selected_data_category_profiles (
    dc integer NOT NULL,
    profile integer NOT NULL
);


--
-- TOC entry 3176 (class 0 OID 0)
-- Dependencies: 239
-- Name: TABLE link_selected_data_category_profiles; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_selected_data_category_profiles IS 'The link table between selected Data Categories and profiles.';


--
-- TOC entry 3177 (class 0 OID 0)
-- Dependencies: 239
-- Name: COLUMN link_selected_data_category_profiles.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_selected_data_category_profiles.dc IS 'The selected Data Category.';


--
-- TOC entry 3178 (class 0 OID 0)
-- Dependencies: 239
-- Name: COLUMN link_selected_data_category_profiles.profile; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_selected_data_category_profiles.profile IS 'The profile.';


--
-- TOC entry 240 (class 1259 OID 34851)
-- Dependencies: 5
-- Name: link_simple_data_category_super; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_simple_data_category_super (
    dc integer NOT NULL,
    super integer NOT NULL
);


--
-- TOC entry 3179 (class 0 OID 0)
-- Dependencies: 240
-- Name: TABLE link_simple_data_category_super; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_simple_data_category_super IS 'The link table between simple Data Category and a more generic simple Data Category.';


--
-- TOC entry 3180 (class 0 OID 0)
-- Dependencies: 240
-- Name: COLUMN link_simple_data_category_super.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_simple_data_category_super.dc IS 'The simple Data Category.';


--
-- TOC entry 3181 (class 0 OID 0)
-- Dependencies: 240
-- Name: COLUMN link_simple_data_category_super.super; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_simple_data_category_super.super IS 'The more generic simple Data Category.';


--
-- TOC entry 241 (class 1259 OID 34854)
-- Dependencies: 5
-- Name: link_value_domain_values; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE link_value_domain_values (
    cd integer NOT NULL,
    dc integer NOT NULL
);


--
-- TOC entry 3182 (class 0 OID 0)
-- Dependencies: 241
-- Name: TABLE link_value_domain_values; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE link_value_domain_values IS 'The link table between Value Domain and the simple Data Categories which are its values.';


--
-- TOC entry 3183 (class 0 OID 0)
-- Dependencies: 241
-- Name: COLUMN link_value_domain_values.cd; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_value_domain_values.cd IS 'The value domain.';


--
-- TOC entry 3184 (class 0 OID 0)
-- Dependencies: 241
-- Name: COLUMN link_value_domain_values.dc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN link_value_domain_values.dc IS 'The simple Data Category.';


--
-- TOC entry 242 (class 1259 OID 34857)
-- Dependencies: 2548 5
-- Name: view_cd_type; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_cd_type AS
    SELECT core_conceptual_domain.id, cd_type.type FROM (core_conceptual_domain JOIN ((SELECT core_open_conceptual_domain.id, 'open'::text AS type FROM core_open_conceptual_domain UNION SELECT core_conceptual_domain_rule.id, 'constrained'::text AS type FROM core_conceptual_domain_rule) UNION SELECT core_value_domain.id, 'closed'::text AS type FROM core_value_domain) cd_type ON ((cd_type.id = core_conceptual_domain.id)));


--
-- TOC entry 243 (class 1259 OID 34861)
-- Dependencies: 2549 622 5
-- Name: view_cr_decision_group_dcrb; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_cr_decision_group_dcrb AS
    SELECT core_change_request.id AS cr, link_group_members.member, link_group_members.role FROM (core_change_request JOIN link_group_members ON ((link_group_members."group" = core_change_request.decision_group_dcrb)));


--
-- TOC entry 244 (class 1259 OID 34865)
-- Dependencies: 2550 622 5
-- Name: view_cr_decision_group_tdg; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_cr_decision_group_tdg AS
    SELECT core_change_request.id AS cr, link_group_members.member, link_group_members.role FROM (core_change_request JOIN link_group_members ON ((link_group_members."group" = core_change_request.decision_group_tdg)));


--
-- TOC entry 245 (class 1259 OID 34869)
-- Dependencies: 2551 5 622
-- Name: view_cr_submission_group; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_cr_submission_group AS
    SELECT core_change_request.id AS cr, link_group_members.member, link_group_members.role FROM (core_change_request JOIN link_group_members ON ((link_group_members."group" = core_change_request.submission_group)));


--
-- TOC entry 246 (class 1259 OID 34873)
-- Dependencies: 2552 5
-- Name: view_dc_type; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_dc_type AS
    SELECT core_data_category.id, dc_type.type FROM (core_data_category LEFT JOIN ((((SELECT open.id, 'open'::text AS type FROM (SELECT core_open_data_category.id FROM core_open_data_category EXCEPT SELECT core_constrained_data_category.id FROM core_constrained_data_category) open UNION SELECT core_constrained_data_category.id, 'constrained'::text AS type FROM core_constrained_data_category) UNION SELECT core_closed_data_category.id, 'closed'::text AS type FROM core_closed_data_category) UNION SELECT core_simple_data_category.id, 'simple'::text AS type FROM core_simple_data_category) UNION SELECT core_container_data_category.id, 'container'::text AS type FROM core_container_data_category) dc_type ON ((dc_type.id = core_data_category.id)));


--
-- TOC entry 247 (class 1259 OID 34878)
-- Dependencies: 2553 5
-- Name: view_owner; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_owner AS
    SELECT core_owner.id, COALESCE(core_thematic_domain_group.name, user_name(core_user.id), NULL::character varying) AS name FROM ((core_owner LEFT JOIN core_thematic_domain_group ON ((core_thematic_domain_group.id = core_owner.id))) LEFT JOIN core_user ON ((core_user.id = core_owner.id)));


--
-- TOC entry 248 (class 1259 OID 34882)
-- Dependencies: 2554 640 5 613 610
-- Name: view_data_category; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_data_category AS
    SELECT core_data_category.id, core_data_category.pid, core_data_category.name, view_owner.id AS owner_id, view_owner.name AS owner, core_data_category.identifier, core_data_category.version, core_data_category.branch, core_data_category.revision, core_data_category.sidebranches, core_data_category.administration_status, core_data_category.registration_status, core_data_category.justification, core_data_category.origin, core_data_category.effective_date, core_data_category.until_date, core_data_category.previous, core_data_category.next, core_data_category.private, view_dc_type.type, core_data_category."check", link_simple_data_category_super.super FROM (((core_data_category JOIN view_owner ON ((view_owner.id = core_data_category.owner))) JOIN view_dc_type ON ((view_dc_type.id = core_data_category.id))) LEFT JOIN link_simple_data_category_super ON ((link_simple_data_category_super.dc = core_data_category.id)));


--
-- TOC entry 249 (class 1259 OID 34887)
-- Dependencies: 2555 607 5 607
-- Name: view_dcs_access; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_dcs_access AS
    SELECT access.dcs, access.account, access.type, max(access.rights) AS rights, max(access.propagate) AS propagate FROM ((SELECT link_dcs_access.dcs, link_dcs_access.account, link_dcs_access.rights, link_dcs_access.propagate, 'user'::text AS type FROM (link_dcs_access JOIN core_user ON ((link_dcs_access.account = core_user.id))) UNION SELECT link_dcs_access.dcs, link_dcs_access.account, link_dcs_access.rights, link_dcs_access.propagate, 'group'::text AS type FROM (link_dcs_access JOIN core_group ON ((link_dcs_access.account = core_group.id)))) UNION SELECT link_dcs_access.dcs, link_group_members.member, link_dcs_access.rights, link_dcs_access.propagate, 'user'::text AS type FROM ((link_group_members JOIN core_group ON ((link_group_members."group" = core_group.id))) JOIN link_dcs_access ON ((link_dcs_access.account = core_group.id))) WHERE (link_group_members.status = 'accepted'::member_status_enum)) access GROUP BY access.dcs, access.account, access.type;


--
-- TOC entry 250 (class 1259 OID 34892)
-- Dependencies: 2556 5
-- Name: view_dcs_dc; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_dcs_dc AS
    SELECT dcs.dcs, dcs.dc, core_data_category.owner FROM ((SELECT core_selected_data_category.dcs, COALESCE(core_selected_container_data_category.dc, core_selected_complex_data_category.dc, core_selected_simple_data_category.dc, NULL::integer) AS dc FROM (((core_selected_data_category LEFT JOIN core_selected_container_data_category ON ((core_selected_container_data_category.id = core_selected_data_category.id))) LEFT JOIN core_selected_complex_data_category ON ((core_selected_complex_data_category.id = core_selected_data_category.id))) LEFT JOIN core_selected_simple_data_category ON ((core_selected_simple_data_category.id = core_selected_data_category.id)))) dcs JOIN core_data_category ON ((core_data_category.id = dcs.dc)));


--
-- TOC entry 251 (class 1259 OID 34897)
-- Dependencies: 2557 607 5
-- Name: view_dc_access; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_dc_access AS
    SELECT access.dc, access.account, access.type, max(access.rights) AS rights FROM (((SELECT link_dc_access.dc, link_dc_access.account, link_dc_access.rights, 'user'::text AS type FROM (link_dc_access JOIN core_user ON ((link_dc_access.account = core_user.id))) UNION SELECT link_dc_access.dc, link_dc_access.account, link_dc_access.rights, 'group'::text AS type FROM (link_dc_access JOIN core_group ON ((link_dc_access.account = core_group.id)))) UNION SELECT link_dc_access.dc, link_group_members.member AS account, link_dc_access.rights, 'user'::text AS type FROM ((link_group_members JOIN core_group ON ((link_group_members."group" = core_group.id))) JOIN link_dc_access ON ((link_dc_access.account = core_group.id))) WHERE ((link_group_members.status)::text = 'accepted'::text)) UNION SELECT oig.dc, view_dcs_access.account, view_dcs_access.propagate, view_dcs_access.type FROM (view_dcs_access JOIN (SELECT DISTINCT view_dcs_dc.dcs, view_dcs_dc.dc FROM ((view_dcs_dc JOIN link_dcs_access ON (((link_dcs_access.dcs = view_dcs_dc.dcs) AND (link_dcs_access.propagate IS NOT NULL)))) JOIN link_group_members ON (((link_group_members.member = view_dcs_dc.owner) AND (link_group_members."group" = link_dcs_access.account)))) WHERE ((link_group_members.status)::text = 'accepted'::text)) oig ON ((oig.dcs = view_dcs_access.dcs)))) access GROUP BY access.dc, access.account, access.type;


--
-- TOC entry 252 (class 1259 OID 34902)
-- Dependencies: 2558 631 5
-- Name: view_dc_name; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_dc_name AS
    SELECT core_data_category.id, generic_name.name, generic_name.status, generic_name.source, core_language.name AS language, core_language.tag FROM (((core_data_category JOIN core_language_section ON ((core_language_section.dc = core_data_category.id))) JOIN core_language ON ((core_language.id = core_language_section.language))) JOIN generic_name ON ((generic_name.owner = core_language_section.id))) WHERE (generic_name.owner_type = 'language section'::owner_type_enum) ORDER BY generic_name.id;


--
-- TOC entry 253 (class 1259 OID 34907)
-- Dependencies: 2559 5
-- Name: view_dc_profiles; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_dc_profiles AS
    SELECT link_profile_members.dc AS id, concat(DISTINCT ((link_profile_members.profile)::character varying)::text) AS profiles FROM link_profile_members GROUP BY link_profile_members.dc;


--
-- TOC entry 254 (class 1259 OID 34911)
-- Dependencies: 2560 613 5 640 610
-- Name: view_dcs; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_dcs AS
    SELECT dcs.dcs, dcs.dc, core_data_category.pid, core_data_category.name, view_owner.id AS owner_id, view_owner.name AS owner, core_data_category.identifier, core_data_category.version, core_data_category.branch, core_data_category.revision, core_data_category.sidebranches, core_data_category.administration_status, core_data_category.registration_status, core_data_category.justification, core_data_category.origin, core_data_category.effective_date, core_data_category.until_date, core_data_category.previous, core_data_category.next, core_data_category.private, view_dc_type.type, core_data_category."check", link_simple_data_category_super.super FROM (((((SELECT core_selected_data_category.dcs, COALESCE(core_selected_complex_data_category.dc, core_selected_simple_data_category.dc, core_selected_container_data_category.dc, NULL::integer) AS dc FROM (((core_selected_data_category LEFT JOIN core_selected_container_data_category ON ((core_selected_container_data_category.id = core_selected_data_category.id))) LEFT JOIN core_selected_complex_data_category ON ((core_selected_complex_data_category.id = core_selected_data_category.id))) LEFT JOIN core_selected_simple_data_category ON ((core_selected_simple_data_category.id = core_selected_data_category.id)))) dcs JOIN core_data_category ON ((core_data_category.id = dcs.dc))) JOIN view_owner ON ((view_owner.id = core_data_category.owner))) JOIN view_dc_type ON ((view_dc_type.id = core_data_category.id))) LEFT JOIN link_simple_data_category_super ON ((link_simple_data_category_super.dc = core_data_category.id)));


--
-- TOC entry 255 (class 1259 OID 34916)
-- Dependencies: 2561 607 5 607
-- Name: view_link_dcs_access; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_link_dcs_access AS
    SELECT link_dcs_access.dcs, link_dcs_access.account, link_dcs_access.rights, link_dcs_access.propagate, core_data_category_selection.name FROM (link_dcs_access JOIN core_data_category_selection ON ((link_dcs_access.dcs = core_data_category_selection.id)));


--
-- TOC entry 256 (class 1259 OID 34920)
-- Dependencies: 2562 5 625 628
-- Name: view_message; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_message AS
    SELECT core_message.id, core_message."from", core_message."to", core_message.subject, core_message.message, core_message.created, core_message.read, core_message.type, core_message.status FROM core_message;


--
-- TOC entry 257 (class 1259 OID 34924)
-- Dependencies: 2563 5 637 631 634
-- Name: view_name; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_name AS
    SELECT generic_name.id, generic_name.owner, generic_name.name_type, generic_name.source, generic_name.status, generic_name.name, generic_name.owner_type FROM generic_name;


--
-- TOC entry 258 (class 1259 OID 34928)
-- Dependencies: 2564 613 640 5 610
-- Name: view_profile; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_profile AS
    SELECT link_profile_members.profile, link_profile_members.dc, core_data_category.pid, core_data_category.name, view_owner.id AS owner_id, view_owner.name AS owner, core_data_category.identifier, core_data_category.version, core_data_category.administration_status, core_data_category.registration_status, core_data_category.justification, core_data_category.origin, core_data_category.effective_date, core_data_category.until_date, core_data_category.previous, core_data_category.private, view_dc_type.type, core_data_category."check", link_simple_data_category_super.super FROM ((((link_profile_members JOIN core_data_category ON ((core_data_category.id = link_profile_members.dc))) JOIN view_owner ON ((view_owner.id = core_data_category.owner))) JOIN view_dc_type ON ((view_dc_type.id = core_data_category.id))) LEFT JOIN link_simple_data_category_super ON ((link_simple_data_category_super.dc = core_data_category.id)));


--
-- TOC entry 259 (class 1259 OID 34933)
-- Dependencies: 2565 5 643 637
-- Name: view_text; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_text AS
    SELECT generic_text.id, generic_text.owner, generic_text.owner_type, generic_text.language, generic_text.date, generic_text."timestamp", generic_text.source, generic_text.text, generic_text.text_type, generic_text."user" FROM generic_text;


--
-- TOC entry 260 (class 1259 OID 34937)
-- Dependencies: 2566 5 646
-- Name: view_user; Type: VIEW; Schema: public; Owner: -
--

CREATE VIEW view_user AS
    SELECT core_user.id, core_user.login, core_user.last_name, core_user.email, core_user.organization, core_user.phone, core_user.post, core_user.access_count, core_user.first_access, core_user.last_access, core_user.password, core_user.type, core_user.first_name, core_user.disclaimer, core_user.sync, core_user.forum, core_user.shib_principal, user_name(core_user.id) AS name FROM core_user;


--
-- TOC entry 2567 (class 2604 OID 34941)
-- Dependencies: 164 163
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_account ALTER COLUMN id SET DEFAULT nextval('core_account_id_seq'::regclass);


--
-- TOC entry 2569 (class 2604 OID 34942)
-- Dependencies: 167 166
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_change_request ALTER COLUMN id SET DEFAULT nextval('core_change_request_id_seq'::regclass);


--
-- TOC entry 2571 (class 2604 OID 34943)
-- Dependencies: 169 168
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_change_request_vote ALTER COLUMN id SET DEFAULT nextval('core_change_request_vote_id_seq'::regclass);


--
-- TOC entry 2573 (class 2604 OID 34944)
-- Dependencies: 174 173
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_conceptual_domain ALTER COLUMN id SET DEFAULT nextval('core_conceptual_domain_id_seq'::regclass);


--
-- TOC entry 2582 (class 2604 OID 34945)
-- Dependencies: 180 179
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_data_category ALTER COLUMN id SET DEFAULT nextval('core_data_category_id_seq'::regclass);


--
-- TOC entry 2584 (class 2604 OID 34946)
-- Dependencies: 182 181
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_data_category_selection ALTER COLUMN id SET DEFAULT nextval('core_data_category_selection_id_seq'::regclass);


--
-- TOC entry 2585 (class 2604 OID 34947)
-- Dependencies: 184 183
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_data_type ALTER COLUMN id SET DEFAULT nextval('core_data_type_id_seq'::regclass);


--
-- TOC entry 2587 (class 2604 OID 34948)
-- Dependencies: 218 185
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_dc_status_log ALTER COLUMN id SET DEFAULT nextval('core_status_log_id_seq'::regclass);


--
-- TOC entry 2592 (class 2604 OID 34949)
-- Dependencies: 190 189
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_language ALTER COLUMN id SET DEFAULT nextval('core_language_id_seq'::regclass);


--
-- TOC entry 2594 (class 2604 OID 34950)
-- Dependencies: 192 191
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_language_section ALTER COLUMN id SET DEFAULT nextval('core_language_section_id_seq'::regclass);


--
-- TOC entry 2596 (class 2604 OID 34951)
-- Dependencies: 194 193
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_linguistic_section ALTER COLUMN id SET DEFAULT nextval('core_linguistic_section_id_seq'::regclass);


--
-- TOC entry 2601 (class 2604 OID 34952)
-- Dependencies: 196 195
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_message ALTER COLUMN id SET DEFAULT nextval('core_message_id_seq'::regclass);


--
-- TOC entry 2602 (class 2604 OID 34953)
-- Dependencies: 201 200
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_profile ALTER COLUMN id SET DEFAULT nextval('core_profile_id_seq'::regclass);


--
-- TOC entry 2603 (class 2604 OID 34954)
-- Dependencies: 204 203
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_registration_authority ALTER COLUMN id SET DEFAULT nextval('core_registration_authority_id_seq'::regclass);


--
-- TOC entry 2605 (class 2604 OID 34955)
-- Dependencies: 207 206
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_rule ALTER COLUMN id SET DEFAULT nextval('core_rule_id_seq'::regclass);


--
-- TOC entry 2606 (class 2604 OID 34956)
-- Dependencies: 209 208
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_rule_type ALTER COLUMN id SET DEFAULT nextval('core_rule_type_id_seq'::regclass);


--
-- TOC entry 2607 (class 2604 OID 34957)
-- Dependencies: 213 212
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_selected_data_category ALTER COLUMN id SET DEFAULT nextval('core_selected_data_category_id_seq'::regclass);


--
-- TOC entry 2609 (class 2604 OID 34958)
-- Dependencies: 216 215
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY core_session ALTER COLUMN id SET DEFAULT nextval('core_session_id_seq'::regclass);


--
-- TOC entry 2615 (class 2604 OID 34959)
-- Dependencies: 224 223
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY generic_lock ALTER COLUMN id SET DEFAULT nextval('generic_lock_id_seq'::regclass);


--
-- TOC entry 2617 (class 2604 OID 34960)
-- Dependencies: 226 225
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY generic_name ALTER COLUMN id SET DEFAULT nextval('generic_name_id_seq'::regclass);


--
-- TOC entry 2622 (class 2604 OID 34961)
-- Dependencies: 228 227
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY generic_text ALTER COLUMN id SET DEFAULT nextval('generic_text_id_seq'::regclass);


