--
--


SELECT pg_catalog.set_config('search_path', '', false);

--
-- Name: _quest; Type: SCHEMA; Schema: -; Owner: _dba
--

CREATE SCHEMA _quest;


ALTER SCHEMA _quest OWNER TO _dba;

--
-- Name: SCHEMA _quest; Type: COMMENT; Schema: -; Owner: _dba
--

COMMENT ON SCHEMA _quest IS 'Quest Data: Tables for normal application use of Quest data';


--
-- Name: off_course_label_text; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.off_course_label_text AS (
	subject_code text,
	catalog text
);


ALTER TYPE _quest.off_course_label_text OWNER TO _quest_root;

--
-- Name: TYPE off_course_label_text; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.off_course_label_text IS 'Parameter type for off_course_label_format()';


--
-- Name: quest_appl_id; Type: DOMAIN; Schema: _quest; Owner: _quest_root
--

CREATE DOMAIN _quest.quest_appl_id AS integer
	CONSTRAINT quest_appl_id_check CHECK (((VALUE >= 0) AND (VALUE <= 99999999)));


ALTER DOMAIN _quest.quest_appl_id OWNER TO _quest_root;

--
-- Name: quest_career; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_career AS ENUM (
    'UG',
    'GRD'
);


ALTER TYPE _quest.quest_career OWNER TO _quest_root;

--
-- Name: TYPE quest_career; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_career IS 'UnderGraduate; GRaDuate';


--
-- Name: quest_combined_type; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_combined_type AS ENUM (
    'W',
    'C',
    'B'
);


ALTER TYPE _quest.quest_combined_type OWNER TO _quest_root;

--
-- Name: TYPE quest_combined_type; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_combined_type IS 'Within subject; Cross subject; Both';


--
-- Name: quest_completion_code; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_completion_code AS ENUM (
    'N',
    'I',
    'Y'
);


ALTER TYPE _quest.quest_completion_code OWNER TO _quest_root;

--
-- Name: TYPE quest_completion_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_completion_code IS 'No; In progress; Yes';


--
-- Name: quest_consent; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_consent AS ENUM (
    'N',
    'D',
    'I'
);


ALTER TYPE _quest.quest_consent OWNER TO _quest_root;

--
-- Name: TYPE quest_consent; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_consent IS 'None; Departmental; Instructor';


--
-- Name: quest_course_id; Type: DOMAIN; Schema: _quest; Owner: _quest_root
--

CREATE DOMAIN _quest.quest_course_id AS integer;


ALTER DOMAIN _quest.quest_course_id OWNER TO _quest_root;

--
-- Name: quest_degree_id; Type: DOMAIN; Schema: _quest; Owner: _quest_root
--

CREATE DOMAIN _quest.quest_degree_id AS integer;


ALTER DOMAIN _quest.quest_degree_id OWNER TO _quest_root;

--
-- Name: quest_instruction_mode; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_instruction_mode AS ENUM (
    'P',
    'CO'
);


ALTER TYPE _quest.quest_instruction_mode OWNER TO _quest_root;

--
-- Name: TYPE quest_instruction_mode; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_instruction_mode IS 'in Person; Course Online';


--
-- Name: quest_load; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_load AS ENUM (
    'N',
    'P',
    'F'
);


ALTER TYPE _quest.quest_load OWNER TO _quest_root;

--
-- Name: TYPE quest_load; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_load IS 'Part-time; Full-time';


--
-- Name: quest_option; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_option AS ENUM (
    'R',
    'P'
);


ALTER TYPE _quest.quest_option OWNER TO _quest_root;

--
-- Name: TYPE quest_option; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_option IS 'Required; Preferred';


--
-- Name: quest_org_id; Type: DOMAIN; Schema: _quest; Owner: _quest_root
--

CREATE DOMAIN _quest.quest_org_id AS integer;


ALTER DOMAIN _quest.quest_org_id OWNER TO _quest_root;

--
-- Name: quest_registration_status; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_registration_status AS ENUM (
    'C',
    'E',
    'R'
);


ALTER TYPE _quest.quest_registration_status OWNER TO _quest_root;

--
-- Name: TYPE quest_registration_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_registration_status IS 'C: Co-op student has job - usually replaced soon by E; E: Enrollment activity occurred; R: Fees arranged';


--
-- Name: quest_requisite_id; Type: DOMAIN; Schema: _quest; Owner: _quest_root
--

CREATE DOMAIN _quest.quest_requisite_id AS integer;


ALTER DOMAIN _quest.quest_requisite_id OWNER TO _quest_root;

--
-- Name: quest_section_status; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_section_status AS ENUM (
    'A',
    'S',
    'X'
);


ALTER TYPE _quest.quest_section_status OWNER TO _quest_root;

--
-- Name: TYPE quest_section_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_section_status IS 'Active; Stop further enrollment; X=cancelled';


--
-- Name: quest_session; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_session AS ENUM (
    'PCS',
    '1',
    '2',
    '3',
    '4',
    '8',
    'UAE'
);


ALTER TYPE _quest.quest_session OWNER TO _quest_root;

--
-- Name: TYPE quest_session; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_session IS 'PCS=course selection; 1=normal; 8=online; others obsolete';


--
-- Name: quest_sex; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_sex AS ENUM (
    'M',
    'F',
    'U',
    'X'
);


ALTER TYPE _quest.quest_sex OWNER TO _quest_root;

--
-- Name: TYPE quest_sex; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_sex IS 'Male; Female; Undetermined; X: not given';


--
-- Name: quest_standing_status; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_standing_status AS ENUM (
    'COMP',
    'COND',
    'DEF',
    'DIS',
    'FAIL',
    'GST',
    'NAPP'
);


ALTER TYPE _quest.quest_standing_status OWNER TO _quest_root;

--
-- Name: TYPE quest_standing_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_standing_status IS 'COMPleted degree; CONDitional; DEFerred; DISmissed; FAILed out of program; Good STanding; Not APPlicable';


--
-- Name: quest_student_enrol_status; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_student_enrol_status AS ENUM (
    'EWAT',
    'ENRL',
    'DROP',
    'WDRW'
);


ALTER TYPE _quest.quest_student_enrol_status OWNER TO _quest_root;

--
-- Name: TYPE quest_student_enrol_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_student_enrol_status IS 'ENRoLled; DROPped; WithDRaWn; EWAT obsolete';


--
-- Name: quest_subplan_type; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_subplan_type AS ENUM (
    'S',
    'OP'
);


ALTER TYPE _quest.quest_subplan_type OWNER TO _quest_root;

--
-- Name: TYPE quest_subplan_type; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_subplan_type IS 'Subplan; OPtion';


--
-- Name: quest_term_id; Type: DOMAIN; Schema: _quest; Owner: _quest_root
--

CREATE DOMAIN _quest.quest_term_id AS integer
	CONSTRAINT quest_term_id_check CHECK (((VALUE % 10) = ANY (ARRAY[1, 5, 9])));


ALTER DOMAIN _quest.quest_term_id OWNER TO _quest_root;

--
-- Name: quest_userid; Type: DOMAIN; Schema: _quest; Owner: _quest_root
--

CREATE DOMAIN _quest.quest_userid AS text
	CONSTRAINT quest_userid_check CHECK ((VALUE ~ '^[a-z0-9-]{1,8}$'::text));


ALTER DOMAIN _quest.quest_userid OWNER TO _quest_root;

--
-- Name: quest_uw_id; Type: DOMAIN; Schema: _quest; Owner: _quest_root
--

CREATE DOMAIN _quest.quest_uw_id AS integer
	CONSTRAINT quest_uw_id_check CHECK (((VALUE >= 0) AND (VALUE <= 99999999)));


ALTER DOMAIN _quest.quest_uw_id OWNER TO _quest_root;

--
-- Name: quest_withdraw_code; Type: TYPE; Schema: _quest; Owner: _quest_root
--

CREATE TYPE _quest.quest_withdraw_code AS ENUM (
    'NWD',
    'CAN',
    'WDR'
);


ALTER TYPE _quest.quest_withdraw_code OWNER TO _quest_root;

--
-- Name: TYPE quest_withdraw_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TYPE _quest.quest_withdraw_code IS 'Not WithDrawn; CANcelled; WithDRew';


--
-- Name: cal_course_format_labels(integer[]); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.cal_course_format_labels(VARIADIC course_ids integer[]) RETURNS text
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT string_agg (subject_code || ' ' || catalog, '/' ORDER BY subject_code)
    FROM (
        SELECT subject_code, string_agg (catalog, '/' ORDER BY catalog) AS catalog
            FROM (
                SELECT DISTINCT subject_code, catalog
                    FROM cal_course NATURAL JOIN cal_course_label_history
                    WHERE course_id = ANY (course_ids)) AS s
            GROUP BY subject_code) t
$$;


ALTER FUNCTION _quest.cal_course_format_labels(VARIADIC course_ids integer[]) OWNER TO _quest_core;

--
-- Name: FUNCTION cal_course_format_labels(VARIADIC course_ids integer[]); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.cal_course_format_labels(VARIADIC course_ids integer[]) IS 'Format all the current labels of a collection of courses in a convenient form for display';


--
-- Name: course_format_meet_days(bit); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.course_format_meet_days(meet_days bit) RETURNS text
    LANGUAGE sql IMMUTABLE
    AS $$
SELECT string_agg (substring ('MTWRFSU' FROM n FOR substring (meet_days FROM n FOR 1)::integer), '')
    FROM generate_series (1, 7) AS n
$$;


ALTER FUNCTION _quest.course_format_meet_days(meet_days bit) OWNER TO _quest_core;

--
-- Name: FUNCTION course_format_meet_days(meet_days bit); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.course_format_meet_days(meet_days bit) IS 'Format a set of weekdays as a short string using MTWRFSU to represent the respective seven days of the week';


--
-- Name: course_format_meet_days_short(bit); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.course_format_meet_days_short(meet_days bit) RETURNS text
    LANGUAGE plpgsql IMMUTABLE
    AS $$
DECLARE
    result text := course_format_meet_days (meet_days);
BEGIN
    IF length (result) <= 4 THEN
        RETURN result;
    ELSE
        RETURN 'X' || course_format_meet_days (~meet_days);
    END IF;
END;
$$;


ALTER FUNCTION _quest.course_format_meet_days_short(meet_days bit) OWNER TO _quest_core;

--
-- Name: FUNCTION course_format_meet_days_short(meet_days bit); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.course_format_meet_days_short(meet_days bit) IS 'Format a set of weekdays as a short string using X to invert large weekday sets';


--
-- Name: is_academic_subject(text); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.is_academic_subject(subject text) RETURNS boolean
    LANGUAGE sql IMMUTABLE
    AS $_$
SELECT NOT subject ~ '^(COOP|PD.*|SEQ.*)$'
$_$;


ALTER FUNCTION _quest.is_academic_subject(subject text) OWNER TO _quest_core;

--
-- Name: FUNCTION is_academic_subject(subject text); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.is_academic_subject(subject text) IS 'Return false if subject is one of the administrative subject such as COOP or PD or SEQ and true otherwise.';


--
-- Name: off_course_label_format(_quest.off_course_label_text[]); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.off_course_label_format(label_text_p _quest.off_course_label_text[]) RETURNS text
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT string_agg (subject_code || ' ' || catalog, '/' ORDER BY subject_code)
    FROM (
        SELECT subject_code, string_agg (catalog, '/' ORDER BY catalog) AS catalog
            FROM (SELECT DISTINCT * FROM unnest (label_text_p)) AS s
            GROUP BY subject_code) t
$$;


ALTER FUNCTION _quest.off_course_label_format(label_text_p _quest.off_course_label_text[]) OWNER TO _quest_core;

--
-- Name: FUNCTION off_course_label_format(label_text_p _quest.off_course_label_text[]); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.off_course_label_format(label_text_p _quest.off_course_label_text[]) IS 'Format the given course labels for convenient display';


--
-- Name: off_course_section_format(_quest.quest_term_id, integer[]); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) RETURNS text
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT string_agg (name, '; ')
    FROM (
        SELECT format ('%s %s %s %s', subject_code, catalog, component_code,
                util_range_summarize (array_agg (section_code::integer ORDER BY section_code::integer), 'FM000')) AS name
            FROM (
                SELECT *
                    FROM off_course_section_plus
                    WHERE term_id = term_id_p AND class_id = ANY (class_ids)
                    ORDER BY subject_code, catalog, component_code, section_code
            ) AS t
            GROUP BY subject_code, catalog, component_code
            ORDER BY subject_code, catalog, component_code
    ) AS t
$$;


ALTER FUNCTION _quest.off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) OWNER TO _quest_core;

--
-- Name: FUNCTION off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) IS 'Format the specified course section or sections for convenient display';


--
-- Name: off_course_section_format_courses(_quest.quest_term_id, integer[]); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) RETURNS text
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT off_course_label_format (array_agg ((subject_code, catalog)::off_course_label_text))
    FROM off_course_section NATURAL JOIN off_course_as_of
        JOIN cal_course_label_history
            USING (course_id, course_as_of)
    WHERE term_id = term_id_p AND class_id = ANY (class_ids)
$$;


ALTER FUNCTION _quest.off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) OWNER TO _quest_core;

--
-- Name: FUNCTION off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) IS 'Format all the labels of the courses of the specified course sections for convenient display';


--
-- Name: off_course_section_format_labels(_quest.quest_term_id, integer[]); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) RETURNS text
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT off_course_label_format (array_agg ((subject_code, catalog)::off_course_label_text))
    FROM off_course_section NATURAL JOIN off_course_as_of
        JOIN cal_course_label_history
            USING (course_id, course_as_of, label_seq)
    WHERE term_id = term_id_p AND class_id = ANY (class_ids)
$$;


ALTER FUNCTION _quest.off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) OWNER TO _quest_core;

--
-- Name: FUNCTION off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) IS 'Format the course labels of the specified course sections for convenient display';


--
-- Name: off_instruct_section_format(_quest.quest_term_id, integer[]); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) RETURNS text
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT off_course_section_format (term_id_p, VARIADIC array_agg (class_id))
    FROM off_course_section
    WHERE term_id = term_id_p AND section_id = ANY (section_ids)
$$;


ALTER FUNCTION _quest.off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) OWNER TO _quest_core;

--
-- Name: FUNCTION off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) IS 'Format the specified instructional section or sections for convenient display';


--
-- Name: off_instruct_section_format_instructors(_quest.quest_term_id, integer[]); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) RETURNS text
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
WITH t AS (
    SELECT surname || ', ' || givennames AS names
        FROM off_instruct_section_instructor_plus
        WHERE term_id = term_id_p AND section_id = ANY (section_ids)
)
SELECT string_agg (DISTINCT names, '/' ORDER BY names)
    FROM t
$$;


ALTER FUNCTION _quest.off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) OWNER TO _quest_core;

--
-- Name: FUNCTION off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) IS 'Format the instructors of the specified instructional section or sections for convenient display';


--
-- Name: quest_update_tables(); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.quest_update_tables() RETURNS integer
    LANGUAGE plpgsql
    SET search_path TO _quest, _data
    AS $$
BEGIN
    PERFORM util_execute_sql_commands (util_format_refresh_schema_views ('_quest_view'));
    RETURN data_update_tables ('_quest',
        'quest_update_tables_before',
        'quest_update_tables_after');
END;
$$;


ALTER FUNCTION _quest.quest_update_tables() OWNER TO _quest_core;

--
-- Name: FUNCTION quest_update_tables(); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.quest_update_tables() IS 'Update working tables from Quest views';


--
-- Name: quest_update_tables_after(); Type: FUNCTION; Schema: _quest; Owner: _quest_root
--

CREATE FUNCTION _quest.quest_update_tables_after() RETURNS void
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO _quest, _data
    AS $$
BEGIN
    SET CONSTRAINTS off_course_section_term_id_fkey1, off_course_section_term_id_fkey4 IMMEDIATE;
    ALTER TABLE off_course_section
        ADD UNIQUE (term_id, course_id, label_seq, session_code, section_code),
        ADD FOREIGN KEY (term_id, course_id, label_seq, session_code, auto_enroll_1_section_code)
            REFERENCES off_course_section (term_id, course_id, label_seq, session_code, section_code),
        ADD FOREIGN KEY (term_id, course_id, label_seq, session_code, auto_enroll_2_section_code)
            REFERENCES off_course_section (term_id, course_id, label_seq, session_code, section_code);
END;
$$;


ALTER FUNCTION _quest.quest_update_tables_after() OWNER TO _quest_root;

--
-- Name: FUNCTION quest_update_tables_after(); Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON FUNCTION _quest.quest_update_tables_after() IS 'Undo the temporary changes of quest_update_tables_before ()';


--
-- Name: quest_update_tables_before(); Type: FUNCTION; Schema: _quest; Owner: _quest_root
--

CREATE FUNCTION _quest.quest_update_tables_before() RETURNS void
    LANGUAGE plpgsql SECURITY DEFINER
    SET search_path TO _quest, _data
    AS $$
BEGIN
    ALTER TABLE off_course_section
        DROP CONSTRAINT off_course_section_term_id_fkey2,
        DROP CONSTRAINT off_course_section_term_id_fkey3,
        DROP CONSTRAINT off_course_section_term_id_course_id_label_seq_session_code_key;
END;
$$;


ALTER FUNCTION _quest.quest_update_tables_before() OWNER TO _quest_root;

--
-- Name: FUNCTION quest_update_tables_before(); Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON FUNCTION _quest.quest_update_tables_before() IS 'Temporary changes to be done before attempting to update tables';


--
-- Name: std_citizenship_foreign(_quest.quest_uw_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.std_citizenship_foreign(uw_id_p _quest.quest_uw_id) RETURNS text[]
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT array_agg (country_code ORDER BY country_code)
    FROM std_citizenship
    WHERE uw_id = uw_id_p AND country_code <> 'CAN'
$$;


ALTER FUNCTION _quest.std_citizenship_foreign(uw_id_p _quest.quest_uw_id) OWNER TO _quest_core;

--
-- Name: FUNCTION std_citizenship_foreign(uw_id_p _quest.quest_uw_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.std_citizenship_foreign(uw_id_p _quest.quest_uw_id) IS 'Return the non-Canadian country codes of the specified student';


--
-- Name: std_citizenship_status(_quest.quest_uw_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.std_citizenship_status(uw_id_p _quest.quest_uw_id) RETURNS text
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT citizenship_code
    FROM std_citizenship
    WHERE uw_id = uw_id_p AND country_code = 'CAN'
$$;


ALTER FUNCTION _quest.std_citizenship_status(uw_id_p _quest.quest_uw_id) OWNER TO _quest_core;

--
-- Name: FUNCTION std_citizenship_status(uw_id_p _quest.quest_uw_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.std_citizenship_status(uw_id_p _quest.quest_uw_id) IS 'Return the Canadian citizenship status code of the specified student';


--
-- Name: to_char(_quest.quest_appl_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.to_char(appl_id_p _quest.quest_appl_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT CASE WHEN appl_id_p < 1000
    THEN format ('[%s]', appl_id_p)
    ELSE to_char (appl_id_p, 'FM00000000') END;
$$;


ALTER FUNCTION _quest.to_char(appl_id_p _quest.quest_appl_id) OWNER TO _quest_core;

--
-- Name: FUNCTION to_char(appl_id_p _quest.quest_appl_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.to_char(appl_id_p _quest.quest_appl_id) IS 'Format an application ID as text';


--
-- Name: to_char(_quest.quest_course_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.to_char(course_id_p _quest.quest_course_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT to_char (course_id_p, 'FM000000');
$$;


ALTER FUNCTION _quest.to_char(course_id_p _quest.quest_course_id) OWNER TO _quest_core;

--
-- Name: FUNCTION to_char(course_id_p _quest.quest_course_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.to_char(course_id_p _quest.quest_course_id) IS 'Format a numeric course ID as text';


--
-- Name: to_char(_quest.quest_degree_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.to_char(degree_id_p _quest.quest_degree_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT to_char (degree_id_p, 'FM00');
$$;


ALTER FUNCTION _quest.to_char(degree_id_p _quest.quest_degree_id) OWNER TO _quest_core;

--
-- Name: FUNCTION to_char(degree_id_p _quest.quest_degree_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.to_char(degree_id_p _quest.quest_degree_id) IS 'Format a degree ID as text';


--
-- Name: to_char(_quest.quest_requisite_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.to_char(requisite_id_p _quest.quest_requisite_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT to_char (requisite_id_p, 'FM000000');
$$;


ALTER FUNCTION _quest.to_char(requisite_id_p _quest.quest_requisite_id) OWNER TO _quest_core;

--
-- Name: FUNCTION to_char(requisite_id_p _quest.quest_requisite_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.to_char(requisite_id_p _quest.quest_requisite_id) IS 'Format a requisite ID as text';


--
-- Name: to_char(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.to_char(term_id_p _quest.quest_term_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT to_char (term_id_p, 'FM0000');
$$;


ALTER FUNCTION _quest.to_char(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION to_char(term_id_p _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.to_char(term_id_p _quest.quest_term_id) IS 'Format a numeric term ID as text';


--
-- Name: to_char(_quest.quest_uw_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.to_char(uw_id_p _quest.quest_uw_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT to_char (uw_id_p, 'FM00000000');
$$;


ALTER FUNCTION _quest.to_char(uw_id_p _quest.quest_uw_id) OWNER TO _quest_core;

--
-- Name: FUNCTION to_char(uw_id_p _quest.quest_uw_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.to_char(uw_id_p _quest.quest_uw_id) IS 'Format a UW ID as text';


--
-- Name: update_check_completion(integer); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.update_check_completion(run_id_p integer) RETURNS boolean
    LANGUAGE sql STABLE STRICT
    AS $$
SELECT run_ready IS NOT NULL
    FROM update_run
    WHERE run_id = run_id_p
$$;


ALTER FUNCTION _quest.update_check_completion(run_id_p integer) OWNER TO _quest_core;

--
-- Name: FUNCTION update_check_completion(run_id_p integer); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.update_check_completion(run_id_p integer) IS 'Return whether the specified import run has received all its expected notifications';


--
-- Name: update_check_notification(integer); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.update_check_notification(notification_id_p integer) RETURNS integer
    LANGUAGE sql STABLE STRICT
    AS $$
SELECT run_id
    FROM update_notification
    WHERE notification_id = notification_id_p
$$;


ALTER FUNCTION _quest.update_check_notification(notification_id_p integer) OWNER TO _quest_core;

--
-- Name: FUNCTION update_check_notification(notification_id_p integer); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.update_check_notification(notification_id_p integer) IS 'Return the run, if any, towards readiness of which the specified notification has been recorded as contributing';


--
-- Name: update_create_run(); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.update_create_run() RETURNS integer
    LANGUAGE plpgsql
    AS $$
DECLARE
    result                      integer;
BEGIN
    INSERT INTO update_run DEFAULT VALUES RETURNING run_id INTO STRICT result;
    INSERT INTO update_run_notification
        SELECT result, process_code
            FROM update_process;
    RETURN result;
END;
$$;


ALTER FUNCTION _quest.update_create_run() OWNER TO _quest_core;

--
-- Name: FUNCTION update_create_run(); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.update_create_run() IS 'Create a new data update run';


--
-- Name: update_current_run(); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.update_current_run() RETURNS integer
    LANGUAGE sql
    AS $$
SELECT run_id
    FROM update_run
    WHERE run_ready IS NULL
    ORDER BY run_created DESC
    LIMIT 1
$$;


ALTER FUNCTION _quest.update_current_run() OWNER TO _quest_core;

--
-- Name: FUNCTION update_current_run(); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.update_current_run() IS 'Return the run_id of the currently-open update run';


--
-- Name: update_receive_notification(integer, text); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.update_receive_notification(process_id_p integer, process_code_p text) RETURNS integer
    LANGUAGE plpgsql
    AS $$
DECLARE
    result                      integer;
    run_id_c                    integer;
BEGIN
    INSERT INTO update_notification (process_id, process_code)
        VALUES (process_id_p, process_code_p)
        RETURNING notification_id
        INTO STRICT result;
    BEGIN
        run_id_c := update_current_run ();
        UPDATE update_notification
            SET run_id = run_id_c
            WHERE notification_id = result;
        IF NOT EXISTS (
            SELECT *
                FROM update_run_notification NATURAL LEFT JOIN update_notification
                WHERE run_id = run_id_c AND update_notification IS NULL
        ) THEN
            UPDATE update_run
                SET run_ready = now ()
                WHERE run_id = run_id_c;
        END IF;
    EXCEPTION
        WHEN unique_violation THEN
            NULL;
    END;
    RETURN result;
END;
$$;


ALTER FUNCTION _quest.update_receive_notification(process_id_p integer, process_code_p text) OWNER TO _quest_core;

--
-- Name: FUNCTION update_receive_notification(process_id_p integer, process_code_p text); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.update_receive_notification(process_id_p integer, process_code_p text) IS 'Record receipt of a process completion notification';


--
-- Name: update_record_load_completion(integer); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.update_record_load_completion(run_id_p integer) RETURNS void
    LANGUAGE plpgsql
    AS $$
BEGIN
    UPDATE update_run
        SET run_loaded = now ()
        WHERE run_id = run_id_p AND run_ready IS NOT NULL AND run_loaded IS NULL;
    IF NOT FOUND THEN
        RAISE EXCEPTION 'Run not valid for load completion: %', run_id_p;
    END IF;
END;
$$;


ALTER FUNCTION _quest.update_record_load_completion(run_id_p integer) OWNER TO _quest_core;

--
-- Name: FUNCTION update_record_load_completion(run_id_p integer); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.update_record_load_completion(run_id_p integer) IS 'Record that the load process associated with the specified import run has completed';


--
-- Name: util_range_summarize(integer[], text); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.util_range_summarize(p integer[], format text) RETURNS text
    LANGUAGE sql
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
WITH s AS (
    SELECT i, CASE WHEN coalesce (lag (i) OVER (ORDER BY i) < i - 1, TRUE)
            THEN i ELSE NULL END AS r
        FROM unnest (p) AS i
), t AS (
    SELECT i, repeat_agg (r) OVER (ORDER BY i) AS r
        FROM s
), u AS (
    SELECT min (i) AS range_begin, max (i) AS range_end
        FROM t
        GROUP BY r
        ORDER BY r
)
SELECT string_agg (util_range_to_char (range_begin, range_end, format), ',')
    FROM u
$$;


ALTER FUNCTION _quest.util_range_summarize(p integer[], format text) OWNER TO _quest_core;

--
-- Name: FUNCTION util_range_summarize(p integer[], format text); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.util_range_summarize(p integer[], format text) IS 'Format the specified integers using the given format string, separating with commas, and summarizing continuous ranges';


--
-- Name: util_range_to_char(integer, integer, text); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.util_range_to_char(range_start integer, range_end integer, format text) RETURNS text
    LANGUAGE sql
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT CASE range_end - range_start
    WHEN 0 THEN to_char (range_start, format)
    WHEN 1 THEN to_char (range_start, format) || ',' || to_char (range_end, format)
    ELSE to_char (range_start, format) || '-' || to_char (range_end, format)
    END
$$;


ALTER FUNCTION _quest.util_range_to_char(range_start integer, range_end integer, format text) OWNER TO _quest_core;

--
-- Name: FUNCTION util_range_to_char(range_start integer, range_end integer, format text); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.util_range_to_char(range_start integer, range_end integer, format text) IS 'Format the specified range using the specified format string';


--
-- Name: uw_business_day_diff(date, date); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_business_day_diff(date_1 date, date_2 date) RETURNS integer
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT ud1.business_day - ud2.business_day
    FROM uw_date AS ud1, uw_date AS ud2
    WHERE (ud1.date, ud2.date) = (date_1, date_2)
$$;


ALTER FUNCTION _quest.uw_business_day_diff(date_1 date, date_2 date) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_business_day_diff(date_1 date, date_2 date); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_business_day_diff(date_1 date, date_2 date) IS 'Find the offset in business days of the first given business day from the second given business day, or NULL if either given date is not a business day';


--
-- Name: uw_business_day_offset(date, integer); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_business_day_offset(date_p date, offset_p integer) RETURNS date
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT ud2.date
    FROM uw_date AS ud1, uw_date AS ud2
    WHERE (ud1.date, ud1.business_day + offset_p) = (date_p, ud2.business_day)
$$;


ALTER FUNCTION _quest.uw_business_day_offset(date_p date, offset_p integer) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_business_day_offset(date_p date, offset_p integer); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_business_day_offset(date_p date, offset_p integer) IS 'Find the business day the given number of business days after the given business day, or NULL if the given date is not a business day';


--
-- Name: uw_date_weekday(date); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_date_weekday(date_p date) RETURNS bit
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT '1000000'::bit(7) >> (6 + extract (DOW FROM date_p)::integer) % 7
$$;


ALTER FUNCTION _quest.uw_date_weekday(date_p date) OWNER TO _quest_core;

--
-- Name: uw_format_term_academic_year(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_format_term_academic_year(term_id_p _quest.quest_term_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT uw_format_year (term_academic_year)
    FROM uw_term
    WHERE term_id = term_id_p
$$;


ALTER FUNCTION _quest.uw_format_term_academic_year(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_format_term_academic_year(term_id_p _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_format_term_academic_year(term_id_p _quest.quest_term_id) IS 'Format in a readable way the academic year of the specified term';


--
-- Name: uw_format_term_fiscal_year(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_format_term_fiscal_year(term_id_p _quest.quest_term_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT uw_format_year (term_fiscal_year)
    FROM uw_term
    WHERE term_id = term_id_p
$$;


ALTER FUNCTION _quest.uw_format_term_fiscal_year(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_format_term_fiscal_year(term_id_p _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_format_term_fiscal_year(term_id_p _quest.quest_term_id) IS 'Format in a readable way the fiscal year of the specified term';


--
-- Name: uw_format_year(integer); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_format_year(year integer) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT format ('%s/%s', year - 1, to_char (year % 100, 'FM00'))
$$;


ALTER FUNCTION _quest.uw_format_year(year integer) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_format_year(year integer); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_format_year(year integer) IS 'Format in a readable way the numbers of the given and previous year';


--
-- Name: uw_next_business_day(date); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_next_business_day(date_p date) RETURNS date
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT min (date)
    FROM uw_date
    WHERE date > date_p AND business_day IS NOT NULL
$$;


ALTER FUNCTION _quest.uw_next_business_day(date_p date) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_next_business_day(date_p date); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_next_business_day(date_p date) IS 'Find the next business day after the given date';


--
-- Name: uw_prev_business_day(date); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_prev_business_day(date_p date) RETURNS date
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT max (date)
    FROM uw_date
    WHERE date < date_p AND business_day IS NOT NULL
$$;


ALTER FUNCTION _quest.uw_prev_business_day(date_p date) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_prev_business_day(date_p date); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_prev_business_day(date_p date) IS 'Find the last business day before the given date';


--
-- Name: uw_term_current(); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_current() RETURNS _quest.quest_term_id
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT uw_term_from_time (current_date)
$$;


ALTER FUNCTION _quest.uw_term_current() OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_current(); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_current() IS 'Find the term ID of the current term';


--
-- Name: uw_term_diff(_quest.quest_term_id, _quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id) RETURNS integer
    LANGUAGE plpgsql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
DECLARE
    raw_diff                    integer := term_id_1 - term_id_2;
    year_offset                 integer := raw_diff / 10;
    term_offset                 integer := raw_diff % 10;
BEGIN
    RETURN year_offset * 3 + (term_offset + 2 * sign (term_offset)::integer) / 4;
END;
$$;


ALTER FUNCTION _quest.uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id) IS 'Find the offset in terms of the first specified term from the second specified term';


--
-- Name: uw_term_format(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_format(term_id_p _quest.quest_term_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT uw_term_time (term_id_p) || ' ' || uw_term_year (term_id_p)
$$;


ALTER FUNCTION _quest.uw_term_format(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_format(term_id_p _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_format(term_id_p _quest.quest_term_id) IS 'Format a term for display in short form';


--
-- Name: uw_term_format_short(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_format_short(term_id_p _quest.quest_term_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT substring (uw_term_time (term_id_p) from 1 for 1)
    || to_char (uw_term_year (term_id_p) % 100, 'FM00')
$$;


ALTER FUNCTION _quest.uw_term_format_short(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: uw_term_from_time(date); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_from_time(when_p date) RETURNS _quest.quest_term_id
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT term_id FROM uw_term WHERE when_p <@ term_dates
$$;


ALTER FUNCTION _quest.uw_term_from_time(when_p date) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_from_time(when_p date); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_from_time(when_p date) IS 'Find the term ID of the current term as of the given date';


--
-- Name: uw_term_from_time(timestamp without time zone); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_from_time(when_p timestamp without time zone) RETURNS _quest.quest_term_id
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT uw_term_from_time (when_p::date)
$$;


ALTER FUNCTION _quest.uw_term_from_time(when_p timestamp without time zone) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_from_time(when_p timestamp without time zone); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_from_time(when_p timestamp without time zone) IS 'Find the term ID of the current term as of the given timestamp';


--
-- Name: uw_term_from_time(timestamp with time zone); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_from_time(when_p timestamp with time zone) RETURNS _quest.quest_term_id
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT uw_term_from_time (when_p::timestamp)
$$;


ALTER FUNCTION _quest.uw_term_from_time(when_p timestamp with time zone) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_from_time(when_p timestamp with time zone); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_from_time(when_p timestamp with time zone) IS 'Find the term ID of the current term as of the given timestamptz';


--
-- Name: uw_term_next(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_next(term_id_p _quest.quest_term_id) RETURNS _quest.quest_term_id
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT uw_term_offset (term_id_p, 1)
$$;


ALTER FUNCTION _quest.uw_term_next(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_next(term_id_p _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_next(term_id_p _quest.quest_term_id) IS 'Find the term immediately after the specified term';


--
-- Name: uw_term_offset(_quest.quest_term_id, integer); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer) RETURNS _quest.quest_term_id
    LANGUAGE plpgsql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
DECLARE
    year_offset                 integer := 10 * (offset_p / 3);
    term_offset                 integer := 4 * (offset_p % 3);
    correction                  integer := 2 * ((term_offset + term_id_p % 10 + 10) / 10 - 1);
BEGIN
    RETURN term_id_p + year_offset + term_offset - correction;
END;
$$;


ALTER FUNCTION _quest.uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer) IS 'Find the term offset_p terms after the specified term';


--
-- Name: uw_term_prev(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_prev(term_id_p _quest.quest_term_id) RETURNS _quest.quest_term_id
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT uw_term_offset (term_id_p, -1)
$$;


ALTER FUNCTION _quest.uw_term_prev(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_prev(term_id_p _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_prev(term_id_p _quest.quest_term_id) IS 'Find the term immediately before the specified term';


--
-- Name: uw_term_time(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_time(term_id_p _quest.quest_term_id) RETURNS text
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT CASE term_id_p % 10
    WHEN 1 THEN 'Winter'
    WHEN 5 THEN 'Spring'
    WHEN 9 THEN 'Fall'
    END;
$$;


ALTER FUNCTION _quest.uw_term_time(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_time(term_id_p _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_time(term_id_p _quest.quest_term_id) IS 'Compute the season description of a term';


--
-- Name: uw_term_year(_quest.quest_term_id); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_term_year(term_id_p _quest.quest_term_id) RETURNS integer
    LANGUAGE sql IMMUTABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT (term_id_p / 10) + 1900
$$;


ALTER FUNCTION _quest.uw_term_year(term_id_p _quest.quest_term_id) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_term_year(term_id_p _quest.quest_term_id); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_term_year(term_id_p _quest.quest_term_id) IS 'Compute the year of a term';


--
-- Name: uw_this_next_business_day(date); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_this_next_business_day(date_p date) RETURNS date
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT min (date)
    FROM uw_date
    WHERE date >= date_p AND business_day IS NOT NULL
$$;


ALTER FUNCTION _quest.uw_this_next_business_day(date_p date) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_this_next_business_day(date_p date); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_this_next_business_day(date_p date) IS 'Find the next business day on or after the given date';


--
-- Name: uw_this_prev_business_day(date); Type: FUNCTION; Schema: _quest; Owner: _quest_core
--

CREATE FUNCTION _quest.uw_this_prev_business_day(date_p date) RETURNS date
    LANGUAGE sql STABLE STRICT
    SET search_path TO _quest, _data, public, pg_temp
    AS $$
SELECT max (date)
    FROM uw_date
    WHERE date <= date_p AND business_day IS NOT NULL
$$;


ALTER FUNCTION _quest.uw_this_prev_business_day(date_p date) OWNER TO _quest_core;

--
-- Name: FUNCTION uw_this_prev_business_day(date_p date); Type: COMMENT; Schema: _quest; Owner: _quest_core
--

COMMENT ON FUNCTION _quest.uw_this_prev_business_day(date_p date) IS 'Find the last business day on or before the given date';




--
-- Name: cal_course_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.cal_course_history (
    course_id _quest.quest_course_id NOT NULL,
    course_as_of date NOT NULL,
    course_active boolean NOT NULL,
    course_short_title text NOT NULL,
    course_title text NOT NULL,
    course_description text,
    course_take_units numeric(5,2) NOT NULL,
    course_ap_units numeric(5,2) NOT NULL,
    course_add_consent _quest.quest_consent NOT NULL,
    course_drop_consent _quest.quest_consent NOT NULL
);


ALTER TABLE _quest.cal_course_history OWNER TO _quest_root;

--
-- Name: cal_course_label_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.cal_course_label_history (
    course_id _quest.quest_course_id NOT NULL,
    course_as_of date NOT NULL,
    label_seq integer NOT NULL,
    subject_code text NOT NULL,
    catalog text NOT NULL,
    campus_code text,
    group_code text NOT NULL,
    unit_code text NOT NULL,
    career_code _quest.quest_career NOT NULL,
    requisite_id _quest.quest_requisite_id,
    label_schedule_print boolean NOT NULL
);


ALTER TABLE _quest.cal_course_label_history OWNER TO _quest_root;

--
-- Name: cal_course_topic_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.cal_course_topic_history (
    course_id _quest.quest_course_id NOT NULL,
    course_as_of date NOT NULL,
    topic_seq integer NOT NULL,
    topic_short_title text NOT NULL,
    topic_title text NOT NULL
);


ALTER TABLE _quest.cal_course_topic_history OWNER TO _quest_root;

--
-- Name: off_course_as_of; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_course_as_of (
    term_id _quest.quest_term_id NOT NULL,
    course_id _quest.quest_course_id NOT NULL,
    course_as_of date NOT NULL
);


ALTER TABLE _quest.off_course_as_of OWNER TO _quest_root;

--
-- Name: off_course_section; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_course_section (
    term_id _quest.quest_term_id NOT NULL,
    class_id integer NOT NULL,
    section_id integer NOT NULL,
    course_id _quest.quest_course_id NOT NULL,
    topic_seq integer NOT NULL,
    label_seq integer NOT NULL,
    session_code _quest.quest_session NOT NULL,
    section_code text NOT NULL,
    component_code text NOT NULL,
    cs_add_consent _quest.quest_consent NOT NULL,
    cs_drop_consent _quest.quest_consent NOT NULL,
    cs_closed boolean NOT NULL,
    association_id integer,
    auto_enroll_1_section_code text,
    auto_enroll_2_section_code text,
    cs_schedule_print boolean NOT NULL,
    cs_enrol_limit integer NOT NULL,
    cs_enrol_total integer NOT NULL,
    cs_capacity_request integer NOT NULL
);


ALTER TABLE _quest.off_course_section OWNER TO _quest_root;

--
-- Name: TABLE off_course_section; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.off_course_section IS 'A course section in which students may be registered and are all eligible to receive the same credit upon completion';


--
-- Name: off_course_section_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.off_course_section_plus AS
 SELECT off_course_section.course_id,
    off_course_as_of.course_as_of,
    off_course_section.topic_seq,
    off_course_section.label_seq,
    off_course_section.term_id,
    off_course_section.class_id,
    off_course_section.section_id,
    off_course_section.session_code,
    off_course_section.section_code,
    off_course_section.component_code,
    off_course_section.cs_add_consent,
    off_course_section.cs_drop_consent,
    off_course_section.cs_closed,
    off_course_section.association_id,
    off_course_section.auto_enroll_1_section_code,
    off_course_section.auto_enroll_2_section_code,
    off_course_section.cs_schedule_print,
    off_course_section.cs_enrol_limit,
    off_course_section.cs_enrol_total,
    off_course_section.cs_capacity_request,
    cal_course_label_history.subject_code,
    cal_course_label_history.catalog,
    cal_course_label_history.campus_code,
    cal_course_label_history.group_code,
    cal_course_label_history.unit_code,
    cal_course_label_history.career_code,
    cal_course_label_history.requisite_id,
    cal_course_label_history.label_schedule_print,
    cal_course_topic_history.topic_short_title,
    cal_course_topic_history.topic_title
   FROM (((_quest.off_course_section
     JOIN _quest.off_course_as_of USING (term_id, course_id))
     LEFT JOIN _quest.cal_course_label_history USING (course_id, course_as_of, label_seq))
     LEFT JOIN _quest.cal_course_topic_history USING (course_id, course_as_of, topic_seq));


ALTER TABLE _quest.off_course_section_plus OWNER TO _quest_root;

--
-- Name: VIEW off_course_section_plus; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.off_course_section_plus IS 'off_course_section enhanced with fields related to the course labels and topics';


--
-- Name: off_course_section_complete; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.off_course_section_complete AS
 SELECT off_course_section_plus.course_id,
    off_course_section_plus.course_as_of,
    off_course_section_plus.topic_seq,
    off_course_section_plus.label_seq,
    off_course_section_plus.term_id,
    off_course_section_plus.class_id,
    off_course_section_plus.section_id,
    off_course_section_plus.session_code,
    off_course_section_plus.section_code,
    off_course_section_plus.component_code,
    off_course_section_plus.cs_add_consent,
    off_course_section_plus.cs_drop_consent,
    off_course_section_plus.cs_closed,
    off_course_section_plus.association_id,
    off_course_section_plus.auto_enroll_1_section_code,
    off_course_section_plus.auto_enroll_2_section_code,
    off_course_section_plus.cs_schedule_print,
    off_course_section_plus.cs_enrol_limit,
    off_course_section_plus.cs_enrol_total,
    off_course_section_plus.cs_capacity_request,
    off_course_section_plus.subject_code,
    off_course_section_plus.catalog,
    off_course_section_plus.campus_code,
    off_course_section_plus.group_code,
    off_course_section_plus.unit_code,
    off_course_section_plus.career_code,
    off_course_section_plus.requisite_id,
    off_course_section_plus.label_schedule_print,
    off_course_section_plus.topic_short_title,
    off_course_section_plus.topic_title,
    cal_course_history.course_active,
    cal_course_history.course_short_title,
    cal_course_history.course_title,
    cal_course_history.course_description,
    cal_course_history.course_take_units,
    cal_course_history.course_ap_units,
    cal_course_history.course_add_consent,
    cal_course_history.course_drop_consent
   FROM (_quest.off_course_section_plus
     JOIN _quest.cal_course_history USING (course_id, course_as_of));


ALTER TABLE _quest.off_course_section_complete OWNER TO _quest_root;

--
-- Name: VIEW off_course_section_complete; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.off_course_section_complete IS 'off_course_section enhanced with fields related to the course labels, topics, and calendar information';


--
-- Name: off_instruct_section_instructor; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_instruct_section_instructor (
    term_id _quest.quest_term_id NOT NULL,
    section_id integer NOT NULL,
    uw_id _quest.quest_uw_id NOT NULL,
    instructor_role_code text NOT NULL,
    userid text
);


ALTER TABLE _quest.off_instruct_section_instructor OWNER TO _quest_root;

--
-- Name: adm_appl_program; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_program (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    program_order integer NOT NULL,
    program_as_of date NOT NULL,
    program_sequence integer NOT NULL,
    program_code text NOT NULL,
    program_status_code text NOT NULL,
    admit_term_id _quest.quest_term_id NOT NULL,
    approved_load _quest.quest_load NOT NULL,
    campus_code text NOT NULL,
    ouac_appl_seq integer,
    ouac_choice integer,
    ext_subject_code text
);


ALTER TABLE _quest.adm_appl_program OWNER TO _quest_root;

--
-- Name: adm_appl_subplan; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_subplan (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    program_order integer NOT NULL,
    program_as_of date NOT NULL,
    program_sequence integer NOT NULL,
    plan_code text NOT NULL,
    subplan_code text NOT NULL
);


ALTER TABLE _quest.adm_appl_subplan OWNER TO _quest_root;

--
-- Name: pps_plan; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_plan (
    plan_code text NOT NULL,
    plan_as_of date NOT NULL,
    plan_active boolean NOT NULL,
    plan_title text NOT NULL,
    plan_short_title text NOT NULL,
    plan_comment text,
    plan_diploma_description text,
    plan_transcript_description text NOT NULL,
    degree_code text,
    program_code text,
    career_code _quest.quest_career,
    unit_code text NOT NULL,
    plan_type_code text NOT NULL,
    first_valid_term_id _quest.quest_term_id,
    last_admit_term_id _quest.quest_term_id
);


ALTER TABLE _quest.pps_plan OWNER TO _quest_root;

--
-- Name: adm_appl_plan; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_plan (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    program_order integer NOT NULL,
    program_as_of date NOT NULL,
    program_sequence integer NOT NULL,
    plan_code text NOT NULL,
    plan_order integer NOT NULL
);


ALTER TABLE _quest.adm_appl_plan OWNER TO _quest_root;

--
-- Name: pps_program; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_program (
    program_code text NOT NULL,
    program_as_of date NOT NULL,
    program_active boolean NOT NULL,
    program_title text NOT NULL,
    program_short_title text NOT NULL,
    career_code _quest.quest_career NOT NULL,
    group_code text NOT NULL,
    unit_code text NOT NULL,
    level_load_rule_code text NOT NULL,
    first_valid_term_id _quest.quest_term_id
);


ALTER TABLE _quest.pps_program OWNER TO _quest_root;

--
-- Name: adm_appl_program_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_program_history (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    program_order integer NOT NULL,
    program_as_of date NOT NULL,
    program_sequence integer NOT NULL,
    program_code text NOT NULL,
    program_status_code text NOT NULL,
    program_action_code text NOT NULL,
    action_date date NOT NULL,
    program_reason text,
    admit_term_id _quest.quest_term_id NOT NULL,
    approved_load _quest.quest_load NOT NULL,
    campus_code text NOT NULL
);


ALTER TABLE _quest.adm_appl_program_history OWNER TO _quest_root;

--
-- Name: pps_subplan; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_subplan (
    plan_code text NOT NULL,
    subplan_code text NOT NULL,
    subplan_as_of date NOT NULL,
    subplan_active boolean NOT NULL,
    subplan_title text NOT NULL,
    subplan_short_title text NOT NULL,
    subplan_diploma_description text,
    subplan_transcript_description text NOT NULL,
    subplan_type _quest.quest_subplan_type NOT NULL,
    first_valid_term_id _quest.quest_term_id,
    last_admit_term_id _quest.quest_term_id
);


ALTER TABLE _quest.pps_subplan OWNER TO _quest_root;

--
-- Name: std_term_course; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_course (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    class_id integer NOT NULL,
    course_grade text,
    earn_credit boolean NOT NULL,
    include_in_gpa boolean NOT NULL,
    requirement_designation text,
    requirement_designation_grade text,
    units_attempted_code _quest.quest_completion_code NOT NULL,
    grade_points numeric(9,3) NOT NULL,
    student_take_units numeric(5,2) NOT NULL,
    student_ap_units numeric(5,2) NOT NULL,
    grading_basis text NOT NULL,
    valid_attempt boolean,
    grade_category text,
    grade_submission_date date,
    transcript_note text
);


ALTER TABLE _quest.std_term_course OWNER TO _quest_root;

--
-- Name: std_term_section; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_section (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    class_id integer NOT NULL,
    enrolment_status _quest.quest_student_enrol_status NOT NULL,
    permission_number integer,
    reserve_id integer,
    add_date date NOT NULL,
    drop_date date,
    last_update timestamp without time zone,
    last_enrolment_change timestamp without time zone,
    last_drop timestamp without time zone
);


ALTER TABLE _quest.std_term_section OWNER TO _quest_root;

--
-- Name: std_term_course_section; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_term_course_section AS
 SELECT course.uw_id,
    course.term_id,
    course.course_id,
    off_course_as_of.course_as_of,
    course.label_seq,
    course.topic_seq,
    course.session_code,
    course.section_id AS course_section_id,
    course.class_id AS course_class_id,
    section.section_id,
    section.class_id,
    "left"(section.section_code, 1) AS component
   FROM (((_quest.std_term_course std_term_course(uw_id_1, term_id, class_id, course_grade, earn_credit, include_in_gpa, requirement_designation, requirement_designation_grade, units_attempted_code, grade_points, student_take_units, student_ap_units, grading_basis, valid_attempt, grade_category, grade_submission_date, transcript_note)
     JOIN _quest.off_course_section off_course_section(term_id, class_id, section_id, course_id_1, topic_seq_1, label_seq_1, session_code_1, section_code, component_code, cs_add_consent, cs_drop_consent, cs_closed, association_id, auto_enroll_1_section_code, auto_enroll_2_section_code, cs_schedule_print, cs_enrol_limit, cs_enrol_total, cs_capacity_request) USING (term_id, class_id)) course(term_id, class_id, uw_id, course_grade, earn_credit, include_in_gpa, requirement_designation, requirement_designation_grade, units_attempted_code, grade_points, student_take_units, student_ap_units, grading_basis, valid_attempt, grade_category, grade_submission_date, transcript_note, section_id, course_id, topic_seq, label_seq, session_code, section_code, component_code, cs_add_consent, cs_drop_consent, cs_closed, association_id, auto_enroll_1_section_code, auto_enroll_2_section_code, cs_schedule_print, cs_enrol_limit, cs_enrol_total, cs_capacity_request)
     JOIN (_quest.std_term_section std_term_section(uw_id_1, term_id, class_id, enrolment_status, permission_number, reserve_id, add_date, drop_date, last_update, last_enrolment_change, last_drop)
     JOIN _quest.off_course_section off_course_section_1(term_id, class_id, section_id, course_id_1, topic_seq_1, label_seq_1, session_code_1, section_code, component_code, cs_add_consent, cs_drop_consent, cs_closed, association_id, auto_enroll_1_section_code, auto_enroll_2_section_code, cs_schedule_print, cs_enrol_limit, cs_enrol_total, cs_capacity_request) USING (term_id, class_id)) section(term_id, class_id, uw_id, enrolment_status, permission_number, reserve_id, add_date, drop_date, last_update, last_enrolment_change, last_drop, section_id, course_id, topic_seq, label_seq, session_code, section_code, component_code, cs_add_consent, cs_drop_consent, cs_closed, association_id, auto_enroll_1_section_code, auto_enroll_2_section_code, cs_schedule_print, cs_enrol_limit, cs_enrol_total, cs_capacity_request) USING (uw_id, term_id, course_id, label_seq, topic_seq, session_code))
     JOIN _quest.off_course_as_of USING (term_id, course_id));


ALTER TABLE _quest.std_term_course_section OWNER TO _quest_root;

--
-- Name: VIEW std_term_course_section; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_term_course_section IS 'Student section registrations related to course registrations';


--
-- Name: cal_course; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.cal_course (
    course_id _quest.quest_course_id NOT NULL,
    course_as_of date NOT NULL,
    course_active boolean NOT NULL,
    course_short_title text NOT NULL,
    course_title text NOT NULL,
    course_description text,
    course_take_units numeric(5,2) NOT NULL,
    course_ap_units numeric(5,2) NOT NULL,
    course_add_consent _quest.quest_consent NOT NULL,
    course_drop_consent _quest.quest_consent NOT NULL
);


ALTER TABLE _quest.cal_course OWNER TO _quest_root;

--
-- Name: TABLE cal_course; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.cal_course IS 'A course as defined in the Calendar';


--
-- Name: off_instruct_section; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_instruct_section (
    term_id _quest.quest_term_id NOT NULL,
    section_id integer NOT NULL,
    session_code _quest.quest_session NOT NULL,
    is_enrolment boolean NOT NULL,
    is_status _quest.quest_section_status NOT NULL,
    is_enrol_limit integer NOT NULL,
    is_enrol_total integer NOT NULL,
    is_capacity_request integer NOT NULL,
    is_combined_type _quest.quest_combined_type,
    campus_code text NOT NULL,
    location_code text NOT NULL,
    instruction_mode_code _quest.quest_instruction_mode NOT NULL
);


ALTER TABLE _quest.off_instruct_section OWNER TO _quest_root;

--
-- Name: TABLE off_instruct_section; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.off_instruct_section IS 'An instructional section in which students may be registered and will be managed together as one group';


--
-- Name: COLUMN off_instruct_section.session_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.off_instruct_section.session_code IS 'The session of the section';


--
-- Name: COLUMN off_instruct_section.is_enrolment; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.off_instruct_section.is_enrolment IS 'Whether the section is an enrolment (primary) section';


--
-- Name: COLUMN off_instruct_section.is_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.off_instruct_section.is_status IS 'The status of the section';


--
-- Name: uw_term; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_term (
    term_id _quest.quest_term_id NOT NULL,
    term_dates daterange NOT NULL,
    term_class_dates daterange NOT NULL,
    term_exam_dates daterange,
    term_calendar_year integer NOT NULL,
    term_academic_year integer NOT NULL,
    term_fiscal_year integer NOT NULL
);


ALTER TABLE _quest.uw_term OWNER TO _quest_root;

--
-- Name: TABLE uw_term; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_term IS 'An academic term';


--
-- Name: COLUMN uw_term.term_dates; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_term.term_dates IS 'The range of dates covered by the term';


--
-- Name: COLUMN uw_term.term_class_dates; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_term.term_class_dates IS 'The range of dates designated for classes for the term';


--
-- Name: COLUMN uw_term.term_exam_dates; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_term.term_exam_dates IS 'The range of dates designated for final examinations for the term, or NULL if the examination period has not been published yet';


--
-- Name: COLUMN uw_term.term_calendar_year; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_term.term_calendar_year IS 'The calendar year during which the term falls';


--
-- Name: COLUMN uw_term.term_academic_year; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_term.term_academic_year IS 'The academic year during which the term falls';


--
-- Name: COLUMN uw_term.term_fiscal_year; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_term.term_fiscal_year IS 'The fiscal year during which the term falls';


--
-- Name: cal_subject; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.cal_subject (
    subject_code text NOT NULL,
    subject_as_of date NOT NULL,
    subject_active boolean NOT NULL,
    subject_description text NOT NULL,
    subject_short_description text NOT NULL,
    unit_code text NOT NULL
);


ALTER TABLE _quest.cal_subject OWNER TO _quest_root;

--
-- Name: TABLE cal_subject; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.cal_subject IS 'A subject code under which a course may be offered';


--
-- Name: uw_unit; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_unit (
    unit_code text NOT NULL,
    unit_as_of date NOT NULL,
    unit_active boolean NOT NULL,
    unit_short_description text NOT NULL,
    unit_description text NOT NULL,
    unit_full_description text NOT NULL,
    campus_code text NOT NULL,
    group_code text NOT NULL
);


ALTER TABLE _quest.uw_unit OWNER TO _quest_root;

--
-- Name: TABLE uw_unit; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_unit IS 'An academic unit (department, school, or other unit) as of the most recent update to that unit in uw_unit_history';


--
-- Name: std_transfer_credit_detail; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_transfer_credit_detail (
    uw_id _quest.quest_uw_id NOT NULL,
    career_code _quest.quest_career NOT NULL,
    transfer_group integer NOT NULL,
    seq_num integer NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    course_id _quest.quest_course_id NOT NULL,
    label_seq integer NOT NULL,
    external_term text,
    external_subject text,
    external_catalog text,
    external_descr text,
    external_grade text,
    course_grade text NOT NULL,
    earn_credit boolean NOT NULL,
    include_in_gpa boolean NOT NULL,
    requirement_designation text,
    units_attempted_code _quest.quest_completion_code NOT NULL,
    student_take_units numeric(5,2),
    student_ap_units numeric(8,3) NOT NULL,
    grading_basis text NOT NULL,
    valid_attempt boolean NOT NULL,
    grade_category text NOT NULL
);


ALTER TABLE _quest.std_transfer_credit_detail OWNER TO _quest_root;

--
-- Name: TABLE std_transfer_credit_detail; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.std_transfer_credit_detail IS 'Transfer credit details.  Some corrections are done in ps_correction.sql upon load.';


--
-- Name: std_transfer_credit_detail_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_transfer_credit_detail_plus AS
 SELECT std_transfer_credit_detail.course_id,
    off_course_as_of.course_as_of,
    std_transfer_credit_detail.label_seq,
    std_transfer_credit_detail.term_id,
    std_transfer_credit_detail.uw_id,
    std_transfer_credit_detail.career_code,
    std_transfer_credit_detail.transfer_group,
    std_transfer_credit_detail.seq_num,
    std_transfer_credit_detail.external_term,
    std_transfer_credit_detail.external_subject,
    std_transfer_credit_detail.external_catalog,
    std_transfer_credit_detail.external_descr,
    std_transfer_credit_detail.external_grade,
    std_transfer_credit_detail.course_grade,
    std_transfer_credit_detail.earn_credit,
    std_transfer_credit_detail.include_in_gpa,
    std_transfer_credit_detail.requirement_designation,
    std_transfer_credit_detail.units_attempted_code,
    std_transfer_credit_detail.student_take_units,
    std_transfer_credit_detail.student_ap_units,
    std_transfer_credit_detail.grading_basis,
    std_transfer_credit_detail.valid_attempt,
    std_transfer_credit_detail.grade_category,
    t.subject_code,
    t.catalog
   FROM ((_quest.std_transfer_credit_detail
     LEFT JOIN _quest.off_course_as_of USING (term_id, course_id))
     LEFT JOIN ( SELECT cal_course_label_history.course_id,
            cal_course_label_history.course_as_of,
            cal_course_label_history.label_seq,
            cal_course_label_history.subject_code,
            cal_course_label_history.catalog
           FROM _quest.cal_course_label_history) t USING (course_id, course_as_of, label_seq));


ALTER TABLE _quest.std_transfer_credit_detail_plus OWNER TO _quest_root;

--
-- Name: VIEW std_transfer_credit_detail_plus; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_transfer_credit_detail_plus IS 'std_transfer_credit_detail plus information about the course for which credit is given';


--
-- Name: std_transfer_credit_school; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_transfer_credit_school (
    uw_id _quest.quest_uw_id NOT NULL,
    career_code _quest.quest_career NOT NULL,
    transfer_group integer NOT NULL,
    program_code text NOT NULL,
    plan_code text,
    school_type text NOT NULL,
    source_school_name text NOT NULL,
    model_status text NOT NULL,
    transfer_units_attempted_towards_gpa numeric(8,3),
    transfer_units_attempted_not_towards_gpa numeric(8,3),
    transfer_units_passed_toward_gpa numeric(8,3),
    transfer_units_passed_not_toward_gpa numeric(8,3),
    transferred_grade_points numeric(9,3),
    transferred_gpa numeric(8,3),
    include_in_gpa boolean NOT NULL,
    comments text,
    CONSTRAINT std_transfer_credit_school_model_status_check CHECK (((model_status = 'P'::text) OR (model_status = 'M'::text)))
);


ALTER TABLE _quest.std_transfer_credit_school OWNER TO _quest_root;

--
-- Name: off_instruct_section_meet; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_instruct_section_meet (
    term_id _quest.quest_term_id NOT NULL,
    section_id integer NOT NULL,
    meet_id integer NOT NULL,
    facility_id text,
    meet_times public.timerange NOT NULL,
    meet_days bit(7) NOT NULL,
    meet_dates daterange NOT NULL
);


ALTER TABLE _quest.off_instruct_section_meet OWNER TO _quest_root;

--
-- Name: uw_room; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_room (
    building_id integer NOT NULL,
    room_code text NOT NULL,
    facility_as_of date NOT NULL,
    room_description text NOT NULL,
    facility_active boolean NOT NULL,
    facility_id text NOT NULL,
    facility_type_code text NOT NULL,
    location_code text NOT NULL,
    room_capacity integer NOT NULL,
    unit_code text,
    facility_partition integer
);


ALTER TABLE _quest.uw_room OWNER TO _quest_root;

--
-- Name: TABLE uw_room; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_room IS 'A room in which events may be held';


--
-- Name: std_student; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_student (
    uw_id _quest.quest_uw_id NOT NULL,
    gender_code text NOT NULL,
    birthdate date,
    deathdate date,
    userid _quest.quest_userid,
    email text,
    wlu_id text,
    privacy_flag boolean NOT NULL,
    aboriginal_flag boolean,
    visible_minority_code text
);


ALTER TABLE _quest.std_student OWNER TO _quest_root;

--
-- Name: std_term; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    career_code _quest.quest_career NOT NULL,
    career_num integer NOT NULL,
    registration_status _quest.quest_registration_status,
    eligible_to_enrol boolean NOT NULL,
    withdraw_code _quest.quest_withdraw_code NOT NULL,
    withdraw_reason text,
    withdraw_date date,
    last_date_attended date,
    approved_load _quest.quest_load NOT NULL,
    actual_load _quest.quest_load NOT NULL,
    projected_level text,
    form_of_study text NOT NULL,
    study_agreement text,
    term_gpa numeric(8,3) NOT NULL,
    cumulative_gpa numeric(8,3) NOT NULL,
    coop_term_type_code text,
    coop_workterm_status text,
    standing_action_date date,
    standing_code text,
    standing_program_code text,
    standing_status _quest.quest_standing_status,
    transcript_text text,
    has_classes boolean NOT NULL,
    has_transfer_credits boolean NOT NULL
);


ALTER TABLE _quest.std_term OWNER TO _quest_root;

--
-- Name: TABLE std_term; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.std_term IS 'Summary of each academic term; mostly from ps_stdnt_car_term.';


--
-- Name: std_term_plan; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_plan (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    plan_code text NOT NULL,
    plan_order integer NOT NULL,
    requirement_term_id _quest.quest_term_id NOT NULL,
    degree_id _quest.quest_degree_id,
    plan_position integer NOT NULL
);


ALTER TABLE _quest.std_term_plan OWNER TO _quest_root;

--
-- Name: std_term_program; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_program (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    program_code text NOT NULL,
    program_as_of date NOT NULL,
    program_sequence integer NOT NULL,
    program_status_code text NOT NULL,
    program_action_code text NOT NULL,
    action_date date NOT NULL,
    program_reason text,
    admit_term_id _quest.quest_term_id NOT NULL,
    expected_grad_term_id _quest.quest_term_id,
    requirement_term_id _quest.quest_term_id NOT NULL,
    approved_load _quest.quest_load NOT NULL,
    campus_code text NOT NULL,
    completion_term_id _quest.quest_term_id,
    data_from_adm_appl boolean NOT NULL
);


ALTER TABLE _quest.std_term_program OWNER TO _quest_root;

--
-- Name: adm_appl; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    career_code _quest.quest_career NOT NULL,
    appl_application_centre text NOT NULL,
    appl_admit_type text NOT NULL,
    appl_financial_aid_interest boolean NOT NULL,
    appl_housing_interest text,
    appl_last_school_org_id _quest.quest_org_id,
    appl_application_date date NOT NULL,
    appl_graduation_date date,
    appl_prior_application boolean NOT NULL,
    appl_application_method text,
    appl_academic_level text
);


ALTER TABLE _quest.adm_appl OWNER TO _quest_root;

--
-- Name: adm_appl_condition; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_condition (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    condition_code text NOT NULL,
    condition_status_code text NOT NULL
);


ALTER TABLE _quest.adm_appl_condition OWNER TO _quest_root;

--
-- Name: TABLE adm_appl_condition; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_appl_condition IS 'An admission condition that applies to an application';


--
-- Name: COLUMN adm_appl_condition.condition_status_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_appl_condition.condition_status_code IS 'The current status of the admission condition';


--
-- Name: adm_appl_program_comment; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_program_comment (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    program_order integer NOT NULL,
    adm_comment_code text NOT NULL,
    adm_comment_text text
);


ALTER TABLE _quest.adm_appl_program_comment OWNER TO _quest_root;

--
-- Name: adm_appl_program_evaluation; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_program_evaluation (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    program_order integer NOT NULL,
    evaluation_code text NOT NULL,
    evaluation_num integer NOT NULL,
    evaluation_complete boolean NOT NULL,
    evaluation_date date NOT NULL
);


ALTER TABLE _quest.adm_appl_program_evaluation OWNER TO _quest_root;

--
-- Name: TABLE adm_appl_program_evaluation; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_appl_program_evaluation IS 'An evaluation of an application';


--
-- Name: COLUMN adm_appl_program_evaluation.evaluation_complete; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_appl_program_evaluation.evaluation_complete IS 'Whether the evaluation is complete';


--
-- Name: COLUMN adm_appl_program_evaluation.evaluation_date; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_appl_program_evaluation.evaluation_date IS 'When the evaluation was conducted';


--
-- Name: adm_appl_program_evaluation_cmp; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_program_evaluation_cmp (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    program_order integer NOT NULL,
    evaluation_code text NOT NULL,
    evaluation_num integer NOT NULL,
    rating_cmp text NOT NULL,
    rating_cmp_value numeric(9,4) NOT NULL
);


ALTER TABLE _quest.adm_appl_program_evaluation_cmp OWNER TO _quest_root;

--
-- Name: TABLE adm_appl_program_evaluation_cmp; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_appl_program_evaluation_cmp IS 'A specific value of an evaluation of an application';


--
-- Name: COLUMN adm_appl_program_evaluation_cmp.rating_cmp_value; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_appl_program_evaluation_cmp.rating_cmp_value IS 'The value of the evaluation';


--
-- Name: adm_appl_program_financial_aid_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_program_financial_aid_history (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    program_order integer NOT NULL,
    aid_category_code text NOT NULL,
    aid_as_of date NOT NULL,
    aid_sequence integer NOT NULL,
    aid_amount numeric(8,2) NOT NULL,
    aid_status_code text NOT NULL
);


ALTER TABLE _quest.adm_appl_program_financial_aid_history OWNER TO _quest_root;

--
-- Name: TABLE adm_appl_program_financial_aid_history; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_appl_program_financial_aid_history IS 'A financial aid application as of a date';


--
-- Name: COLUMN adm_appl_program_financial_aid_history.aid_amount; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_appl_program_financial_aid_history.aid_amount IS 'The amount of the financial aid application';


--
-- Name: COLUMN adm_appl_program_financial_aid_history.aid_status_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_appl_program_financial_aid_history.aid_status_code IS 'The status of the financial aid application';


--
-- Name: adm_appl_referee; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_appl_referee (
    uw_id _quest.quest_uw_id NOT NULL,
    appl_id _quest.quest_appl_id NOT NULL,
    referee_seq integer NOT NULL,
    referee_name text,
    referee_title text,
    referee_institution text,
    referee_address1 text,
    referee_address2 text,
    referee_address3 text,
    referee_address4 text,
    referee_city text,
    referee_state text,
    referee_postal text,
    referee_country text NOT NULL,
    referee_phone text,
    referee_email text
);


ALTER TABLE _quest.adm_appl_referee OWNER TO _quest_root;

--
-- Name: TABLE adm_appl_referee; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_appl_referee IS 'A referee named as part of an application';


--
-- Name: adm_std_academic; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_std_academic (
    uw_id _quest.quest_uw_id NOT NULL,
    ext_org_id _quest.quest_org_id NOT NULL
);


ALTER TABLE _quest.adm_std_academic OWNER TO _quest_root;

--
-- Name: TABLE adm_std_academic; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_std_academic IS 'A previous institution attended by an applicant';


--
-- Name: adm_std_academic_attendance; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_std_academic_attendance (
    uw_id _quest.quest_uw_id NOT NULL,
    ext_org_id _quest.quest_org_id NOT NULL,
    ext_career_code text NOT NULL,
    ext_career_seq integer NOT NULL,
    start_date date,
    end_date date
);


ALTER TABLE _quest.adm_std_academic_attendance OWNER TO _quest_root;

--
-- Name: TABLE adm_std_academic_attendance; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_std_academic_attendance IS 'Attendance at a previous institution by an applicant';


--
-- Name: COLUMN adm_std_academic_attendance.start_date; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_academic_attendance.start_date IS 'The start of the attendance';


--
-- Name: COLUMN adm_std_academic_attendance.end_date; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_academic_attendance.end_date IS 'The end of the attendance';


--
-- Name: adm_std_academic_course; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_std_academic_course (
    uw_id _quest.quest_uw_id NOT NULL,
    ext_org_id _quest.quest_org_id NOT NULL,
    ext_career_code text NOT NULL,
    ext_career_seq integer NOT NULL,
    ext_course_seq integer NOT NULL,
    ext_course_type_code text NOT NULL,
    begin_date date,
    end_date date,
    ext_term_type_code text,
    student_take_units numeric(5,2) NOT NULL,
    grading_basis_code text NOT NULL,
    course_level_code text,
    course_grade text NOT NULL,
    school_course_number text NOT NULL,
    ext_subject_code text NOT NULL,
    ext_term_code text NOT NULL,
    term_year integer NOT NULL,
    course_description text NOT NULL,
    ext_academic_level_code text,
    last_update timestamp without time zone
);


ALTER TABLE _quest.adm_std_academic_course OWNER TO _quest_root;

--
-- Name: TABLE adm_std_academic_course; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_std_academic_course IS 'A course obtained from a previous institution by an applicant';


--
-- Name: adm_std_academic_degree; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_std_academic_degree (
    uw_id _quest.quest_uw_id NOT NULL,
    ext_org_id _quest.quest_org_id NOT NULL,
    ext_career_code text NOT NULL,
    ext_career_seq integer NOT NULL,
    ext_degree_seq integer NOT NULL,
    degree_code text,
    degree_date date NOT NULL,
    degree_status_code text,
    degree_specialization text
);


ALTER TABLE _quest.adm_std_academic_degree OWNER TO _quest_root;

--
-- Name: TABLE adm_std_academic_degree; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_std_academic_degree IS 'A degree in progress or obtained from a previous institution by an applicant';


--
-- Name: COLUMN adm_std_academic_degree.degree_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_academic_degree.degree_code IS 'The type of degree';


--
-- Name: COLUMN adm_std_academic_degree.degree_date; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_academic_degree.degree_date IS 'The date of the degree';


--
-- Name: COLUMN adm_std_academic_degree.degree_status_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_academic_degree.degree_status_code IS 'The status of the degree';


--
-- Name: COLUMN adm_std_academic_degree.degree_specialization; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_academic_degree.degree_specialization IS 'The specialization or topic for the degree';


--
-- Name: adm_std_academic_gpa; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_std_academic_gpa (
    uw_id _quest.quest_uw_id NOT NULL,
    ext_org_id _quest.quest_org_id NOT NULL,
    ext_career_code text NOT NULL,
    ext_career_seq integer NOT NULL,
    ext_gpa_type_code text NOT NULL,
    ext_gpa numeric(6,3) NOT NULL
);


ALTER TABLE _quest.adm_std_academic_gpa OWNER TO _quest_root;

--
-- Name: TABLE adm_std_academic_gpa; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_std_academic_gpa IS 'A GPA reported at a previous institution for an applicant';


--
-- Name: COLUMN adm_std_academic_gpa.ext_gpa; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_academic_gpa.ext_gpa IS 'The GPA reported';


--
-- Name: adm_std_employment; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_std_employment (
    uw_id _quest.quest_uw_id NOT NULL,
    start_date date NOT NULL,
    employer_name text NOT NULL,
    employer_city text,
    country_code text NOT NULL,
    end_date date,
    job_title text NOT NULL
);


ALTER TABLE _quest.adm_std_employment OWNER TO _quest_root;

--
-- Name: TABLE adm_std_employment; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_std_employment IS 'Previous employment of an applicant';


--
-- Name: adm_std_language; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_std_language (
    uw_id _quest.quest_uw_id NOT NULL,
    language_code text NOT NULL
);


ALTER TABLE _quest.adm_std_language OWNER TO _quest_root;

--
-- Name: TABLE adm_std_language; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_std_language IS 'A language fluency claimed by a student applicant';


--
-- Name: adm_std_test; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.adm_std_test (
    uw_id _quest.quest_uw_id NOT NULL,
    test_code text NOT NULL,
    test_component text NOT NULL,
    test_date date NOT NULL,
    test_source text NOT NULL,
    test_score numeric(6,2) NOT NULL,
    test_ext_academic_level text,
    test_loaded date NOT NULL
);


ALTER TABLE _quest.adm_std_test OWNER TO _quest_root;

--
-- Name: TABLE adm_std_test; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.adm_std_test IS 'A test component result reported for a student applicant';


--
-- Name: COLUMN adm_std_test.test_score; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_test.test_score IS 'The applicant''s mark on the test component';


--
-- Name: COLUMN adm_std_test.test_ext_academic_level; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_test.test_ext_academic_level IS 'The external academic level associated with the test component result';


--
-- Name: COLUMN adm_std_test.test_loaded; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.adm_std_test.test_loaded IS 'The date the test component result was loaded';


--
-- Name: cal_requisite; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.cal_requisite (
    requisite_id _quest.quest_requisite_id NOT NULL,
    requisite_as_of date NOT NULL,
    requisite_active boolean NOT NULL,
    requisite_brief_description text NOT NULL,
    requisite_short_description text NOT NULL,
    requisite_description text NOT NULL
);


ALTER TABLE _quest.cal_requisite OWNER TO _quest_root;

--
-- Name: TABLE cal_requisite; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.cal_requisite IS 'A requisite which may be required in order to enrol in a course or in a reservation slot of a section';


--
-- Name: cal_requisite_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.cal_requisite_history (
    requisite_id _quest.quest_requisite_id NOT NULL,
    requisite_as_of date NOT NULL,
    requisite_active boolean NOT NULL,
    requisite_brief_description text NOT NULL,
    requisite_short_description text NOT NULL,
    requisite_description text NOT NULL
);


ALTER TABLE _quest.cal_requisite_history OWNER TO _quest_root;

--
-- Name: cal_subject_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.cal_subject_history (
    subject_code text NOT NULL,
    subject_as_of date NOT NULL,
    subject_active boolean NOT NULL,
    subject_description text NOT NULL,
    subject_short_description text NOT NULL,
    unit_code text NOT NULL
);


ALTER TABLE _quest.cal_subject_history OWNER TO _quest_root;

--
-- Name: iso_639_3_language; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.iso_639_3_language (
    language_code text NOT NULL,
    language_part2b text,
    language_part2t text,
    language_part1 text,
    language_scope text NOT NULL,
    language_type text NOT NULL,
    language_name text NOT NULL,
    language_comment text
);


ALTER TABLE _quest.iso_639_3_language OWNER TO _quest_root;

--
-- Name: TABLE iso_639_3_language; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.iso_639_3_language IS 'A language listed in ISO 639-3';


--
-- Name: COLUMN iso_639_3_language.language_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.iso_639_3_language.language_code IS 'The three-letter 639-3 identifier';


--
-- Name: COLUMN iso_639_3_language.language_part2b; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.iso_639_3_language.language_part2b IS 'Equivalent 639-2 identifier of the bibliographic applications code set, if there is one';


--
-- Name: COLUMN iso_639_3_language.language_part2t; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.iso_639_3_language.language_part2t IS 'Equivalent 639-2 identifier of the terminology applications code set, if there is one';


--
-- Name: COLUMN iso_639_3_language.language_part1; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.iso_639_3_language.language_part1 IS 'Equivalent 639-1 identifier, if there is one';


--
-- Name: COLUMN iso_639_3_language.language_scope; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.iso_639_3_language.language_scope IS 'I(ndividual), M(acrolanguage), S(pecial)';


--
-- Name: COLUMN iso_639_3_language.language_type; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.iso_639_3_language.language_type IS 'A(ncient), C(onstructed), E(xtinct), H(istorical), L(iving), S(pecial)';


--
-- Name: COLUMN iso_639_3_language.language_name; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.iso_639_3_language.language_name IS 'Reference language name';


--
-- Name: COLUMN iso_639_3_language.language_comment; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.iso_639_3_language.language_comment IS 'Comment relating to one or more of the columns';


--
-- Name: off_association; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_association (
    term_id _quest.quest_term_id NOT NULL,
    course_id _quest.quest_course_id NOT NULL,
    label_seq integer NOT NULL,
    session_code _quest.quest_session NOT NULL,
    association_id integer NOT NULL,
    course_take_units numeric(5,2) NOT NULL,
    course_ap_units numeric(5,2) NOT NULL,
    grade_basis_code text NOT NULL,
    requirement_designation text,
    component_code text NOT NULL,
    primary_component_code text
);


ALTER TABLE _quest.off_association OWNER TO _quest_root;

--
-- Name: off_course; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_course (
    term_id _quest.quest_term_id NOT NULL,
    class_id integer NOT NULL,
    course_id _quest.quest_course_id NOT NULL,
    label_seq integer NOT NULL
);


ALTER TABLE _quest.off_course OWNER TO _quest_root;

--
-- Name: TABLE off_course; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.off_course IS 'A course enrolment section in which students may be registered and are all eligible to receive the same credit upon completion';


--
-- Name: off_course_section_note; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_course_section_note (
    term_id _quest.quest_term_id NOT NULL,
    class_id integer NOT NULL,
    section_note_id integer NOT NULL,
    note_id integer,
    note_text text,
    CONSTRAINT off_course_section_note_check CHECK (((note_id IS NULL) <> (note_text IS NULL)))
);


ALTER TABLE _quest.off_course_section_note OWNER TO _quest_root;

--
-- Name: off_course_section_reserve; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_course_section_reserve (
    term_id _quest.quest_term_id NOT NULL,
    class_id integer NOT NULL,
    reserve_id integer NOT NULL,
    reserve_enrol_limit integer NOT NULL,
    reserve_enrol_total integer NOT NULL,
    reserve_start_date date NOT NULL,
    requisite_id _quest.quest_requisite_id NOT NULL
);


ALTER TABLE _quest.off_course_section_reserve OWNER TO _quest_root;

--
-- Name: off_default_note; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_default_note (
    note_id integer NOT NULL,
    note_as_of date NOT NULL,
    note_active boolean NOT NULL,
    note_description text NOT NULL,
    note_text text NOT NULL
);


ALTER TABLE _quest.off_default_note OWNER TO _quest_root;

--
-- Name: off_default_note_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.off_default_note_history (
    note_id integer NOT NULL,
    note_as_of date NOT NULL,
    note_active boolean NOT NULL,
    note_description text NOT NULL,
    note_text text NOT NULL
);


ALTER TABLE _quest.off_default_note_history OWNER TO _quest_root;

--
-- Name: off_instruct_section_instructor_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.off_instruct_section_instructor_plus AS
 SELECT off_instruct_section_instructor.term_id,
    off_instruct_section_instructor.section_id,
    off_instruct_section_instructor.instructor_role_code,
    off_instruct_section_instructor.userid,
    watiam_entry.surname,
    COALESCE(watiam_entry.nicknames, watiam_entry.givennames) AS givennames
   FROM (_quest.off_instruct_section_instructor
     LEFT JOIN _watiam.watiam_entry USING (userid));


ALTER TABLE _quest.off_instruct_section_instructor_plus OWNER TO _quest_root;

--
-- Name: VIEW off_instruct_section_instructor_plus; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.off_instruct_section_instructor_plus IS 'Instructor information from off_instruct_section_instructor enhanced with names but missing uw_id so view can be made public';


--
-- Name: off_instruct_section_meet_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.off_instruct_section_meet_plus AS
 SELECT off_instruct_section_meet.facility_id,
    off_instruct_section_meet.term_id,
    off_instruct_section_meet.section_id,
    off_instruct_section_meet.meet_id,
    off_instruct_section_meet.meet_times,
    off_instruct_section_meet.meet_days,
    off_instruct_section_meet.meet_dates,
    uw_room.building_id,
    uw_room.room_code,
    uw_room.facility_as_of,
    uw_room.room_description,
    uw_room.facility_active,
    uw_room.facility_type_code,
    uw_room.location_code,
    uw_room.room_capacity,
    uw_room.unit_code,
    uw_room.facility_partition
   FROM (_quest.off_instruct_section_meet
     LEFT JOIN _quest.uw_room USING (facility_id));


ALTER TABLE _quest.off_instruct_section_meet_plus OWNER TO _quest_root;

--
-- Name: VIEW off_instruct_section_meet_plus; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.off_instruct_section_meet_plus IS 'off_instruct_section_meet enhanced with information about the room in which the meet takes place';


--
-- Name: pps_degree; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_degree (
    degree_code text NOT NULL,
    degree_as_of date NOT NULL,
    degree_active boolean NOT NULL,
    degree_full_title text NOT NULL,
    degree_title text NOT NULL,
    degree_short_title text NOT NULL,
    degree_years integer NOT NULL,
    degree_level text,
    degree_internal boolean NOT NULL,
    career_code _quest.quest_career
);


ALTER TABLE _quest.pps_degree OWNER TO _quest_root;

--
-- Name: pps_degree_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_degree_history (
    degree_code text NOT NULL,
    degree_as_of date NOT NULL,
    degree_active boolean NOT NULL,
    degree_full_title text NOT NULL,
    degree_title text NOT NULL,
    degree_short_title text NOT NULL,
    degree_years integer NOT NULL,
    degree_level text,
    degree_internal boolean NOT NULL,
    career_code _quest.quest_career
);


ALTER TABLE _quest.pps_degree_history OWNER TO _quest_root;

--
-- Name: pps_milestone; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_milestone (
    milestone_code text NOT NULL,
    short_description text NOT NULL,
    formal_description text NOT NULL
);


ALTER TABLE _quest.pps_milestone OWNER TO _quest_root;

--
-- Name: TABLE pps_milestone; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.pps_milestone IS 'A milestone that may be earned by a student';


--
-- Name: COLUMN pps_milestone.short_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.pps_milestone.short_description IS 'The brief description of the milestone';


--
-- Name: COLUMN pps_milestone.formal_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.pps_milestone.formal_description IS 'The formal description of the milestone';


--
-- Name: pps_plan_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_plan_history (
    plan_code text NOT NULL,
    plan_as_of date NOT NULL,
    plan_active boolean NOT NULL,
    plan_title text NOT NULL,
    plan_short_title text NOT NULL,
    plan_comment text,
    plan_diploma_description text,
    plan_transcript_description text NOT NULL,
    degree_code text,
    program_code text,
    career_code _quest.quest_career,
    unit_code text NOT NULL,
    plan_type_code text NOT NULL,
    first_valid_term_id _quest.quest_term_id,
    last_admit_term_id _quest.quest_term_id
);


ALTER TABLE _quest.pps_plan_history OWNER TO _quest_root;

--
-- Name: pps_program_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_program_history (
    program_code text NOT NULL,
    program_as_of date NOT NULL,
    program_active boolean NOT NULL,
    program_title text NOT NULL,
    program_short_title text NOT NULL,
    career_code _quest.quest_career NOT NULL,
    group_code text NOT NULL,
    unit_code text NOT NULL,
    level_load_rule_code text NOT NULL,
    first_valid_term_id _quest.quest_term_id
);


ALTER TABLE _quest.pps_program_history OWNER TO _quest_root;

--
-- Name: pps_service_indicator; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_service_indicator (
    service_indicator_code text NOT NULL,
    service_indicator_as_of date NOT NULL,
    title text NOT NULL,
    short_title text NOT NULL,
    positive_indicator boolean NOT NULL,
    display_in_self_serve boolean NOT NULL
);


ALTER TABLE _quest.pps_service_indicator OWNER TO _quest_root;

--
-- Name: pps_service_indicator_impact; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_service_indicator_impact (
    service_indicator_code text NOT NULL,
    service_impact_code text NOT NULL,
    service_impact_as_of date NOT NULL,
    term_category text,
    description text
);


ALTER TABLE _quest.pps_service_indicator_impact OWNER TO _quest_root;

--
-- Name: pps_service_indicator_reason; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_service_indicator_reason (
    service_indicator_code text NOT NULL,
    service_indicator_reason text NOT NULL,
    reason_as_of date NOT NULL,
    reason text NOT NULL,
    short_reason text NOT NULL,
    description text
);


ALTER TABLE _quest.pps_service_indicator_reason OWNER TO _quest_root;

--
-- Name: pps_standing; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_standing (
    standing_code text NOT NULL,
    standing_status_code _quest.quest_standing_status NOT NULL,
    standing_brief_description text NOT NULL,
    standing_short_description text NOT NULL,
    standing_description text NOT NULL
);


ALTER TABLE _quest.pps_standing OWNER TO _quest_root;

--
-- Name: pps_subplan_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_subplan_history (
    plan_code text NOT NULL,
    subplan_code text NOT NULL,
    subplan_as_of date NOT NULL,
    subplan_active boolean NOT NULL,
    subplan_title text NOT NULL,
    subplan_short_title text NOT NULL,
    subplan_diploma_description text,
    subplan_transcript_description text NOT NULL,
    subplan_type _quest.quest_subplan_type NOT NULL,
    first_valid_term_id _quest.quest_term_id,
    last_admit_term_id _quest.quest_term_id
);


ALTER TABLE _quest.pps_subplan_history OWNER TO _quest_root;

--
-- Name: pps_term_award; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.pps_term_award (
    award_code text NOT NULL,
    award_external boolean NOT NULL,
    award_description text NOT NULL,
    award_formal_description text NOT NULL
);


ALTER TABLE _quest.pps_term_award OWNER TO _quest_root;

--
-- Name: TABLE pps_term_award; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.pps_term_award IS 'A term award that may be earned by a student';


--
-- Name: COLUMN pps_term_award.award_external; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.pps_term_award.award_external IS 'Whether the term award is awarded externally to the University';


--
-- Name: COLUMN pps_term_award.award_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.pps_term_award.award_description IS 'The description of the term award';


--
-- Name: COLUMN pps_term_award.award_formal_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.pps_term_award.award_formal_description IS 'The formal description of the term award';


--
-- Name: std_address; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_address (
    uw_id _quest.quest_uw_id NOT NULL,
    address_type text NOT NULL,
    country text,
    address1 text,
    address2 text,
    address3 text,
    address4 text,
    city text,
    prov text,
    postal text
);


ALTER TABLE _quest.std_address OWNER TO _quest_root;

--
-- Name: std_citizenship; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_citizenship (
    uw_id _quest.quest_uw_id NOT NULL,
    country_code text NOT NULL,
    citizenship_code text
);


ALTER TABLE _quest.std_citizenship OWNER TO _quest_root;

--
-- Name: TABLE std_citizenship; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.std_citizenship IS 'A student''s citizenship status with respect to a country';


--
-- Name: COLUMN std_citizenship.citizenship_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_citizenship.citizenship_code IS 'The citizenship status of the student with respect to the country or NULL if it is not indicated';


--
-- Name: std_degree; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_degree (
    uw_id _quest.quest_uw_id NOT NULL,
    degree_id _quest.quest_degree_id NOT NULL,
    degree_code text NOT NULL,
    completion_term_id _quest.quest_term_id NOT NULL,
    degree_conferral_date date NOT NULL,
    degree_revoked boolean NOT NULL
);


ALTER TABLE _quest.std_degree OWNER TO _quest_root;

--
-- Name: std_degree_honour; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_degree_honour (
    uw_id _quest.quest_uw_id NOT NULL,
    degree_id _quest.quest_degree_id NOT NULL,
    honours_id integer NOT NULL,
    honours_code text NOT NULL,
    honours_award_date date NOT NULL
);


ALTER TABLE _quest.std_degree_honour OWNER TO _quest_root;

--
-- Name: std_degree_plan; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_degree_plan (
    uw_id _quest.quest_uw_id NOT NULL,
    degree_id _quest.quest_degree_id NOT NULL,
    plan_code text NOT NULL,
    plan_order integer NOT NULL,
    plan_position integer NOT NULL
);


ALTER TABLE _quest.std_degree_plan OWNER TO _quest_root;

--
-- Name: std_degree_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_degree_plus AS
 SELECT DISTINCT ON (std_degree.uw_id, std_degree.degree_id) std_degree.degree_code,
    std_degree.uw_id,
    std_degree.degree_id,
    std_degree.completion_term_id,
    std_degree.degree_conferral_date,
    std_degree.degree_revoked,
    pdh.degree_as_of,
    pdh.degree_active,
    pdh.degree_full_title,
    pdh.degree_title,
    pdh.degree_short_title,
    pdh.degree_years,
    pdh.degree_level,
    pdh.degree_internal,
    pdh.career_code
   FROM (_quest.std_degree
     LEFT JOIN _quest.pps_degree_history pdh USING (degree_code))
  WHERE ((pdh.degree_as_of <= std_degree.degree_conferral_date) OR (pdh.* IS NULL))
  ORDER BY std_degree.uw_id, std_degree.degree_id, pdh.degree_as_of DESC;


ALTER TABLE _quest.std_degree_plus OWNER TO _quest_root;

--
-- Name: VIEW std_degree_plus; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_degree_plus IS 'std_degree plus fields from the related rows of pps_degree_history';


--
-- Name: std_degree_subplan; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_degree_subplan (
    uw_id _quest.quest_uw_id NOT NULL,
    degree_id _quest.quest_degree_id NOT NULL,
    plan_code text NOT NULL,
    subplan_code text NOT NULL
);


ALTER TABLE _quest.std_degree_subplan OWNER TO _quest_root;

--
-- Name: std_grad_supervision_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_grad_supervision_history (
    uw_id _quest.quest_uw_id NOT NULL,
    supervisor_effective date NOT NULL
);


ALTER TABLE _quest.std_grad_supervision_history OWNER TO _quest_root;

--
-- Name: TABLE std_grad_supervision_history; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.std_grad_supervision_history IS 'Supervision of a graduate student as of a date';


--
-- Name: std_grad_supervision; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_grad_supervision AS
 SELECT DISTINCT ON (std_grad_supervision_history.uw_id) std_grad_supervision_history.uw_id,
    std_grad_supervision_history.supervisor_effective
   FROM _quest.std_grad_supervision_history
  ORDER BY std_grad_supervision_history.uw_id, std_grad_supervision_history.supervisor_effective DESC;


ALTER TABLE _quest.std_grad_supervision OWNER TO _quest_root;

--
-- Name: VIEW std_grad_supervision; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_grad_supervision IS 'Most up-to-date information about graduate student supervision';


--
-- Name: std_grad_supervisor; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_grad_supervisor (
    uw_id _quest.quest_uw_id NOT NULL,
    supervisor_effective date NOT NULL,
    supervisor_uw_id _quest.quest_uw_id NOT NULL,
    supervisor_seq integer NOT NULL,
    program_code text NOT NULL,
    plan_code text
);


ALTER TABLE _quest.std_grad_supervisor OWNER TO _quest_root;

--
-- Name: TABLE std_grad_supervisor; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.std_grad_supervisor IS 'Assignment of a graduate supervisor to a graduate student';


--
-- Name: COLUMN std_grad_supervisor.supervisor_seq; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_grad_supervisor.supervisor_seq IS 'The position of the supervisor for this student';


--
-- Name: COLUMN std_grad_supervisor.program_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_grad_supervisor.program_code IS 'The program for which the supervisor is assigned';


--
-- Name: COLUMN std_grad_supervisor.plan_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_grad_supervisor.plan_code IS 'The plan for which the supervisor is assigned';


--
-- Name: std_milestone; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_milestone (
    uw_id _quest.quest_uw_id NOT NULL,
    program_code text NOT NULL,
    milestone_order integer NOT NULL,
    plan_code text,
    milestone_code text NOT NULL,
    milestone_title text,
    milestone_complete _quest.quest_completion_code NOT NULL,
    date_completed date,
    milestone_comments text,
    milestone_id integer NOT NULL
);


ALTER TABLE _quest.std_milestone OWNER TO _quest_root;

--
-- Name: std_name; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_name (
    uw_id _quest.quest_uw_id NOT NULL,
    name_type_code text NOT NULL,
    name_as_of date NOT NULL,
    name_title text,
    last_name text NOT NULL,
    first_name text NOT NULL,
    middle_name text
);


ALTER TABLE _quest.std_name OWNER TO _quest_root;

--
-- Name: TABLE std_name; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.std_name IS 'Student name; may be primary (PRI) or preferred (PRF)';


--
-- Name: std_name_preferred; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_name_preferred AS
 SELECT std_name.uw_id,
    std_name.name_type_code,
    std_name.name_as_of,
    std_name.name_title,
    std_name.last_name,
    std_name.first_name,
    std_name.middle_name
   FROM _quest.std_name
  WHERE (std_name.name_type_code = 'PRF'::text);


ALTER TABLE _quest.std_name_preferred OWNER TO _quest_root;

--
-- Name: VIEW std_name_preferred; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_name_preferred IS 'Student preferred name';


--
-- Name: std_name_primary; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_name_primary AS
 SELECT std_name.uw_id,
    std_name.name_type_code,
    std_name.name_as_of,
    std_name.name_title,
    std_name.last_name,
    std_name.first_name,
    std_name.middle_name
   FROM _quest.std_name
  WHERE (std_name.name_type_code = 'PRI'::text);


ALTER TABLE _quest.std_name_primary OWNER TO _quest_root;

--
-- Name: VIEW std_name_primary; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_name_primary IS 'Student primary name';


--
-- Name: std_photo; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_photo (
    uw_id _quest.quest_uw_id NOT NULL,
    photo_as_of date NOT NULL,
    photo_original_md5 text NOT NULL,
    photo_standard bytea NOT NULL
);


ALTER TABLE _quest.std_photo OWNER TO _quest_root;

--
-- Name: TABLE std_photo; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.std_photo IS 'The WatCard photo for the student';


--
-- Name: COLUMN std_photo.photo_as_of; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_photo.photo_as_of IS 'When this photo was loaded';


--
-- Name: COLUMN std_photo.photo_original_md5; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_photo.photo_original_md5 IS 'MD5 of the original photo supplied by WatCard';


--
-- Name: COLUMN std_photo.photo_standard; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_photo.photo_standard IS 'The photo re-sized to a standard size';


--
-- Name: std_plan_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_plan_history (
    uw_id _quest.quest_uw_id NOT NULL,
    career_code _quest.quest_career NOT NULL,
    career_num integer NOT NULL,
    program_as_of date NOT NULL,
    program_sequence integer NOT NULL,
    plan_code text NOT NULL,
    plan_order integer NOT NULL,
    requirement_term_id _quest.quest_term_id,
    degree_id _quest.quest_degree_id,
    plan_position integer NOT NULL
);


ALTER TABLE _quest.std_plan_history OWNER TO _quest_root;

--
-- Name: std_program_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_program_history (
    uw_id _quest.quest_uw_id NOT NULL,
    career_code _quest.quest_career NOT NULL,
    career_num integer NOT NULL,
    program_as_of date NOT NULL,
    program_sequence integer NOT NULL,
    program_code text NOT NULL,
    program_status_code text NOT NULL,
    program_action_code text NOT NULL,
    action_date date NOT NULL,
    program_reason text,
    admit_term_id _quest.quest_term_id NOT NULL,
    expected_grad_term_id _quest.quest_term_id,
    requirement_term_id _quest.quest_term_id,
    approved_load _quest.quest_load NOT NULL,
    campus_code text NOT NULL,
    completion_term_id _quest.quest_term_id,
    data_from_adm_appl boolean NOT NULL
);


ALTER TABLE _quest.std_program_history OWNER TO _quest_root;

--
-- Name: std_service_indicator; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_service_indicator (
    uw_id _quest.quest_uw_id NOT NULL,
    service_indicator_as_of timestamp without time zone NOT NULL,
    service_indicator_code text NOT NULL,
    service_indicator_reason text NOT NULL,
    active_term _quest.quest_term_id,
    active_date date NOT NULL
);


ALTER TABLE _quest.std_service_indicator OWNER TO _quest_root;

--
-- Name: std_subplan_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_subplan_history (
    uw_id _quest.quest_uw_id NOT NULL,
    career_code _quest.quest_career NOT NULL,
    career_num integer NOT NULL,
    program_as_of date NOT NULL,
    program_sequence integer NOT NULL,
    plan_code text NOT NULL,
    subplan_code text NOT NULL,
    requirement_term_id _quest.quest_term_id NOT NULL
);


ALTER TABLE _quest.std_subplan_history OWNER TO _quest_root;

--
-- Name: std_term_award; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_award (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    award_code text NOT NULL,
    date_received date NOT NULL
);


ALTER TABLE _quest.std_term_award OWNER TO _quest_root;

--
-- Name: TABLE std_term_award; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.std_term_award IS 'A term award received by a student';


--
-- Name: COLUMN std_term_award.date_received; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_term_award.date_received IS 'When the award was received';


--
-- Name: std_term_course_demand; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_course_demand (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    class_id integer NOT NULL,
    instruction_mode _quest.quest_instruction_mode,
    instruction_mode_optional _quest.quest_option,
    priority integer,
    location_code text,
    campus_code text,
    campus_optional _quest.quest_option,
    apply_ng_grade boolean NOT NULL,
    demand_as_of timestamp without time zone NOT NULL,
    CONSTRAINT std_term_course_demand_check CHECK (((location_code IS NULL) = (campus_code IS NULL))),
    CONSTRAINT std_term_course_demand_priority_check CHECK (((priority >= 1) AND (priority <= 9)))
);


ALTER TABLE _quest.std_term_course_demand OWNER TO _quest_root;

--
-- Name: std_term_course_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_term_course_plus AS
 SELECT stc.uw_id,
    stc.term_id,
    stc.class_id,
    stc.course_grade,
    stc.earn_credit,
    stc.include_in_gpa,
    stc.requirement_designation,
    stc.requirement_designation_grade,
    stc.units_attempted_code,
    stc.grade_points,
    stc.student_take_units,
    stc.student_ap_units,
    stc.grading_basis,
    stc.valid_attempt,
    stc.grade_category,
    stc.grade_submission_date,
    stc.transcript_note,
    off_course_section_plus.course_id,
    off_course_section_plus.course_as_of,
    off_course_section_plus.label_seq,
    off_course_section_plus.subject_code,
    off_course_section_plus.catalog,
    off_course_section_plus.campus_code,
    off_course_section_plus.group_code,
    off_course_section_plus.unit_code,
    off_course_section_plus.career_code,
    off_course_section_plus.requisite_id,
    off_course_section_plus.label_schedule_print
   FROM (_quest.std_term_course stc
     LEFT JOIN _quest.off_course_section_plus USING (term_id, class_id));


ALTER TABLE _quest.std_term_course_plus OWNER TO _quest_root;

--
-- Name: std_term_grad_supervision; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_term_grad_supervision AS
 SELECT std_term.term_id,
    sgs.uw_id,
    sgs.supervisor_effective
   FROM ((_quest.std_term
     JOIN _quest.uw_term USING (term_id))
     JOIN LATERAL ( SELECT DISTINCT ON (std_grad_supervision_history.uw_id) std_grad_supervision_history.uw_id,
            std_grad_supervision_history.supervisor_effective
           FROM _quest.std_grad_supervision_history
          WHERE (std_grad_supervision_history.supervisor_effective < upper(uw_term.term_dates))
          ORDER BY std_grad_supervision_history.uw_id, std_grad_supervision_history.supervisor_effective DESC) sgs USING (uw_id));


ALTER TABLE _quest.std_term_grad_supervision OWNER TO _quest_root;

--
-- Name: VIEW std_term_grad_supervision; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_term_grad_supervision IS 'Most up-to-date information about graduate student supervision as of each term';


--
-- Name: std_term_plan_gpa; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_plan_gpa (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    plan_code text NOT NULL,
    gpa_type_code text NOT NULL,
    gpa numeric(8,3),
    gpa_date date
);


ALTER TABLE _quest.std_term_plan_gpa OWNER TO _quest_root;

--
-- Name: std_term_plan_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_term_plan_plus AS
 SELECT std_term_plan.plan_code,
    std_term_plan.uw_id,
    std_term_plan.term_id,
    std_term_plan.plan_order,
    std_term_plan.requirement_term_id,
    std_term_plan.degree_id,
    std_term_plan.plan_position,
    pps_plan.plan_as_of,
    pps_plan.plan_active,
    pps_plan.plan_title,
    pps_plan.plan_short_title,
    pps_plan.plan_comment,
    pps_plan.plan_diploma_description,
    pps_plan.plan_transcript_description,
    pps_plan.degree_code,
    pps_plan.program_code,
    pps_plan.career_code,
    pps_plan.unit_code,
    pps_plan.plan_type_code,
    pps_plan.first_valid_term_id,
    pps_plan.last_admit_term_id
   FROM (_quest.std_term_plan
     JOIN _quest.pps_plan USING (plan_code));


ALTER TABLE _quest.std_term_plan_plus OWNER TO _quest_root;

--
-- Name: std_term_program_history; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_term_program_history AS
 SELECT uw_term.term_id AS request_term_id,
    std_student.uw_id,
    public.repeat_agg(stp.term_id) OVER (PARTITION BY std_student.uw_id ORDER BY uw_term.term_id) AS term_id
   FROM ((_quest.uw_term
     CROSS JOIN _quest.std_student)
     LEFT JOIN _quest.std_term stp USING (term_id, uw_id));


ALTER TABLE _quest.std_term_program_history OWNER TO _quest_root;

--
-- Name: VIEW std_term_program_history; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_term_program_history IS 'Most recent term activation for students as of each term';


--
-- Name: std_term_program_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_term_program_plus AS
 SELECT stp.uw_id,
    stp.term_id,
    stp.program_code,
    stp.program_as_of,
    stp.program_sequence,
    stp.program_status_code,
    stp.program_action_code,
    stp.action_date,
    stp.program_reason,
    stp.admit_term_id,
    stp.expected_grad_term_id,
    stp.requirement_term_id,
    stp.approved_load,
    stp.campus_code,
    stp.completion_term_id,
    stp.data_from_adm_appl,
    pps_program.program_title,
    pps_program.program_short_title
   FROM (_quest.std_term_program stp
     JOIN _quest.pps_program USING (program_code));


ALTER TABLE _quest.std_term_program_plus OWNER TO _quest_root;

--
-- Name: VIEW std_term_program_plus; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_term_program_plus IS 'std_term_program plus program titles';


--
-- Name: std_term_subplan; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_subplan (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    plan_code text NOT NULL,
    subplan_code text NOT NULL,
    requirement_term_id _quest.quest_term_id NOT NULL
);


ALTER TABLE _quest.std_term_subplan OWNER TO _quest_root;

--
-- Name: std_term_subplan_gpa; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_subplan_gpa (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    plan_code text NOT NULL,
    subplan_code text NOT NULL,
    gpa_type_code text NOT NULL,
    gpa numeric(8,3),
    gpa_date date
);


ALTER TABLE _quest.std_term_subplan_gpa OWNER TO _quest_root;

--
-- Name: std_term_units; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.std_term_units (
    uw_id _quest.quest_uw_id NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    override_max_units boolean NOT NULL,
    max_total_unit_load numeric(5,2) NOT NULL,
    max_nogpa_unit_load numeric(5,2) NOT NULL,
    term_academic_units_attempted numeric(8,3) NOT NULL,
    term_academic_units_passed numeric(8,3) NOT NULL,
    term_units_attempted_in_gpa numeric(8,3) NOT NULL,
    term_units_passed_in_gpa numeric(8,3) NOT NULL,
    term_units_attempted_not_in_gpa numeric(8,3) NOT NULL,
    term_units_passed_not_in_gpa numeric(8,3) NOT NULL,
    term_units_in_progress_towards_gpa numeric(8,3) NOT NULL,
    term_units_in_progress_not_towards_gpa numeric(8,3) NOT NULL,
    term_grade_points numeric(9,3) NOT NULL,
    term_units_audited numeric(8,3) NOT NULL,
    term_units_transferred numeric(8,3) NOT NULL,
    term_units_total numeric(8,3) NOT NULL,
    transferred_units_attempted_towards_gpa numeric(8,3) NOT NULL,
    transferred_units_attempted_not_towards_gpa numeric(8,3) NOT NULL,
    transferred_units_passed_in_gpa numeric(8,3) NOT NULL,
    transferred_units_passed_not_in_gpa numeric(8,3) NOT NULL,
    transferred_grade_points numeric(9,3) NOT NULL,
    reset_cum_stats boolean NOT NULL,
    cum_academic_units_attempted numeric(8,3) NOT NULL,
    cum_academic_units_passed numeric(8,3) NOT NULL,
    cum_units_attempted_in_gpa numeric(8,3) NOT NULL,
    cum_units_passed_in_gpa numeric(8,3) NOT NULL,
    cum_units_attempted_not_in_gpa numeric(8,3) NOT NULL,
    cum_units_passed_not_in_gpa numeric(8,3) NOT NULL,
    cum_units_in_progress_towards_gpa numeric(8,3) NOT NULL,
    cum_units_in_progress_not_towards_gpa numeric(8,3) NOT NULL,
    cum_units_audited numeric(8,3) NOT NULL,
    cum_units_transferred numeric(8,3) NOT NULL,
    cum_units_total numeric(8,3) NOT NULL,
    cum_grade_points numeric(9,3) NOT NULL,
    resident_terms_credited numeric(6,3) NOT NULL,
    resident_terms_adjustment numeric(6,3) NOT NULL,
    cum_resident_terms numeric(6,3) NOT NULL
);


ALTER TABLE _quest.std_term_units OWNER TO _quest_root;

--
-- Name: COLUMN std_term_units.term_units_attempted_not_in_gpa; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_term_units.term_units_attempted_not_in_gpa IS 'Includes non-academic (PD) courses.';


--
-- Name: COLUMN std_term_units.cum_academic_units_passed; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.std_term_units.cum_academic_units_passed IS 'Does not include transfer credits.';


--
-- Name: std_transfer_credit_school_plus; Type: VIEW; Schema: _quest; Owner: _quest_root
--

CREATE VIEW _quest.std_transfer_credit_school_plus AS
 SELECT std_transfer_credit_school.uw_id,
    std_transfer_credit_school.career_code,
    std_transfer_credit_school.transfer_group,
    std_transfer_credit_school.program_code,
    std_transfer_credit_school.plan_code,
    std_transfer_credit_school.school_type,
    std_transfer_credit_school.source_school_name,
    std_transfer_credit_school.model_status,
    std_transfer_credit_school.transfer_units_attempted_towards_gpa,
    std_transfer_credit_school.transfer_units_attempted_not_towards_gpa,
    std_transfer_credit_school.transfer_units_passed_toward_gpa,
    std_transfer_credit_school.transfer_units_passed_not_toward_gpa,
    std_transfer_credit_school.transferred_grade_points,
    std_transfer_credit_school.transferred_gpa,
    std_transfer_credit_school.include_in_gpa,
    std_transfer_credit_school.comments,
    t.student_take_units,
    t.student_ap_units
   FROM (_quest.std_transfer_credit_school
     LEFT JOIN ( SELECT std_transfer_credit_detail.uw_id,
            std_transfer_credit_detail.career_code,
            std_transfer_credit_detail.transfer_group,
            sum(std_transfer_credit_detail.student_take_units) AS student_take_units,
            sum(std_transfer_credit_detail.student_ap_units) AS student_ap_units
           FROM _quest.std_transfer_credit_detail
          GROUP BY std_transfer_credit_detail.uw_id, std_transfer_credit_detail.career_code, std_transfer_credit_detail.transfer_group) t USING (uw_id, career_code, transfer_group));


ALTER TABLE _quest.std_transfer_credit_school_plus OWNER TO _quest_root;

--
-- Name: VIEW std_transfer_credit_school_plus; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON VIEW _quest.std_transfer_credit_school_plus IS 'std_transfer_credit_school plus summary columns depending on std_transfer_credit_detail';


--
-- Name: update_notification; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.update_notification (
    notification_id integer NOT NULL,
    process_id integer NOT NULL,
    process_code text NOT NULL,
    notification_time timestamp without time zone DEFAULT now() NOT NULL,
    run_id integer
);


ALTER TABLE _quest.update_notification OWNER TO _quest_root;

--
-- Name: TABLE update_notification; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.update_notification IS 'A notification received from Quest of extract process completion';


--
-- Name: COLUMN update_notification.process_id; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.update_notification.process_id IS 'The Quest process ID of the notification';


--
-- Name: COLUMN update_notification.process_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.update_notification.process_code IS 'The Quest process code of the notification';


--
-- Name: COLUMN update_notification.notification_time; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.update_notification.notification_time IS 'When the notification was recorded';


--
-- Name: COLUMN update_notification.run_id; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.update_notification.run_id IS 'The run_id, if any, this notification contributes to making ready';


--
-- Name: update_notification_notification_id_seq; Type: SEQUENCE; Schema: _quest; Owner: _quest_root
--

CREATE SEQUENCE _quest.update_notification_notification_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE _quest.update_notification_notification_id_seq OWNER TO _quest_root;

--
-- Name: update_notification_notification_id_seq; Type: SEQUENCE OWNED BY; Schema: _quest; Owner: _quest_root
--

ALTER SEQUENCE _quest.update_notification_notification_id_seq OWNED BY _quest.update_notification.notification_id;


--
-- Name: update_process; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.update_process (
    process_code text NOT NULL,
    process_description text NOT NULL
);


ALTER TABLE _quest.update_process OWNER TO _quest_root;

--
-- Name: update_run; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.update_run (
    run_id integer NOT NULL,
    run_created timestamp without time zone DEFAULT now() NOT NULL,
    run_ready timestamp without time zone,
    run_loaded timestamp without time zone
);


ALTER TABLE _quest.update_run OWNER TO _quest_root;

--
-- Name: TABLE update_run; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.update_run IS 'An update run, i.e. a set of notifications expected to be received';


--
-- Name: COLUMN update_run.run_created; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.update_run.run_created IS 'When this run was created';


--
-- Name: COLUMN update_run.run_ready; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.update_run.run_ready IS 'When the final notification for this run was received';


--
-- Name: COLUMN update_run.run_loaded; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.update_run.run_loaded IS 'When the data update process for this run finished';


--
-- Name: update_run_notification; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.update_run_notification (
    run_id integer NOT NULL,
    process_code text NOT NULL
);


ALTER TABLE _quest.update_run_notification OWNER TO _quest_root;

--
-- Name: TABLE update_run_notification; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.update_run_notification IS 'An expected notification associated with an import run';


--
-- Name: update_run_run_id_seq; Type: SEQUENCE; Schema: _quest; Owner: _quest_root
--

CREATE SEQUENCE _quest.update_run_run_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE _quest.update_run_run_id_seq OWNER TO _quest_root;

--
-- Name: update_run_run_id_seq; Type: SEQUENCE OWNED BY; Schema: _quest; Owner: _quest_root
--

ALTER SEQUENCE _quest.update_run_run_id_seq OWNED BY _quest.update_run.run_id;


--
-- Name: uw_adm_comment; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_adm_comment (
    adm_comment_code text NOT NULL,
    adm_comment_description text NOT NULL
);


ALTER TABLE _quest.uw_adm_comment OWNER TO _quest_root;

--
-- Name: TABLE uw_adm_comment; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_adm_comment IS 'A possible comment type for an application';


--
-- Name: uw_aid_category; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_aid_category (
    aid_category_code text NOT NULL,
    aid_category_description text NOT NULL
);


ALTER TABLE _quest.uw_aid_category OWNER TO _quest_root;

--
-- Name: TABLE uw_aid_category; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_aid_category IS 'A possible category for a financial aid application';


--
-- Name: uw_aid_status; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_aid_status (
    aid_status_code text NOT NULL,
    aid_status_description text NOT NULL
);


ALTER TABLE _quest.uw_aid_status OWNER TO _quest_root;

--
-- Name: TABLE uw_aid_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_aid_status IS 'A possible status for a financial aid application';


--
-- Name: uw_appl_method; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_appl_method (
    appl_method_code text NOT NULL,
    appl_method_description text NOT NULL
);


ALTER TABLE _quest.uw_appl_method OWNER TO _quest_root;

--
-- Name: TABLE uw_appl_method; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_appl_method IS 'A possible method of application submission';


--
-- Name: uw_building; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_building (
    building_id integer NOT NULL,
    building_as_of date NOT NULL,
    building_active boolean NOT NULL,
    building_code text NOT NULL,
    building_description text NOT NULL
);


ALTER TABLE _quest.uw_building OWNER TO _quest_root;

--
-- Name: TABLE uw_building; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_building IS 'A building on campus as of the most recent update to that building';


--
-- Name: COLUMN uw_building.building_as_of; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_building.building_as_of IS 'When this version of the building is effective';


--
-- Name: COLUMN uw_building.building_active; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_building.building_active IS 'Whether the building is currently active';


--
-- Name: COLUMN uw_building.building_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_building.building_code IS 'The short code for this building';


--
-- Name: COLUMN uw_building.building_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_building.building_description IS 'The name of this building';


--
-- Name: uw_building_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_building_history (
    building_id integer NOT NULL,
    building_as_of date NOT NULL,
    building_active boolean NOT NULL,
    building_code text NOT NULL,
    building_description text NOT NULL
);


ALTER TABLE _quest.uw_building_history OWNER TO _quest_root;

--
-- Name: TABLE uw_building_history; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_building_history IS 'A building on campus as of a specific date';


--
-- Name: COLUMN uw_building_history.building_active; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_building_history.building_active IS 'Whether the building is active';


--
-- Name: COLUMN uw_building_history.building_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_building_history.building_code IS 'The short code for this building';


--
-- Name: COLUMN uw_building_history.building_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_building_history.building_description IS 'The name of this building';


--
-- Name: uw_campus; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_campus (
    campus_code text NOT NULL,
    campus_as_of date NOT NULL,
    campus_active boolean NOT NULL,
    campus_description text NOT NULL,
    campus_short_description text NOT NULL,
    location_code text NOT NULL
);


ALTER TABLE _quest.uw_campus OWNER TO _quest_root;

--
-- Name: TABLE uw_campus; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_campus IS 'A campus on which classes may be held, as of the most recent update to that campus in uw_campus_history';


--
-- Name: uw_campus_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_campus_history (
    campus_code text NOT NULL,
    campus_as_of date NOT NULL,
    campus_active boolean NOT NULL,
    campus_description text NOT NULL,
    campus_short_description text NOT NULL,
    location_code text NOT NULL
);


ALTER TABLE _quest.uw_campus_history OWNER TO _quest_root;

--
-- Name: TABLE uw_campus_history; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_campus_history IS 'A campus on which classes may be held, as of a particular date';


--
-- Name: uw_citizenship; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_citizenship (
    citizenship_code text NOT NULL,
    citizenship_description text NOT NULL
);


ALTER TABLE _quest.uw_citizenship OWNER TO _quest_root;

--
-- Name: TABLE uw_citizenship; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_citizenship IS 'A citizenship status';


--
-- Name: COLUMN uw_citizenship.citizenship_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_citizenship.citizenship_description IS 'A brief description of the citizenship status';


--
-- Name: uw_condition; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_condition (
    condition_code text NOT NULL,
    condition_description text NOT NULL
);


ALTER TABLE _quest.uw_condition OWNER TO _quest_root;

--
-- Name: TABLE uw_condition; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_condition IS 'A possible condition that may be applied to an admissions application';


--
-- Name: uw_condition_status; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_condition_status (
    condition_status_code text NOT NULL,
    condition_status_description text NOT NULL
);


ALTER TABLE _quest.uw_condition_status OWNER TO _quest_root;

--
-- Name: TABLE uw_condition_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_condition_status IS 'A possible status for an admissions application condition';


--
-- Name: uw_coop_term_type; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_coop_term_type (
    coop_term_type_code text NOT NULL,
    coop_term_type_description text NOT NULL
);


ALTER TABLE _quest.uw_coop_term_type OWNER TO _quest_root;

--
-- Name: TABLE uw_coop_term_type; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_coop_term_type IS 'A possible co-op term type';


--
-- Name: uw_coop_workterm_status; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_coop_workterm_status (
    coop_workterm_status_code text NOT NULL,
    coop_workterm_status_description text NOT NULL
);


ALTER TABLE _quest.uw_coop_workterm_status OWNER TO _quest_root;

--
-- Name: TABLE uw_coop_workterm_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_coop_workterm_status IS 'A possible co-op workterm status';


--
-- Name: uw_country; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_country (
    country_code text NOT NULL,
    country_name text NOT NULL,
    country_short_name text NOT NULL,
    country_short_code text NOT NULL
);


ALTER TABLE _quest.uw_country OWNER TO _quest_root;

--
-- Name: TABLE uw_country; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_country IS 'A country of the world';


--
-- Name: COLUMN uw_country.country_name; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_country.country_name IS 'The full name of the country';


--
-- Name: COLUMN uw_country.country_short_name; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_country.country_short_name IS 'The short name of the country';


--
-- Name: COLUMN uw_country.country_short_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_country.country_short_code IS 'The two-letter ISO code for the country';


--
-- Name: uw_country_citizenship; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_country_citizenship (
    country_code text NOT NULL,
    citizenship_code text NOT NULL
);


ALTER TABLE _quest.uw_country_citizenship OWNER TO _quest_root;

--
-- Name: TABLE uw_country_citizenship; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_country_citizenship IS 'A citizenship status valid for a country';


--
-- Name: uw_course_level; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_course_level (
    course_level_code text NOT NULL,
    course_level_description text NOT NULL
);


ALTER TABLE _quest.uw_course_level OWNER TO _quest_root;

--
-- Name: TABLE uw_course_level; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_course_level IS 'A possible course level for a course';


--
-- Name: uw_date; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_date (
    date date NOT NULL,
    term_id _quest.quest_term_id NOT NULL,
    business_day integer,
    holiday_code text,
    class_weekday bit(7),
    exam_day boolean,
    CONSTRAINT uw_date_check CHECK (((business_day IS NULL) OR (holiday_code IS NULL))),
    CONSTRAINT uw_date_check1 CHECK (((class_weekday IS NULL) OR (NOT exam_day)))
);


ALTER TABLE _quest.uw_date OWNER TO _quest_root;

--
-- Name: TABLE uw_date; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_date IS 'A calendar date';


--
-- Name: COLUMN uw_date.term_id; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_date.term_id IS 'The term to which this date belongs';


--
-- Name: COLUMN uw_date.business_day; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_date.business_day IS 'The sequential number of this business day, or NULL if it is not a business day for the University';


--
-- Name: COLUMN uw_date.holiday_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_date.holiday_code IS 'The holiday code for this holiday, or NULL if it is not a holiday for the University';


--
-- Name: COLUMN uw_date.class_weekday; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_date.class_weekday IS 'The day of the week this is deemed to be for class scheduling purposes, or NULL if this is not a regular class day';


--
-- Name: COLUMN uw_date.exam_day; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_date.exam_day IS 'Whether this day is a scheduled examination day, or NULL if the examination dates for the term have not been released';


--
-- Name: uw_ext_academic_level; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_academic_level (
    ext_academic_level_code text NOT NULL,
    ext_academic_level_description text NOT NULL
);


ALTER TABLE _quest.uw_ext_academic_level OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_academic_level; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_academic_level IS 'A possible academic level for an external course';


--
-- Name: uw_ext_career; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_career (
    ext_career_code text NOT NULL,
    ext_career_description text NOT NULL
);


ALTER TABLE _quest.uw_ext_career OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_career; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_career IS 'A possible career for a previous academic attendance';


--
-- Name: uw_ext_course_type; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_course_type (
    ext_course_type_code text NOT NULL,
    ext_course_type_description text NOT NULL
);


ALTER TABLE _quest.uw_ext_course_type OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_course_type; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_course_type IS 'A possible course type for an external course';


--
-- Name: uw_ext_degree_status; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_degree_status (
    degree_status_code text NOT NULL,
    degree_status_description text NOT NULL
);


ALTER TABLE _quest.uw_ext_degree_status OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_degree_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_degree_status IS 'A possible status for a previous degree';


--
-- Name: uw_ext_gpa_type; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_gpa_type (
    ext_gpa_type_code text NOT NULL,
    ext_gpa_type_description text NOT NULL
);


ALTER TABLE _quest.uw_ext_gpa_type OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_gpa_type; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_gpa_type IS 'A possible GPA type for a previous academic attendance';


--
-- Name: uw_ext_org; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_org (
    ext_org_id _quest.quest_org_id NOT NULL,
    ext_org_name text NOT NULL,
    country_code text NOT NULL
);


ALTER TABLE _quest.uw_ext_org OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_org; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_org IS 'An external organization';


--
-- Name: COLUMN uw_ext_org.ext_org_name; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_ext_org.ext_org_name IS 'The name of the organization';


--
-- Name: COLUMN uw_ext_org.country_code; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_ext_org.country_code IS 'The country of the organization';


--
-- Name: uw_ext_subject; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_subject (
    ext_subject_code text NOT NULL,
    ext_subject_description text NOT NULL
);


ALTER TABLE _quest.uw_ext_subject OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_subject; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_subject IS 'A possible subject area for an external course';


--
-- Name: uw_ext_term; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_term (
    ext_term_code text NOT NULL,
    ext_term_description text NOT NULL
);


ALTER TABLE _quest.uw_ext_term OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_term; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_term IS 'A possible term for an external course';


--
-- Name: uw_ext_term_type; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_ext_term_type (
    ext_term_type_code text NOT NULL,
    ext_term_type_description text NOT NULL
);


ALTER TABLE _quest.uw_ext_term_type OWNER TO _quest_root;

--
-- Name: TABLE uw_ext_term_type; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_ext_term_type IS 'A possible term type for an external course';


--
-- Name: uw_form_of_study; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_form_of_study (
    form_of_study_code text NOT NULL,
    form_of_study_description text NOT NULL
);


ALTER TABLE _quest.uw_form_of_study OWNER TO _quest_root;

--
-- Name: TABLE uw_form_of_study; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_form_of_study IS 'A possible form of study';


--
-- Name: uw_gender; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_gender (
    gender_code text NOT NULL,
    gender_description text NOT NULL
);


ALTER TABLE _quest.uw_gender OWNER TO _quest_root;

--
-- Name: TABLE uw_gender; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_gender IS 'A possible gender value';


--
-- Name: COLUMN uw_gender.gender_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_gender.gender_description IS 'A brief display description of the gender value';


--
-- Name: uw_grading_basis; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_grading_basis (
    grading_basis_code text NOT NULL,
    grading_basis_description text NOT NULL
);


ALTER TABLE _quest.uw_grading_basis OWNER TO _quest_root;

--
-- Name: TABLE uw_grading_basis; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_grading_basis IS 'A possible grading basis for a course';


--
-- Name: uw_group; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_group (
    group_code text NOT NULL,
    group_as_of date NOT NULL,
    group_active boolean NOT NULL,
    group_quest_name text NOT NULL
);


ALTER TABLE _quest.uw_group OWNER TO _quest_root;

--
-- Name: TABLE uw_group; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_group IS 'An academic group (faculty, affiliated college, or other group), as of the most recent update to that group in uw_group_history';


--
-- Name: uw_group_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_group_history (
    group_code text NOT NULL,
    group_as_of date NOT NULL,
    group_active boolean NOT NULL,
    group_quest_name text NOT NULL
);


ALTER TABLE _quest.uw_group_history OWNER TO _quest_root;

--
-- Name: TABLE uw_group_history; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_group_history IS 'An academic group (faculty, affiliated college, or other group), as of a particular date';


--
-- Name: uw_holiday_type; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_holiday_type (
    holiday_code text NOT NULL,
    holiday_description text NOT NULL
);


ALTER TABLE _quest.uw_holiday_type OWNER TO _quest_root;

--
-- Name: TABLE uw_holiday_type; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_holiday_type IS 'A name that may be applied to a declared University holiday';


--
-- Name: COLUMN uw_holiday_type.holiday_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_holiday_type.holiday_description IS 'A brief readable description of the holiday';


--
-- Name: uw_location; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_location (
    location_code text NOT NULL,
    location_as_of date NOT NULL,
    location_active boolean NOT NULL,
    location_quest_description text NOT NULL,
    country_code text NOT NULL
);


ALTER TABLE _quest.uw_location OWNER TO _quest_root;

--
-- Name: TABLE uw_location; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_location IS 'A location in which events may be held, as of the most recent update to that location in uw_location_history';


--
-- Name: uw_location_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_location_history (
    location_code text NOT NULL,
    location_as_of date NOT NULL,
    location_active boolean NOT NULL,
    location_quest_description text NOT NULL,
    country_code text NOT NULL
);


ALTER TABLE _quest.uw_location_history OWNER TO _quest_root;

--
-- Name: TABLE uw_location_history; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_location_history IS 'A location in which events may be held, as of a particular date';


--
-- Name: uw_program_action; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_program_action (
    program_action_code text NOT NULL,
    program_action_description text NOT NULL
);


ALTER TABLE _quest.uw_program_action OWNER TO _quest_root;

--
-- Name: TABLE uw_program_action; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_program_action IS 'A possible action that can be applied to a student with respect to a program';


--
-- Name: uw_program_status; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_program_status (
    program_status_code text NOT NULL,
    program_status_description text NOT NULL
);


ALTER TABLE _quest.uw_program_status OWNER TO _quest_root;

--
-- Name: TABLE uw_program_status; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_program_status IS 'A possible status of a student in a program';


--
-- Name: uw_unit_history; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_unit_history (
    unit_code text NOT NULL,
    unit_as_of date NOT NULL,
    unit_active boolean NOT NULL,
    unit_short_description text NOT NULL,
    unit_description text NOT NULL,
    unit_full_description text NOT NULL,
    campus_code text NOT NULL,
    group_code text NOT NULL
);


ALTER TABLE _quest.uw_unit_history OWNER TO _quest_root;

--
-- Name: TABLE uw_unit_history; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_unit_history IS 'An academic unit (department, school, or other unit) as of a particular date';


--
-- Name: uw_visible_minority; Type: TABLE; Schema: _quest; Owner: _quest_root
--

CREATE TABLE _quest.uw_visible_minority (
    visible_minority_code text NOT NULL,
    visible_minority_description text NOT NULL
);


ALTER TABLE _quest.uw_visible_minority OWNER TO _quest_root;

--
-- Name: TABLE uw_visible_minority; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON TABLE _quest.uw_visible_minority IS 'A possible visible minority classification';


--
-- Name: COLUMN uw_visible_minority.visible_minority_description; Type: COMMENT; Schema: _quest; Owner: _quest_root
--

COMMENT ON COLUMN _quest.uw_visible_minority.visible_minority_description IS 'A brief display description of the visible minority classification';


--
-- Name: notification_id; Type: DEFAULT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_notification ALTER COLUMN notification_id SET DEFAULT nextval('_quest.update_notification_notification_id_seq'::regclass);


--
-- Name: run_id; Type: DEFAULT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_run ALTER COLUMN run_id SET DEFAULT nextval('_quest.update_run_run_id_seq'::regclass);


--
-- Name: adm_appl_condition_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_condition
    ADD CONSTRAINT adm_appl_condition_pkey PRIMARY KEY (uw_id, appl_id, condition_code);


--
-- Name: adm_appl_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl
    ADD CONSTRAINT adm_appl_pkey PRIMARY KEY (uw_id, appl_id);


--
-- Name: adm_appl_plan_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_plan
    ADD CONSTRAINT adm_appl_plan_pkey PRIMARY KEY (uw_id, appl_id, program_order, program_as_of, program_sequence, plan_code);


--
-- Name: adm_appl_program_comment_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_comment
    ADD CONSTRAINT adm_appl_program_comment_pkey PRIMARY KEY (uw_id, appl_id, program_order, adm_comment_code);


--
-- Name: adm_appl_program_evaluation_cmp_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_evaluation_cmp
    ADD CONSTRAINT adm_appl_program_evaluation_cmp_pkey PRIMARY KEY (uw_id, appl_id, program_order, evaluation_code, evaluation_num, rating_cmp);


--
-- Name: adm_appl_program_evaluation_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_evaluation
    ADD CONSTRAINT adm_appl_program_evaluation_pkey PRIMARY KEY (uw_id, appl_id, program_order, evaluation_code, evaluation_num);


--
-- Name: adm_appl_program_financial_aid_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_financial_aid_history
    ADD CONSTRAINT adm_appl_program_financial_aid_history_pkey PRIMARY KEY (uw_id, appl_id, program_order, aid_category_code, aid_as_of, aid_sequence);


--
-- Name: adm_appl_program_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_history
    ADD CONSTRAINT adm_appl_program_history_pkey PRIMARY KEY (uw_id, appl_id, program_order, program_as_of, program_sequence);


--
-- Name: adm_appl_program_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program
    ADD CONSTRAINT adm_appl_program_pkey PRIMARY KEY (uw_id, appl_id, program_order);


--
-- Name: adm_appl_referee_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_referee
    ADD CONSTRAINT adm_appl_referee_pkey PRIMARY KEY (uw_id, appl_id, referee_seq);


--
-- Name: adm_appl_subplan_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_subplan
    ADD CONSTRAINT adm_appl_subplan_pkey PRIMARY KEY (uw_id, appl_id, program_order, program_as_of, program_sequence, plan_code, subplan_code);


--
-- Name: adm_std_academic_attendance_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_attendance
    ADD CONSTRAINT adm_std_academic_attendance_pkey PRIMARY KEY (uw_id, ext_org_id, ext_career_code, ext_career_seq);


--
-- Name: adm_std_academic_course_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_course
    ADD CONSTRAINT adm_std_academic_course_pkey PRIMARY KEY (uw_id, ext_org_id, ext_career_code, ext_career_seq, ext_course_seq);


--
-- Name: adm_std_academic_degree_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_degree
    ADD CONSTRAINT adm_std_academic_degree_pkey PRIMARY KEY (uw_id, ext_org_id, ext_career_code, ext_career_seq, ext_degree_seq);


--
-- Name: adm_std_academic_gpa_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_gpa
    ADD CONSTRAINT adm_std_academic_gpa_pkey PRIMARY KEY (uw_id, ext_org_id, ext_career_code, ext_career_seq, ext_gpa_type_code);


--
-- Name: adm_std_academic_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic
    ADD CONSTRAINT adm_std_academic_pkey PRIMARY KEY (uw_id, ext_org_id);


--
-- Name: adm_std_employment_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_employment
    ADD CONSTRAINT adm_std_employment_pkey PRIMARY KEY (uw_id, start_date, employer_name);


--
-- Name: adm_std_language_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_language
    ADD CONSTRAINT adm_std_language_pkey PRIMARY KEY (uw_id, language_code);


--
-- Name: adm_std_test_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_test
    ADD CONSTRAINT adm_std_test_pkey PRIMARY KEY (uw_id, test_code, test_component, test_date, test_source);


--
-- Name: cal_course_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_history
    ADD CONSTRAINT cal_course_history_pkey PRIMARY KEY (course_id, course_as_of);


--
-- Name: cal_course_label_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_label_history
    ADD CONSTRAINT cal_course_label_history_pkey PRIMARY KEY (course_id, course_as_of, label_seq);


--
-- Name: cal_course_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course
    ADD CONSTRAINT cal_course_pkey PRIMARY KEY (course_id);


--
-- Name: cal_course_topic_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_topic_history
    ADD CONSTRAINT cal_course_topic_history_pkey PRIMARY KEY (course_id, course_as_of, topic_seq);


--
-- Name: cal_requisite_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_requisite_history
    ADD CONSTRAINT cal_requisite_history_pkey PRIMARY KEY (requisite_id, requisite_as_of);


--
-- Name: cal_requisite_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_requisite
    ADD CONSTRAINT cal_requisite_pkey PRIMARY KEY (requisite_id);


--
-- Name: cal_subject_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_subject_history
    ADD CONSTRAINT cal_subject_history_pkey PRIMARY KEY (subject_code, subject_as_of);


--
-- Name: cal_subject_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_subject
    ADD CONSTRAINT cal_subject_pkey PRIMARY KEY (subject_code);


--
-- Name: iso_639_3_language_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.iso_639_3_language
    ADD CONSTRAINT iso_639_3_language_pkey PRIMARY KEY (language_code);


--
-- Name: off_association_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_association
    ADD CONSTRAINT off_association_pkey PRIMARY KEY (term_id, course_id, label_seq, session_code, association_id);


--
-- Name: off_course_as_of_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_as_of
    ADD CONSTRAINT off_course_as_of_pkey PRIMARY KEY (term_id, course_id);


--
-- Name: off_course_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course
    ADD CONSTRAINT off_course_pkey PRIMARY KEY (term_id, class_id);


--
-- Name: off_course_section_note_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section_note
    ADD CONSTRAINT off_course_section_note_pkey PRIMARY KEY (term_id, class_id, section_note_id);


--
-- Name: off_course_section_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section
    ADD CONSTRAINT off_course_section_pkey PRIMARY KEY (term_id, class_id);


--
-- Name: off_course_section_reserve_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section_reserve
    ADD CONSTRAINT off_course_section_reserve_pkey PRIMARY KEY (term_id, class_id, reserve_id);


--
-- Name: off_course_section_term_id_course_id_label_seq_session_code_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section
    ADD CONSTRAINT off_course_section_term_id_course_id_label_seq_session_code_key UNIQUE (term_id, course_id, label_seq, session_code, section_code);


--
-- Name: off_course_section_term_id_section_id_class_id_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section
    ADD CONSTRAINT off_course_section_term_id_section_id_class_id_key UNIQUE (term_id, section_id, class_id);


--
-- Name: off_default_note_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_default_note_history
    ADD CONSTRAINT off_default_note_history_pkey PRIMARY KEY (note_id, note_as_of);


--
-- Name: off_default_note_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_default_note
    ADD CONSTRAINT off_default_note_pkey PRIMARY KEY (note_id);


--
-- Name: off_instruct_section_instructor_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section_instructor
    ADD CONSTRAINT off_instruct_section_instructor_pkey PRIMARY KEY (term_id, section_id, uw_id);


--
-- Name: off_instruct_section_meet_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section_meet
    ADD CONSTRAINT off_instruct_section_meet_pkey PRIMARY KEY (term_id, section_id, meet_id);


--
-- Name: off_instruct_section_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section
    ADD CONSTRAINT off_instruct_section_pkey PRIMARY KEY (term_id, section_id);


--
-- Name: pps_degree_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_degree_history
    ADD CONSTRAINT pps_degree_history_pkey PRIMARY KEY (degree_code, degree_as_of);


--
-- Name: pps_degree_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_degree
    ADD CONSTRAINT pps_degree_pkey PRIMARY KEY (degree_code);


--
-- Name: pps_milestone_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_milestone
    ADD CONSTRAINT pps_milestone_pkey PRIMARY KEY (milestone_code);


--
-- Name: pps_plan_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan_history
    ADD CONSTRAINT pps_plan_history_pkey PRIMARY KEY (plan_code, plan_as_of);


--
-- Name: pps_plan_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan
    ADD CONSTRAINT pps_plan_pkey PRIMARY KEY (plan_code);


--
-- Name: pps_program_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program_history
    ADD CONSTRAINT pps_program_history_pkey PRIMARY KEY (program_code, program_as_of);


--
-- Name: pps_program_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program
    ADD CONSTRAINT pps_program_pkey PRIMARY KEY (program_code);


--
-- Name: pps_service_indicator_impact_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_service_indicator_impact
    ADD CONSTRAINT pps_service_indicator_impact_pkey PRIMARY KEY (service_indicator_code, service_impact_code);


--
-- Name: pps_service_indicator_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_service_indicator
    ADD CONSTRAINT pps_service_indicator_pkey PRIMARY KEY (service_indicator_code);


--
-- Name: pps_service_indicator_reason_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_service_indicator_reason
    ADD CONSTRAINT pps_service_indicator_reason_pkey PRIMARY KEY (service_indicator_code, service_indicator_reason);


--
-- Name: pps_standing_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_standing
    ADD CONSTRAINT pps_standing_pkey PRIMARY KEY (standing_code);


--
-- Name: pps_subplan_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_subplan_history
    ADD CONSTRAINT pps_subplan_history_pkey PRIMARY KEY (plan_code, subplan_code, subplan_as_of);


--
-- Name: pps_subplan_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_subplan
    ADD CONSTRAINT pps_subplan_pkey PRIMARY KEY (plan_code, subplan_code);


--
-- Name: pps_term_award_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_term_award
    ADD CONSTRAINT pps_term_award_pkey PRIMARY KEY (award_code);


--
-- Name: std_address_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_address
    ADD CONSTRAINT std_address_pkey PRIMARY KEY (uw_id, address_type);


--
-- Name: std_citizenship_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_citizenship
    ADD CONSTRAINT std_citizenship_pkey PRIMARY KEY (uw_id, country_code);


--
-- Name: std_degree_honour_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_honour
    ADD CONSTRAINT std_degree_honour_pkey PRIMARY KEY (uw_id, degree_id, honours_id);


--
-- Name: std_degree_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree
    ADD CONSTRAINT std_degree_pkey PRIMARY KEY (uw_id, degree_id);


--
-- Name: std_degree_plan_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_plan
    ADD CONSTRAINT std_degree_plan_pkey PRIMARY KEY (uw_id, degree_id, plan_code);


--
-- Name: std_degree_plan_uw_id_degree_id_plan_order_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_plan
    ADD CONSTRAINT std_degree_plan_uw_id_degree_id_plan_order_key UNIQUE (uw_id, degree_id, plan_order);


--
-- Name: std_degree_subplan_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_subplan
    ADD CONSTRAINT std_degree_subplan_pkey PRIMARY KEY (uw_id, degree_id, plan_code, subplan_code);


--
-- Name: std_grad_supervision_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_grad_supervision_history
    ADD CONSTRAINT std_grad_supervision_history_pkey PRIMARY KEY (uw_id, supervisor_effective);


--
-- Name: std_grad_supervisor_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_grad_supervisor
    ADD CONSTRAINT std_grad_supervisor_pkey PRIMARY KEY (uw_id, supervisor_effective, supervisor_uw_id);


--
-- Name: std_milestone_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_milestone
    ADD CONSTRAINT std_milestone_pkey PRIMARY KEY (uw_id, program_code, milestone_order);


--
-- Name: std_name_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_name
    ADD CONSTRAINT std_name_pkey PRIMARY KEY (uw_id, name_type_code);


--
-- Name: std_photo_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_photo
    ADD CONSTRAINT std_photo_pkey PRIMARY KEY (uw_id);


--
-- Name: std_plan_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_plan_history
    ADD CONSTRAINT std_plan_history_pkey PRIMARY KEY (uw_id, career_code, career_num, program_as_of, program_sequence, plan_code);


--
-- Name: std_plan_history_uw_id_career_code_career_num_program_as_of_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_plan_history
    ADD CONSTRAINT std_plan_history_uw_id_career_code_career_num_program_as_of_key UNIQUE (uw_id, career_code, career_num, program_as_of, program_sequence, plan_order) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: std_program_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_pkey PRIMARY KEY (uw_id, career_code, career_num, program_as_of, program_sequence);


--
-- Name: std_service_indicator_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_service_indicator
    ADD CONSTRAINT std_service_indicator_pkey PRIMARY KEY (uw_id, service_indicator_as_of);


--
-- Name: std_student_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_student
    ADD CONSTRAINT std_student_pkey PRIMARY KEY (uw_id);


--
-- Name: std_subplan_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_subplan_history
    ADD CONSTRAINT std_subplan_history_pkey PRIMARY KEY (uw_id, career_code, career_num, program_as_of, program_sequence, plan_code, subplan_code);


--
-- Name: std_term_award_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_award
    ADD CONSTRAINT std_term_award_pkey PRIMARY KEY (uw_id, term_id, award_code);


--
-- Name: std_term_course_demand_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_course_demand
    ADD CONSTRAINT std_term_course_demand_pkey PRIMARY KEY (uw_id, term_id, class_id);


--
-- Name: std_term_course_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_course
    ADD CONSTRAINT std_term_course_pkey PRIMARY KEY (uw_id, term_id, class_id);


--
-- Name: std_term_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term
    ADD CONSTRAINT std_term_pkey PRIMARY KEY (uw_id, term_id);


--
-- Name: std_term_plan_gpa_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_plan_gpa
    ADD CONSTRAINT std_term_plan_gpa_pkey PRIMARY KEY (uw_id, term_id, plan_code, gpa_type_code);


--
-- Name: std_term_plan_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_plan
    ADD CONSTRAINT std_term_plan_pkey PRIMARY KEY (uw_id, term_id, plan_code);


--
-- Name: std_term_plan_uw_id_term_id_plan_order_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_plan
    ADD CONSTRAINT std_term_plan_uw_id_term_id_plan_order_key UNIQUE (uw_id, term_id, plan_order) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: std_term_program_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_pkey PRIMARY KEY (uw_id, term_id);


--
-- Name: std_term_section_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_section
    ADD CONSTRAINT std_term_section_pkey PRIMARY KEY (uw_id, term_id, class_id);


--
-- Name: std_term_subplan_gpa_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_subplan_gpa
    ADD CONSTRAINT std_term_subplan_gpa_pkey PRIMARY KEY (uw_id, term_id, plan_code, subplan_code, gpa_type_code);


--
-- Name: std_term_subplan_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_subplan
    ADD CONSTRAINT std_term_subplan_pkey PRIMARY KEY (uw_id, term_id, plan_code, subplan_code);


--
-- Name: std_term_units_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_units
    ADD CONSTRAINT std_term_units_pkey PRIMARY KEY (uw_id, term_id);


--
-- Name: std_transfer_credit_detail_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_transfer_credit_detail
    ADD CONSTRAINT std_transfer_credit_detail_pkey PRIMARY KEY (uw_id, career_code, transfer_group, seq_num);


--
-- Name: std_transfer_credit_school_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_transfer_credit_school
    ADD CONSTRAINT std_transfer_credit_school_pkey PRIMARY KEY (uw_id, career_code, transfer_group);


--
-- Name: update_notification_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_notification
    ADD CONSTRAINT update_notification_pkey PRIMARY KEY (notification_id);


--
-- Name: update_notification_run_id_process_code_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_notification
    ADD CONSTRAINT update_notification_run_id_process_code_key UNIQUE (run_id, process_code);


--
-- Name: update_process_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_process
    ADD CONSTRAINT update_process_pkey PRIMARY KEY (process_code);


--
-- Name: update_process_process_description_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_process
    ADD CONSTRAINT update_process_process_description_key UNIQUE (process_description);


--
-- Name: update_run_notification_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_run_notification
    ADD CONSTRAINT update_run_notification_pkey PRIMARY KEY (run_id, process_code);


--
-- Name: update_run_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_run
    ADD CONSTRAINT update_run_pkey PRIMARY KEY (run_id);


--
-- Name: uw_adm_comment_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_adm_comment
    ADD CONSTRAINT uw_adm_comment_pkey PRIMARY KEY (adm_comment_code);


--
-- Name: uw_aid_category_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_aid_category
    ADD CONSTRAINT uw_aid_category_pkey PRIMARY KEY (aid_category_code);


--
-- Name: uw_aid_status_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_aid_status
    ADD CONSTRAINT uw_aid_status_pkey PRIMARY KEY (aid_status_code);


--
-- Name: uw_appl_method_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_appl_method
    ADD CONSTRAINT uw_appl_method_pkey PRIMARY KEY (appl_method_code);


--
-- Name: uw_building_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_building_history
    ADD CONSTRAINT uw_building_history_pkey PRIMARY KEY (building_id, building_as_of);


--
-- Name: uw_building_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_building
    ADD CONSTRAINT uw_building_pkey PRIMARY KEY (building_id);


--
-- Name: uw_campus_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_campus_history
    ADD CONSTRAINT uw_campus_history_pkey PRIMARY KEY (campus_code, campus_as_of);


--
-- Name: uw_campus_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_campus
    ADD CONSTRAINT uw_campus_pkey PRIMARY KEY (campus_code);


--
-- Name: uw_citizenship_citizenship_description_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_citizenship
    ADD CONSTRAINT uw_citizenship_citizenship_description_key UNIQUE (citizenship_description);


--
-- Name: uw_citizenship_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_citizenship
    ADD CONSTRAINT uw_citizenship_pkey PRIMARY KEY (citizenship_code);


--
-- Name: uw_condition_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_condition
    ADD CONSTRAINT uw_condition_pkey PRIMARY KEY (condition_code);


--
-- Name: uw_condition_status_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_condition_status
    ADD CONSTRAINT uw_condition_status_pkey PRIMARY KEY (condition_status_code);


--
-- Name: uw_coop_term_type_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_coop_term_type
    ADD CONSTRAINT uw_coop_term_type_pkey PRIMARY KEY (coop_term_type_code);


--
-- Name: uw_coop_workterm_status_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_coop_workterm_status
    ADD CONSTRAINT uw_coop_workterm_status_pkey PRIMARY KEY (coop_workterm_status_code);


--
-- Name: uw_country_citizenship_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_country_citizenship
    ADD CONSTRAINT uw_country_citizenship_pkey PRIMARY KEY (country_code, citizenship_code);


--
-- Name: uw_country_country_short_code_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_country
    ADD CONSTRAINT uw_country_country_short_code_key UNIQUE (country_short_code);


--
-- Name: uw_country_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_country
    ADD CONSTRAINT uw_country_pkey PRIMARY KEY (country_code);


--
-- Name: uw_course_level_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_course_level
    ADD CONSTRAINT uw_course_level_pkey PRIMARY KEY (course_level_code);


--
-- Name: uw_date_business_day_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_date
    ADD CONSTRAINT uw_date_business_day_key UNIQUE (business_day) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: uw_date_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_date
    ADD CONSTRAINT uw_date_pkey PRIMARY KEY (date);


--
-- Name: uw_ext_academic_level_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_academic_level
    ADD CONSTRAINT uw_ext_academic_level_pkey PRIMARY KEY (ext_academic_level_code);


--
-- Name: uw_ext_career_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_career
    ADD CONSTRAINT uw_ext_career_pkey PRIMARY KEY (ext_career_code);


--
-- Name: uw_ext_course_type_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_course_type
    ADD CONSTRAINT uw_ext_course_type_pkey PRIMARY KEY (ext_course_type_code);


--
-- Name: uw_ext_degree_status_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_degree_status
    ADD CONSTRAINT uw_ext_degree_status_pkey PRIMARY KEY (degree_status_code);


--
-- Name: uw_ext_gpa_type_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_gpa_type
    ADD CONSTRAINT uw_ext_gpa_type_pkey PRIMARY KEY (ext_gpa_type_code);


--
-- Name: uw_ext_org_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_org
    ADD CONSTRAINT uw_ext_org_pkey PRIMARY KEY (ext_org_id);


--
-- Name: uw_ext_subject_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_subject
    ADD CONSTRAINT uw_ext_subject_pkey PRIMARY KEY (ext_subject_code);


--
-- Name: uw_ext_term_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_term
    ADD CONSTRAINT uw_ext_term_pkey PRIMARY KEY (ext_term_code);


--
-- Name: uw_ext_term_type_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_term_type
    ADD CONSTRAINT uw_ext_term_type_pkey PRIMARY KEY (ext_term_type_code);


--
-- Name: uw_form_of_study_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_form_of_study
    ADD CONSTRAINT uw_form_of_study_pkey PRIMARY KEY (form_of_study_code);


--
-- Name: uw_gender_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_gender
    ADD CONSTRAINT uw_gender_pkey PRIMARY KEY (gender_code);


--
-- Name: uw_grading_basis_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_grading_basis
    ADD CONSTRAINT uw_grading_basis_pkey PRIMARY KEY (grading_basis_code);


--
-- Name: uw_group_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_group_history
    ADD CONSTRAINT uw_group_history_pkey PRIMARY KEY (group_code, group_as_of);


--
-- Name: uw_group_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_group
    ADD CONSTRAINT uw_group_pkey PRIMARY KEY (group_code);


--
-- Name: uw_holiday_type_holiday_description_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_holiday_type
    ADD CONSTRAINT uw_holiday_type_holiday_description_key UNIQUE (holiday_description);


--
-- Name: uw_holiday_type_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_holiday_type
    ADD CONSTRAINT uw_holiday_type_pkey PRIMARY KEY (holiday_code);


--
-- Name: uw_location_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_location_history
    ADD CONSTRAINT uw_location_history_pkey PRIMARY KEY (location_code, location_as_of);


--
-- Name: uw_location_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_location
    ADD CONSTRAINT uw_location_pkey PRIMARY KEY (location_code);


--
-- Name: uw_program_action_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_program_action
    ADD CONSTRAINT uw_program_action_pkey PRIMARY KEY (program_action_code);


--
-- Name: uw_program_status_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_program_status
    ADD CONSTRAINT uw_program_status_pkey PRIMARY KEY (program_status_code);


--
-- Name: uw_room_building_id_room_code_facility_id_key; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_room
    ADD CONSTRAINT uw_room_building_id_room_code_facility_id_key UNIQUE (building_id, room_code, facility_id);


--
-- Name: uw_room_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_room
    ADD CONSTRAINT uw_room_pkey PRIMARY KEY (facility_id);


--
-- Name: uw_term_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_term
    ADD CONSTRAINT uw_term_pkey PRIMARY KEY (term_id);


--
-- Name: uw_unit_history_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_unit_history
    ADD CONSTRAINT uw_unit_history_pkey PRIMARY KEY (unit_code, unit_as_of);


--
-- Name: uw_unit_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_unit
    ADD CONSTRAINT uw_unit_pkey PRIMARY KEY (unit_code);


--
-- Name: uw_visible_minority_pkey; Type: CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_visible_minority
    ADD CONSTRAINT uw_visible_minority_pkey PRIMARY KEY (visible_minority_code);


--
-- Name: adm_appl_program_history_admit_term_id_uw_id_idx; Type: INDEX; Schema: _quest; Owner: _quest_root
--

CREATE INDEX adm_appl_program_history_admit_term_id_uw_id_idx ON _quest.adm_appl_program_history USING btree (admit_term_id, uw_id);


--
-- Name: std_grad_supervisor_supervisor_uw_id_idx; Type: INDEX; Schema: _quest; Owner: _quest_root
--

CREATE INDEX std_grad_supervisor_supervisor_uw_id_idx ON _quest.std_grad_supervisor USING btree (supervisor_uw_id);


--
-- Name: std_name_lower_idx; Type: INDEX; Schema: _quest; Owner: _quest_root
--

CREATE INDEX std_name_lower_idx ON _quest.std_name USING btree (lower(last_name));


--
-- Name: std_term_course_term_id_class_id_idx; Type: INDEX; Schema: _quest; Owner: _quest_root
--

CREATE INDEX std_term_course_term_id_class_id_idx ON _quest.std_term_course USING btree (term_id, class_id);


--
-- Name: std_term_section_term_id_class_id_idx; Type: INDEX; Schema: _quest; Owner: _quest_root
--

CREATE INDEX std_term_section_term_id_class_id_idx ON _quest.std_term_section USING btree (term_id, class_id);


--
-- Name: adm_appl_appl_application_method_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl
    ADD CONSTRAINT adm_appl_appl_application_method_fkey FOREIGN KEY (appl_application_method) REFERENCES _quest.uw_appl_method(appl_method_code);


--
-- Name: adm_appl_appl_last_school_org_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl
    ADD CONSTRAINT adm_appl_appl_last_school_org_id_fkey FOREIGN KEY (appl_last_school_org_id) REFERENCES _quest.uw_ext_org(ext_org_id);


--
-- Name: adm_appl_condition_condition_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_condition
    ADD CONSTRAINT adm_appl_condition_condition_code_fkey FOREIGN KEY (condition_code) REFERENCES _quest.uw_condition(condition_code);


--
-- Name: adm_appl_condition_condition_status_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_condition
    ADD CONSTRAINT adm_appl_condition_condition_status_code_fkey FOREIGN KEY (condition_status_code) REFERENCES _quest.uw_condition_status(condition_status_code);


--
-- Name: adm_appl_condition_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_condition
    ADD CONSTRAINT adm_appl_condition_uw_id_fkey FOREIGN KEY (uw_id, appl_id) REFERENCES _quest.adm_appl(uw_id, appl_id);


--
-- Name: adm_appl_plan_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_plan
    ADD CONSTRAINT adm_appl_plan_plan_code_fkey FOREIGN KEY (plan_code) REFERENCES _quest.pps_plan(plan_code);


--
-- Name: adm_appl_plan_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_plan
    ADD CONSTRAINT adm_appl_plan_uw_id_fkey FOREIGN KEY (uw_id, appl_id, program_order, program_as_of, program_sequence) REFERENCES _quest.adm_appl_program_history(uw_id, appl_id, program_order, program_as_of, program_sequence);


--
-- Name: adm_appl_program_admit_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program
    ADD CONSTRAINT adm_appl_program_admit_term_id_fkey FOREIGN KEY (admit_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: adm_appl_program_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program
    ADD CONSTRAINT adm_appl_program_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: adm_appl_program_comment_adm_comment_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_comment
    ADD CONSTRAINT adm_appl_program_comment_adm_comment_code_fkey FOREIGN KEY (adm_comment_code) REFERENCES _quest.uw_adm_comment(adm_comment_code);


--
-- Name: adm_appl_program_comment_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_comment
    ADD CONSTRAINT adm_appl_program_comment_uw_id_fkey FOREIGN KEY (uw_id, appl_id, program_order) REFERENCES _quest.adm_appl_program(uw_id, appl_id, program_order);


--
-- Name: adm_appl_program_evaluation_cmp_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_evaluation_cmp
    ADD CONSTRAINT adm_appl_program_evaluation_cmp_uw_id_fkey FOREIGN KEY (uw_id, appl_id, program_order, evaluation_code, evaluation_num) REFERENCES _quest.adm_appl_program_evaluation(uw_id, appl_id, program_order, evaluation_code, evaluation_num);


--
-- Name: adm_appl_program_evaluation_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_evaluation
    ADD CONSTRAINT adm_appl_program_evaluation_uw_id_fkey FOREIGN KEY (uw_id, appl_id, program_order) REFERENCES _quest.adm_appl_program(uw_id, appl_id, program_order);


--
-- Name: adm_appl_program_financial_aid_history_aid_status_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_financial_aid_history
    ADD CONSTRAINT adm_appl_program_financial_aid_history_aid_status_code_fkey FOREIGN KEY (aid_status_code) REFERENCES _quest.uw_aid_status(aid_status_code);


--
-- Name: adm_appl_program_financial_aid_history_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_financial_aid_history
    ADD CONSTRAINT adm_appl_program_financial_aid_history_uw_id_fkey FOREIGN KEY (uw_id, appl_id, program_order) REFERENCES _quest.adm_appl_program(uw_id, appl_id, program_order);


--
-- Name: adm_appl_program_history_admit_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_history
    ADD CONSTRAINT adm_appl_program_history_admit_term_id_fkey FOREIGN KEY (admit_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: adm_appl_program_history_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_history
    ADD CONSTRAINT adm_appl_program_history_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: adm_appl_program_history_program_action_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_history
    ADD CONSTRAINT adm_appl_program_history_program_action_code_fkey FOREIGN KEY (program_action_code) REFERENCES _quest.uw_program_action(program_action_code);


--
-- Name: adm_appl_program_history_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_history
    ADD CONSTRAINT adm_appl_program_history_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: adm_appl_program_history_program_status_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_history
    ADD CONSTRAINT adm_appl_program_history_program_status_code_fkey FOREIGN KEY (program_status_code) REFERENCES _quest.uw_program_status(program_status_code);


--
-- Name: adm_appl_program_history_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program_history
    ADD CONSTRAINT adm_appl_program_history_uw_id_fkey FOREIGN KEY (uw_id, appl_id, program_order) REFERENCES _quest.adm_appl_program(uw_id, appl_id, program_order);


--
-- Name: adm_appl_program_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program
    ADD CONSTRAINT adm_appl_program_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: adm_appl_program_program_status_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program
    ADD CONSTRAINT adm_appl_program_program_status_code_fkey FOREIGN KEY (program_status_code) REFERENCES _quest.uw_program_status(program_status_code);


--
-- Name: adm_appl_program_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_program
    ADD CONSTRAINT adm_appl_program_uw_id_fkey FOREIGN KEY (uw_id, appl_id) REFERENCES _quest.adm_appl(uw_id, appl_id);


--
-- Name: adm_appl_referee_referee_country_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_referee
    ADD CONSTRAINT adm_appl_referee_referee_country_fkey FOREIGN KEY (referee_country) REFERENCES _quest.uw_country(country_code);


--
-- Name: adm_appl_referee_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_referee
    ADD CONSTRAINT adm_appl_referee_uw_id_fkey FOREIGN KEY (uw_id, appl_id) REFERENCES _quest.adm_appl(uw_id, appl_id);


--
-- Name: adm_appl_subplan_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_subplan
    ADD CONSTRAINT adm_appl_subplan_plan_code_fkey FOREIGN KEY (plan_code, subplan_code) REFERENCES _quest.pps_subplan(plan_code, subplan_code);


--
-- Name: adm_appl_subplan_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_appl_subplan
    ADD CONSTRAINT adm_appl_subplan_uw_id_fkey FOREIGN KEY (uw_id, appl_id, program_order, program_as_of, program_sequence, plan_code) REFERENCES _quest.adm_appl_plan(uw_id, appl_id, program_order, program_as_of, program_sequence, plan_code);


--
-- Name: adm_std_academic_attendance_ext_career_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_attendance
    ADD CONSTRAINT adm_std_academic_attendance_ext_career_code_fkey FOREIGN KEY (ext_career_code) REFERENCES _quest.uw_ext_career(ext_career_code);


--
-- Name: adm_std_academic_attendance_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_attendance
    ADD CONSTRAINT adm_std_academic_attendance_uw_id_fkey FOREIGN KEY (uw_id, ext_org_id) REFERENCES _quest.adm_std_academic(uw_id, ext_org_id);


--
-- Name: adm_std_academic_course_course_level_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_course
    ADD CONSTRAINT adm_std_academic_course_course_level_code_fkey FOREIGN KEY (course_level_code) REFERENCES _quest.uw_course_level(course_level_code);


--
-- Name: adm_std_academic_course_ext_academic_level_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_course
    ADD CONSTRAINT adm_std_academic_course_ext_academic_level_code_fkey FOREIGN KEY (ext_academic_level_code) REFERENCES _quest.uw_ext_academic_level(ext_academic_level_code);


--
-- Name: adm_std_academic_course_ext_course_type_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_course
    ADD CONSTRAINT adm_std_academic_course_ext_course_type_code_fkey FOREIGN KEY (ext_course_type_code) REFERENCES _quest.uw_ext_course_type(ext_course_type_code);


--
-- Name: adm_std_academic_course_ext_subject_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_course
    ADD CONSTRAINT adm_std_academic_course_ext_subject_code_fkey FOREIGN KEY (ext_subject_code) REFERENCES _quest.uw_ext_subject(ext_subject_code);


--
-- Name: adm_std_academic_course_ext_term_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_course
    ADD CONSTRAINT adm_std_academic_course_ext_term_code_fkey FOREIGN KEY (ext_term_code) REFERENCES _quest.uw_ext_term(ext_term_code);


--
-- Name: adm_std_academic_course_ext_term_type_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_course
    ADD CONSTRAINT adm_std_academic_course_ext_term_type_code_fkey FOREIGN KEY (ext_term_type_code) REFERENCES _quest.uw_ext_term_type(ext_term_type_code);


--
-- Name: adm_std_academic_course_grading_basis_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_course
    ADD CONSTRAINT adm_std_academic_course_grading_basis_code_fkey FOREIGN KEY (grading_basis_code) REFERENCES _quest.uw_grading_basis(grading_basis_code);


--
-- Name: adm_std_academic_degree_degree_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_degree
    ADD CONSTRAINT adm_std_academic_degree_degree_code_fkey FOREIGN KEY (degree_code) REFERENCES _quest.pps_degree(degree_code);


--
-- Name: adm_std_academic_degree_degree_status_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_degree
    ADD CONSTRAINT adm_std_academic_degree_degree_status_code_fkey FOREIGN KEY (degree_status_code) REFERENCES _quest.uw_ext_degree_status(degree_status_code);


--
-- Name: adm_std_academic_degree_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_degree
    ADD CONSTRAINT adm_std_academic_degree_uw_id_fkey FOREIGN KEY (uw_id, ext_org_id, ext_career_code, ext_career_seq) REFERENCES _quest.adm_std_academic_attendance(uw_id, ext_org_id, ext_career_code, ext_career_seq);


--
-- Name: adm_std_academic_ext_org_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic
    ADD CONSTRAINT adm_std_academic_ext_org_id_fkey FOREIGN KEY (ext_org_id) REFERENCES _quest.uw_ext_org(ext_org_id);


--
-- Name: adm_std_academic_gpa_ext_gpa_type_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_gpa
    ADD CONSTRAINT adm_std_academic_gpa_ext_gpa_type_code_fkey FOREIGN KEY (ext_gpa_type_code) REFERENCES _quest.uw_ext_gpa_type(ext_gpa_type_code);


--
-- Name: adm_std_academic_gpa_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_academic_gpa
    ADD CONSTRAINT adm_std_academic_gpa_uw_id_fkey FOREIGN KEY (uw_id, ext_org_id, ext_career_code, ext_career_seq) REFERENCES _quest.adm_std_academic_attendance(uw_id, ext_org_id, ext_career_code, ext_career_seq);


--
-- Name: adm_std_employment_country_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_employment
    ADD CONSTRAINT adm_std_employment_country_code_fkey FOREIGN KEY (country_code) REFERENCES _quest.uw_country(country_code);


--
-- Name: adm_std_language_language_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.adm_std_language
    ADD CONSTRAINT adm_std_language_language_code_fkey FOREIGN KEY (language_code) REFERENCES _quest.iso_639_3_language(language_code);


--
-- Name: cal_course_course_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course
    ADD CONSTRAINT cal_course_course_id_fkey FOREIGN KEY (course_id, course_as_of) REFERENCES _quest.cal_course_history(course_id, course_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: cal_course_label_history_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_label_history
    ADD CONSTRAINT cal_course_label_history_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: cal_course_label_history_course_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_label_history
    ADD CONSTRAINT cal_course_label_history_course_id_fkey FOREIGN KEY (course_id) REFERENCES _quest.cal_course(course_id);


--
-- Name: cal_course_label_history_course_id_fkey1; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_label_history
    ADD CONSTRAINT cal_course_label_history_course_id_fkey1 FOREIGN KEY (course_id, course_as_of) REFERENCES _quest.cal_course_history(course_id, course_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: cal_course_label_history_group_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_label_history
    ADD CONSTRAINT cal_course_label_history_group_code_fkey FOREIGN KEY (group_code) REFERENCES _quest.uw_group(group_code);


--
-- Name: cal_course_label_history_requisite_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_label_history
    ADD CONSTRAINT cal_course_label_history_requisite_id_fkey FOREIGN KEY (requisite_id) REFERENCES _quest.cal_requisite(requisite_id);


--
-- Name: cal_course_label_history_subject_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_label_history
    ADD CONSTRAINT cal_course_label_history_subject_code_fkey FOREIGN KEY (subject_code) REFERENCES _quest.cal_subject(subject_code);


--
-- Name: cal_course_label_history_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_label_history
    ADD CONSTRAINT cal_course_label_history_unit_code_fkey FOREIGN KEY (unit_code) REFERENCES _quest.uw_unit(unit_code);


--
-- Name: cal_course_topic_history_course_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_course_topic_history
    ADD CONSTRAINT cal_course_topic_history_course_id_fkey FOREIGN KEY (course_id, course_as_of) REFERENCES _quest.cal_course_history(course_id, course_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: cal_requisite_requisite_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_requisite
    ADD CONSTRAINT cal_requisite_requisite_id_fkey FOREIGN KEY (requisite_id, requisite_as_of) REFERENCES _quest.cal_requisite_history(requisite_id, requisite_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: cal_subject_history_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_subject_history
    ADD CONSTRAINT cal_subject_history_unit_code_fkey FOREIGN KEY (unit_code) REFERENCES _quest.uw_unit(unit_code);


--
-- Name: cal_subject_subject_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_subject
    ADD CONSTRAINT cal_subject_subject_code_fkey FOREIGN KEY (subject_code, subject_as_of) REFERENCES _quest.cal_subject_history(subject_code, subject_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: cal_subject_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.cal_subject
    ADD CONSTRAINT cal_subject_unit_code_fkey FOREIGN KEY (unit_code) REFERENCES _quest.uw_unit(unit_code);


--
-- Name: off_association_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_association
    ADD CONSTRAINT off_association_term_id_fkey FOREIGN KEY (term_id, course_id) REFERENCES _quest.off_course_as_of(term_id, course_id);


--
-- Name: off_course_as_of_course_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_as_of
    ADD CONSTRAINT off_course_as_of_course_id_fkey FOREIGN KEY (course_id, course_as_of) REFERENCES _quest.cal_course_history(course_id, course_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: off_course_as_of_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_as_of
    ADD CONSTRAINT off_course_as_of_term_id_fkey FOREIGN KEY (term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: off_course_section_note_note_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section_note
    ADD CONSTRAINT off_course_section_note_note_id_fkey FOREIGN KEY (note_id) REFERENCES _quest.off_default_note(note_id);


--
-- Name: off_course_section_note_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section_note
    ADD CONSTRAINT off_course_section_note_term_id_fkey FOREIGN KEY (term_id, class_id) REFERENCES _quest.off_course_section(term_id, class_id);


--
-- Name: off_course_section_reserve_requisite_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section_reserve
    ADD CONSTRAINT off_course_section_reserve_requisite_id_fkey FOREIGN KEY (requisite_id) REFERENCES _quest.cal_requisite(requisite_id);


--
-- Name: off_course_section_reserve_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section_reserve
    ADD CONSTRAINT off_course_section_reserve_term_id_fkey FOREIGN KEY (term_id, class_id) REFERENCES _quest.off_course_section(term_id, class_id);


--
-- Name: off_course_section_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section
    ADD CONSTRAINT off_course_section_term_id_fkey FOREIGN KEY (term_id, course_id) REFERENCES _quest.off_course_as_of(term_id, course_id);


--
-- Name: off_course_section_term_id_fkey1; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section
    ADD CONSTRAINT off_course_section_term_id_fkey1 FOREIGN KEY (term_id, course_id, label_seq, session_code, association_id) REFERENCES _quest.off_association(term_id, course_id, label_seq, session_code, association_id) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: off_course_section_term_id_fkey2; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section
    ADD CONSTRAINT off_course_section_term_id_fkey2 FOREIGN KEY (term_id, course_id, label_seq, session_code, auto_enroll_1_section_code) REFERENCES _quest.off_course_section(term_id, course_id, label_seq, session_code, section_code);


--
-- Name: off_course_section_term_id_fkey3; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section
    ADD CONSTRAINT off_course_section_term_id_fkey3 FOREIGN KEY (term_id, course_id, label_seq, session_code, auto_enroll_2_section_code) REFERENCES _quest.off_course_section(term_id, course_id, label_seq, session_code, section_code);


--
-- Name: off_course_section_term_id_fkey4; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_course_section
    ADD CONSTRAINT off_course_section_term_id_fkey4 FOREIGN KEY (term_id, section_id) REFERENCES _quest.off_instruct_section(term_id, section_id) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: off_default_note_note_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_default_note
    ADD CONSTRAINT off_default_note_note_id_fkey FOREIGN KEY (note_id, note_as_of) REFERENCES _quest.off_default_note_history(note_id, note_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: off_instruct_section_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section
    ADD CONSTRAINT off_instruct_section_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: off_instruct_section_instructor_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section_instructor
    ADD CONSTRAINT off_instruct_section_instructor_term_id_fkey FOREIGN KEY (term_id, section_id) REFERENCES _quest.off_instruct_section(term_id, section_id);


--
-- Name: off_instruct_section_location_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section
    ADD CONSTRAINT off_instruct_section_location_code_fkey FOREIGN KEY (location_code) REFERENCES _quest.uw_location(location_code);


--
-- Name: off_instruct_section_meet_facility_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section_meet
    ADD CONSTRAINT off_instruct_section_meet_facility_id_fkey FOREIGN KEY (facility_id) REFERENCES _quest.uw_room(facility_id) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: off_instruct_section_meet_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section_meet
    ADD CONSTRAINT off_instruct_section_meet_term_id_fkey FOREIGN KEY (term_id, section_id) REFERENCES _quest.off_instruct_section(term_id, section_id);


--
-- Name: off_instruct_section_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.off_instruct_section
    ADD CONSTRAINT off_instruct_section_term_id_fkey FOREIGN KEY (term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_degree_degree_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_degree
    ADD CONSTRAINT pps_degree_degree_code_fkey FOREIGN KEY (degree_code, degree_as_of) REFERENCES _quest.pps_degree_history(degree_code, degree_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: pps_plan_degree_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan
    ADD CONSTRAINT pps_plan_degree_code_fkey FOREIGN KEY (degree_code) REFERENCES _quest.pps_degree(degree_code);


--
-- Name: pps_plan_first_valid_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan
    ADD CONSTRAINT pps_plan_first_valid_term_id_fkey FOREIGN KEY (first_valid_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_plan_history_degree_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan_history
    ADD CONSTRAINT pps_plan_history_degree_code_fkey FOREIGN KEY (degree_code) REFERENCES _quest.pps_degree(degree_code);


--
-- Name: pps_plan_history_first_valid_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan_history
    ADD CONSTRAINT pps_plan_history_first_valid_term_id_fkey FOREIGN KEY (first_valid_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_plan_history_last_admit_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan_history
    ADD CONSTRAINT pps_plan_history_last_admit_term_id_fkey FOREIGN KEY (last_admit_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_plan_history_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan_history
    ADD CONSTRAINT pps_plan_history_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: pps_plan_history_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan_history
    ADD CONSTRAINT pps_plan_history_unit_code_fkey FOREIGN KEY (unit_code) REFERENCES _quest.uw_unit(unit_code);


--
-- Name: pps_plan_last_admit_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan
    ADD CONSTRAINT pps_plan_last_admit_term_id_fkey FOREIGN KEY (last_admit_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_plan_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan
    ADD CONSTRAINT pps_plan_plan_code_fkey FOREIGN KEY (plan_code, plan_as_of) REFERENCES _quest.pps_plan_history(plan_code, plan_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: pps_plan_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan
    ADD CONSTRAINT pps_plan_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: pps_plan_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_plan
    ADD CONSTRAINT pps_plan_unit_code_fkey FOREIGN KEY (unit_code) REFERENCES _quest.uw_unit(unit_code);


--
-- Name: pps_program_first_valid_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program
    ADD CONSTRAINT pps_program_first_valid_term_id_fkey FOREIGN KEY (first_valid_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_program_group_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program
    ADD CONSTRAINT pps_program_group_code_fkey FOREIGN KEY (group_code) REFERENCES _quest.uw_group(group_code);


--
-- Name: pps_program_history_first_valid_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program_history
    ADD CONSTRAINT pps_program_history_first_valid_term_id_fkey FOREIGN KEY (first_valid_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_program_history_group_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program_history
    ADD CONSTRAINT pps_program_history_group_code_fkey FOREIGN KEY (group_code) REFERENCES _quest.uw_group(group_code);


--
-- Name: pps_program_history_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program_history
    ADD CONSTRAINT pps_program_history_unit_code_fkey FOREIGN KEY (unit_code) REFERENCES _quest.uw_unit(unit_code);


--
-- Name: pps_program_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program
    ADD CONSTRAINT pps_program_program_code_fkey FOREIGN KEY (program_code, program_as_of) REFERENCES _quest.pps_program_history(program_code, program_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: pps_program_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_program
    ADD CONSTRAINT pps_program_unit_code_fkey FOREIGN KEY (unit_code) REFERENCES _quest.uw_unit(unit_code);


--
-- Name: pps_service_indicator_impact_service_indicator_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_service_indicator_impact
    ADD CONSTRAINT pps_service_indicator_impact_service_indicator_code_fkey FOREIGN KEY (service_indicator_code) REFERENCES _quest.pps_service_indicator(service_indicator_code);


--
-- Name: pps_service_indicator_reason_service_indicator_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_service_indicator_reason
    ADD CONSTRAINT pps_service_indicator_reason_service_indicator_code_fkey FOREIGN KEY (service_indicator_code) REFERENCES _quest.pps_service_indicator(service_indicator_code);


--
-- Name: pps_subplan_first_valid_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_subplan
    ADD CONSTRAINT pps_subplan_first_valid_term_id_fkey FOREIGN KEY (first_valid_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_subplan_history_first_valid_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_subplan_history
    ADD CONSTRAINT pps_subplan_history_first_valid_term_id_fkey FOREIGN KEY (first_valid_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_subplan_history_last_admit_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_subplan_history
    ADD CONSTRAINT pps_subplan_history_last_admit_term_id_fkey FOREIGN KEY (last_admit_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_subplan_history_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_subplan_history
    ADD CONSTRAINT pps_subplan_history_plan_code_fkey FOREIGN KEY (plan_code) REFERENCES _quest.pps_plan(plan_code);


--
-- Name: pps_subplan_last_admit_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_subplan
    ADD CONSTRAINT pps_subplan_last_admit_term_id_fkey FOREIGN KEY (last_admit_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: pps_subplan_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.pps_subplan
    ADD CONSTRAINT pps_subplan_plan_code_fkey FOREIGN KEY (plan_code, subplan_code, subplan_as_of) REFERENCES _quest.pps_subplan_history(plan_code, subplan_code, subplan_as_of) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: std_address_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_address
    ADD CONSTRAINT std_address_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_citizenship_country_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_citizenship
    ADD CONSTRAINT std_citizenship_country_code_fkey FOREIGN KEY (country_code) REFERENCES _quest.uw_country(country_code);


--
-- Name: std_citizenship_country_code_fkey1; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_citizenship
    ADD CONSTRAINT std_citizenship_country_code_fkey1 FOREIGN KEY (country_code, citizenship_code) REFERENCES _quest.uw_country_citizenship(country_code, citizenship_code);


--
-- Name: std_citizenship_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_citizenship
    ADD CONSTRAINT std_citizenship_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_degree_degree_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree
    ADD CONSTRAINT std_degree_degree_code_fkey FOREIGN KEY (degree_code) REFERENCES _quest.pps_degree(degree_code);


--
-- Name: std_degree_honour_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_honour
    ADD CONSTRAINT std_degree_honour_uw_id_fkey FOREIGN KEY (uw_id, degree_id) REFERENCES _quest.std_degree(uw_id, degree_id);


--
-- Name: std_degree_plan_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_plan
    ADD CONSTRAINT std_degree_plan_plan_code_fkey FOREIGN KEY (plan_code) REFERENCES _quest.pps_plan(plan_code);


--
-- Name: std_degree_plan_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_plan
    ADD CONSTRAINT std_degree_plan_uw_id_fkey FOREIGN KEY (uw_id, degree_id) REFERENCES _quest.std_degree(uw_id, degree_id);


--
-- Name: std_degree_subplan_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_subplan
    ADD CONSTRAINT std_degree_subplan_plan_code_fkey FOREIGN KEY (plan_code, subplan_code) REFERENCES _quest.pps_subplan(plan_code, subplan_code);


--
-- Name: std_degree_subplan_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree_subplan
    ADD CONSTRAINT std_degree_subplan_uw_id_fkey FOREIGN KEY (uw_id, degree_id, plan_code) REFERENCES _quest.std_degree_plan(uw_id, degree_id, plan_code);


--
-- Name: std_degree_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_degree
    ADD CONSTRAINT std_degree_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_grad_supervisor_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_grad_supervisor
    ADD CONSTRAINT std_grad_supervisor_plan_code_fkey FOREIGN KEY (plan_code) REFERENCES _quest.pps_plan(plan_code);


--
-- Name: std_grad_supervisor_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_grad_supervisor
    ADD CONSTRAINT std_grad_supervisor_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: std_grad_supervisor_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_grad_supervisor
    ADD CONSTRAINT std_grad_supervisor_uw_id_fkey FOREIGN KEY (uw_id, supervisor_effective) REFERENCES _quest.std_grad_supervision_history(uw_id, supervisor_effective);


--
-- Name: std_milestone_milestone_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_milestone
    ADD CONSTRAINT std_milestone_milestone_code_fkey FOREIGN KEY (milestone_code) REFERENCES _quest.pps_milestone(milestone_code);


--
-- Name: std_milestone_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_milestone
    ADD CONSTRAINT std_milestone_plan_code_fkey FOREIGN KEY (plan_code) REFERENCES _quest.pps_plan(plan_code);


--
-- Name: std_milestone_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_milestone
    ADD CONSTRAINT std_milestone_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: std_milestone_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_milestone
    ADD CONSTRAINT std_milestone_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_plan_history_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_plan_history
    ADD CONSTRAINT std_plan_history_uw_id_fkey FOREIGN KEY (uw_id, career_code, career_num, program_as_of, program_sequence) REFERENCES _quest.std_program_history(uw_id, career_code, career_num, program_as_of, program_sequence);


--
-- Name: std_program_history_admit_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_admit_term_id_fkey FOREIGN KEY (admit_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_program_history_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: std_program_history_completion_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_completion_term_id_fkey FOREIGN KEY (completion_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_program_history_expected_grad_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_expected_grad_term_id_fkey FOREIGN KEY (expected_grad_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_program_history_program_action_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_program_action_code_fkey FOREIGN KEY (program_action_code) REFERENCES _quest.uw_program_action(program_action_code);


--
-- Name: std_program_history_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: std_program_history_program_status_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_program_status_code_fkey FOREIGN KEY (program_status_code) REFERENCES _quest.uw_program_status(program_status_code);


--
-- Name: std_program_history_requirement_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_requirement_term_id_fkey FOREIGN KEY (requirement_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_program_history_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_program_history
    ADD CONSTRAINT std_program_history_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_service_indicator_active_term_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_service_indicator
    ADD CONSTRAINT std_service_indicator_active_term_fkey FOREIGN KEY (active_term) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_service_indicator_service_indicator_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_service_indicator
    ADD CONSTRAINT std_service_indicator_service_indicator_code_fkey FOREIGN KEY (service_indicator_code, service_indicator_reason) REFERENCES _quest.pps_service_indicator_reason(service_indicator_code, service_indicator_reason);


--
-- Name: std_service_indicator_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_service_indicator
    ADD CONSTRAINT std_service_indicator_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_student_gender_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_student
    ADD CONSTRAINT std_student_gender_code_fkey FOREIGN KEY (gender_code) REFERENCES _quest.uw_gender(gender_code);


--
-- Name: std_student_visible_minority_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_student
    ADD CONSTRAINT std_student_visible_minority_code_fkey FOREIGN KEY (visible_minority_code) REFERENCES _quest.uw_visible_minority(visible_minority_code);


--
-- Name: std_subplan_history_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_subplan_history
    ADD CONSTRAINT std_subplan_history_uw_id_fkey FOREIGN KEY (uw_id, career_code, career_num, program_as_of, program_sequence, plan_code) REFERENCES _quest.std_plan_history(uw_id, career_code, career_num, program_as_of, program_sequence, plan_code) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: std_term_award_award_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_award
    ADD CONSTRAINT std_term_award_award_code_fkey FOREIGN KEY (award_code) REFERENCES _quest.pps_term_award(award_code);


--
-- Name: std_term_award_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_award
    ADD CONSTRAINT std_term_award_term_id_fkey FOREIGN KEY (term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_term_award_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_award
    ADD CONSTRAINT std_term_award_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_term_course_demand_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_course_demand
    ADD CONSTRAINT std_term_course_demand_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: std_term_course_demand_location_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_course_demand
    ADD CONSTRAINT std_term_course_demand_location_code_fkey FOREIGN KEY (location_code) REFERENCES _quest.uw_location(location_code);


--
-- Name: std_term_course_demand_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_course_demand
    ADD CONSTRAINT std_term_course_demand_term_id_fkey FOREIGN KEY (term_id, class_id) REFERENCES _quest.off_course_section(term_id, class_id);


--
-- Name: std_term_course_demand_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_course_demand
    ADD CONSTRAINT std_term_course_demand_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_term_course_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_course
    ADD CONSTRAINT std_term_course_term_id_fkey FOREIGN KEY (term_id, class_id) REFERENCES _quest.off_course(term_id, class_id);


--
-- Name: std_term_course_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_course
    ADD CONSTRAINT std_term_course_uw_id_fkey FOREIGN KEY (uw_id, term_id) REFERENCES _quest.std_term(uw_id, term_id);


--
-- Name: std_term_plan_gpa_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_plan_gpa
    ADD CONSTRAINT std_term_plan_gpa_plan_code_fkey FOREIGN KEY (plan_code) REFERENCES _quest.pps_plan(plan_code);


--
-- Name: std_term_plan_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_plan
    ADD CONSTRAINT std_term_plan_plan_code_fkey FOREIGN KEY (plan_code) REFERENCES _quest.pps_plan(plan_code);


--
-- Name: std_term_plan_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_plan
    ADD CONSTRAINT std_term_plan_uw_id_fkey FOREIGN KEY (uw_id, term_id) REFERENCES _quest.std_term_program(uw_id, term_id);


--
-- Name: std_term_program_admit_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_admit_term_id_fkey FOREIGN KEY (admit_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_term_program_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: std_term_program_completion_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_completion_term_id_fkey FOREIGN KEY (completion_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_term_program_expected_grad_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_expected_grad_term_id_fkey FOREIGN KEY (expected_grad_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_term_program_program_action_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_program_action_code_fkey FOREIGN KEY (program_action_code) REFERENCES _quest.uw_program_action(program_action_code);


--
-- Name: std_term_program_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: std_term_program_program_status_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_program_status_code_fkey FOREIGN KEY (program_status_code) REFERENCES _quest.uw_program_status(program_status_code);


--
-- Name: std_term_program_requirement_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_requirement_term_id_fkey FOREIGN KEY (requirement_term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_term_program_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_program
    ADD CONSTRAINT std_term_program_uw_id_fkey FOREIGN KEY (uw_id, term_id) REFERENCES _quest.std_term(uw_id, term_id);


--
-- Name: std_term_section_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_section
    ADD CONSTRAINT std_term_section_term_id_fkey FOREIGN KEY (term_id, class_id) REFERENCES _quest.off_course_section(term_id, class_id);


--
-- Name: std_term_section_term_id_fkey1; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_section
    ADD CONSTRAINT std_term_section_term_id_fkey1 FOREIGN KEY (term_id, class_id, reserve_id) REFERENCES _quest.off_course_section_reserve(term_id, class_id, reserve_id);


--
-- Name: std_term_section_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_section
    ADD CONSTRAINT std_term_section_uw_id_fkey FOREIGN KEY (uw_id, term_id) REFERENCES _quest.std_term(uw_id, term_id);


--
-- Name: std_term_standing_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term
    ADD CONSTRAINT std_term_standing_code_fkey FOREIGN KEY (standing_code) REFERENCES _quest.pps_standing(standing_code);


--
-- Name: std_term_standing_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term
    ADD CONSTRAINT std_term_standing_program_code_fkey FOREIGN KEY (standing_program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: std_term_subplan_gpa_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_subplan_gpa
    ADD CONSTRAINT std_term_subplan_gpa_plan_code_fkey FOREIGN KEY (plan_code, subplan_code) REFERENCES _quest.pps_subplan(plan_code, subplan_code);


--
-- Name: std_term_subplan_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_subplan
    ADD CONSTRAINT std_term_subplan_uw_id_fkey FOREIGN KEY (uw_id, term_id, plan_code) REFERENCES _quest.std_term_plan(uw_id, term_id, plan_code);


--
-- Name: std_term_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term
    ADD CONSTRAINT std_term_term_id_fkey FOREIGN KEY (term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: std_term_units_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term_units
    ADD CONSTRAINT std_term_units_uw_id_fkey FOREIGN KEY (uw_id, term_id) REFERENCES _quest.std_term(uw_id, term_id);


--
-- Name: std_term_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_term
    ADD CONSTRAINT std_term_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: std_transfer_credit_detail_course_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_transfer_credit_detail
    ADD CONSTRAINT std_transfer_credit_detail_course_id_fkey FOREIGN KEY (course_id) REFERENCES _quest.cal_course(course_id);


--
-- Name: std_transfer_credit_detail_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_transfer_credit_detail
    ADD CONSTRAINT std_transfer_credit_detail_uw_id_fkey FOREIGN KEY (uw_id, career_code, transfer_group) REFERENCES _quest.std_transfer_credit_school(uw_id, career_code, transfer_group);


--
-- Name: std_transfer_credit_detail_uw_id_fkey1; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_transfer_credit_detail
    ADD CONSTRAINT std_transfer_credit_detail_uw_id_fkey1 FOREIGN KEY (uw_id, term_id) REFERENCES _quest.std_term(uw_id, term_id) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: std_transfer_credit_school_plan_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_transfer_credit_school
    ADD CONSTRAINT std_transfer_credit_school_plan_code_fkey FOREIGN KEY (plan_code) REFERENCES _quest.pps_plan(plan_code);


--
-- Name: std_transfer_credit_school_program_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_transfer_credit_school
    ADD CONSTRAINT std_transfer_credit_school_program_code_fkey FOREIGN KEY (program_code) REFERENCES _quest.pps_program(program_code);


--
-- Name: std_transfer_credit_school_uw_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.std_transfer_credit_school
    ADD CONSTRAINT std_transfer_credit_school_uw_id_fkey FOREIGN KEY (uw_id) REFERENCES _quest.std_student(uw_id);


--
-- Name: update_notification_run_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_notification
    ADD CONSTRAINT update_notification_run_id_fkey FOREIGN KEY (run_id, process_code) REFERENCES _quest.update_run_notification(run_id, process_code);


--
-- Name: update_run_notification_process_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_run_notification
    ADD CONSTRAINT update_run_notification_process_code_fkey FOREIGN KEY (process_code) REFERENCES _quest.update_process(process_code);


--
-- Name: update_run_notification_run_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.update_run_notification
    ADD CONSTRAINT update_run_notification_run_id_fkey FOREIGN KEY (run_id) REFERENCES _quest.update_run(run_id);


--
-- Name: uw_building_building_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_building
    ADD CONSTRAINT uw_building_building_id_fkey FOREIGN KEY (building_id, building_as_of) REFERENCES _quest.uw_building_history(building_id, building_as_of);


--
-- Name: uw_campus_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_campus
    ADD CONSTRAINT uw_campus_campus_code_fkey FOREIGN KEY (campus_code, campus_as_of) REFERENCES _quest.uw_campus_history(campus_code, campus_as_of);


--
-- Name: uw_campus_history_location_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_campus_history
    ADD CONSTRAINT uw_campus_history_location_code_fkey FOREIGN KEY (location_code) REFERENCES _quest.uw_location(location_code);


--
-- Name: uw_campus_location_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_campus
    ADD CONSTRAINT uw_campus_location_code_fkey FOREIGN KEY (location_code) REFERENCES _quest.uw_location(location_code);


--
-- Name: uw_country_citizenship_citizenship_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_country_citizenship
    ADD CONSTRAINT uw_country_citizenship_citizenship_code_fkey FOREIGN KEY (citizenship_code) REFERENCES _quest.uw_citizenship(citizenship_code);


--
-- Name: uw_country_citizenship_country_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_country_citizenship
    ADD CONSTRAINT uw_country_citizenship_country_code_fkey FOREIGN KEY (country_code) REFERENCES _quest.uw_country(country_code);


--
-- Name: uw_date_holiday_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_date
    ADD CONSTRAINT uw_date_holiday_code_fkey FOREIGN KEY (holiday_code) REFERENCES _quest.uw_holiday_type(holiday_code);


--
-- Name: uw_date_term_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_date
    ADD CONSTRAINT uw_date_term_id_fkey FOREIGN KEY (term_id) REFERENCES _quest.uw_term(term_id);


--
-- Name: uw_ext_org_country_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_ext_org
    ADD CONSTRAINT uw_ext_org_country_code_fkey FOREIGN KEY (country_code) REFERENCES _quest.uw_country(country_code);


--
-- Name: uw_group_group_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_group
    ADD CONSTRAINT uw_group_group_code_fkey FOREIGN KEY (group_code, group_as_of) REFERENCES _quest.uw_group_history(group_code, group_as_of);


--
-- Name: uw_location_country_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_location
    ADD CONSTRAINT uw_location_country_code_fkey FOREIGN KEY (country_code) REFERENCES _quest.uw_country(country_code);


--
-- Name: uw_location_history_country_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_location_history
    ADD CONSTRAINT uw_location_history_country_code_fkey FOREIGN KEY (country_code) REFERENCES _quest.uw_country(country_code);


--
-- Name: uw_location_location_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_location
    ADD CONSTRAINT uw_location_location_code_fkey FOREIGN KEY (location_code, location_as_of) REFERENCES _quest.uw_location_history(location_code, location_as_of);


--
-- Name: uw_room_building_id_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_room
    ADD CONSTRAINT uw_room_building_id_fkey FOREIGN KEY (building_id) REFERENCES _quest.uw_building(building_id);


--
-- Name: uw_room_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_room
    ADD CONSTRAINT uw_room_unit_code_fkey FOREIGN KEY (unit_code) REFERENCES _quest.uw_unit(unit_code);


--
-- Name: uw_unit_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_unit
    ADD CONSTRAINT uw_unit_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: uw_unit_group_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_unit
    ADD CONSTRAINT uw_unit_group_code_fkey FOREIGN KEY (group_code) REFERENCES _quest.uw_group(group_code);


--
-- Name: uw_unit_history_campus_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_unit_history
    ADD CONSTRAINT uw_unit_history_campus_code_fkey FOREIGN KEY (campus_code) REFERENCES _quest.uw_campus(campus_code);


--
-- Name: uw_unit_history_group_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_unit_history
    ADD CONSTRAINT uw_unit_history_group_code_fkey FOREIGN KEY (group_code) REFERENCES _quest.uw_group(group_code);


--
-- Name: uw_unit_unit_code_fkey; Type: FK CONSTRAINT; Schema: _quest; Owner: _quest_root
--

ALTER TABLE ONLY _quest.uw_unit
    ADD CONSTRAINT uw_unit_unit_code_fkey FOREIGN KEY (unit_code, unit_as_of) REFERENCES _quest.uw_unit_history(unit_code, unit_as_of);


--
-- Name: SCHEMA _quest; Type: ACL; Schema: -; Owner: _dba
--

REVOKE ALL ON SCHEMA _quest FROM PUBLIC;
REVOKE ALL ON SCHEMA _quest FROM _dba;
GRANT ALL ON SCHEMA _quest TO _dba;
GRANT USAGE ON SCHEMA _quest TO PUBLIC;
GRANT ALL ON SCHEMA _quest TO _quest_root;


--
-- Name: FUNCTION cal_course_format_labels(VARIADIC course_ids integer[]); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.cal_course_format_labels(VARIADIC course_ids integer[]) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.cal_course_format_labels(VARIADIC course_ids integer[]) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.cal_course_format_labels(VARIADIC course_ids integer[]) TO _quest_core;
GRANT ALL ON FUNCTION _quest.cal_course_format_labels(VARIADIC course_ids integer[]) TO PUBLIC;


--
-- Name: FUNCTION course_format_meet_days(meet_days bit); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.course_format_meet_days(meet_days bit) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.course_format_meet_days(meet_days bit) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.course_format_meet_days(meet_days bit) TO _quest_core;
GRANT ALL ON FUNCTION _quest.course_format_meet_days(meet_days bit) TO PUBLIC;


--
-- Name: FUNCTION course_format_meet_days_short(meet_days bit); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.course_format_meet_days_short(meet_days bit) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.course_format_meet_days_short(meet_days bit) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.course_format_meet_days_short(meet_days bit) TO _quest_core;
GRANT ALL ON FUNCTION _quest.course_format_meet_days_short(meet_days bit) TO PUBLIC;


--
-- Name: FUNCTION is_academic_subject(subject text); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.is_academic_subject(subject text) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.is_academic_subject(subject text) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.is_academic_subject(subject text) TO _quest_core;
GRANT ALL ON FUNCTION _quest.is_academic_subject(subject text) TO PUBLIC;


--
-- Name: FUNCTION off_course_label_format(label_text_p _quest.off_course_label_text[]); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.off_course_label_format(label_text_p _quest.off_course_label_text[]) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.off_course_label_format(label_text_p _quest.off_course_label_text[]) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.off_course_label_format(label_text_p _quest.off_course_label_text[]) TO _quest_core;
GRANT ALL ON FUNCTION _quest.off_course_label_format(label_text_p _quest.off_course_label_text[]) TO PUBLIC;


--
-- Name: FUNCTION off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) TO _quest_core;
GRANT ALL ON FUNCTION _quest.off_course_section_format(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) TO PUBLIC;


--
-- Name: FUNCTION off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) TO _quest_core;
GRANT ALL ON FUNCTION _quest.off_course_section_format_courses(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) TO PUBLIC;


--
-- Name: FUNCTION off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) TO _quest_core;
GRANT ALL ON FUNCTION _quest.off_course_section_format_labels(term_id_p _quest.quest_term_id, VARIADIC class_ids integer[]) TO PUBLIC;


--
-- Name: FUNCTION off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) TO _quest_core;
GRANT ALL ON FUNCTION _quest.off_instruct_section_format(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) TO PUBLIC;


--
-- Name: FUNCTION off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) TO _quest_core;
GRANT ALL ON FUNCTION _quest.off_instruct_section_format_instructors(term_id_p _quest.quest_term_id, VARIADIC section_ids integer[]) TO PUBLIC;


--
-- Name: FUNCTION quest_update_tables(); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.quest_update_tables() FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.quest_update_tables() FROM _quest_core;
GRANT ALL ON FUNCTION _quest.quest_update_tables() TO _quest_core;
GRANT ALL ON FUNCTION _quest.quest_update_tables() TO PUBLIC;


--
-- Name: FUNCTION quest_update_tables_after(); Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON FUNCTION _quest.quest_update_tables_after() FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.quest_update_tables_after() FROM _quest_root;
GRANT ALL ON FUNCTION _quest.quest_update_tables_after() TO _quest_root;
GRANT ALL ON FUNCTION _quest.quest_update_tables_after() TO PUBLIC;
GRANT ALL ON FUNCTION _quest.quest_update_tables_after() TO _quest_load;


--
-- Name: FUNCTION quest_update_tables_before(); Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON FUNCTION _quest.quest_update_tables_before() FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.quest_update_tables_before() FROM _quest_root;
GRANT ALL ON FUNCTION _quest.quest_update_tables_before() TO _quest_root;
GRANT ALL ON FUNCTION _quest.quest_update_tables_before() TO PUBLIC;
GRANT ALL ON FUNCTION _quest.quest_update_tables_before() TO _quest_load;


--
-- Name: FUNCTION std_citizenship_foreign(uw_id_p _quest.quest_uw_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.std_citizenship_foreign(uw_id_p _quest.quest_uw_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.std_citizenship_foreign(uw_id_p _quest.quest_uw_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.std_citizenship_foreign(uw_id_p _quest.quest_uw_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.std_citizenship_foreign(uw_id_p _quest.quest_uw_id) TO PUBLIC;


--
-- Name: FUNCTION std_citizenship_status(uw_id_p _quest.quest_uw_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.std_citizenship_status(uw_id_p _quest.quest_uw_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.std_citizenship_status(uw_id_p _quest.quest_uw_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.std_citizenship_status(uw_id_p _quest.quest_uw_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.std_citizenship_status(uw_id_p _quest.quest_uw_id) TO PUBLIC;


--
-- Name: FUNCTION to_char(appl_id_p _quest.quest_appl_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.to_char(appl_id_p _quest.quest_appl_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.to_char(appl_id_p _quest.quest_appl_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(appl_id_p _quest.quest_appl_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(appl_id_p _quest.quest_appl_id) TO PUBLIC;


--
-- Name: FUNCTION to_char(course_id_p _quest.quest_course_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.to_char(course_id_p _quest.quest_course_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.to_char(course_id_p _quest.quest_course_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(course_id_p _quest.quest_course_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(course_id_p _quest.quest_course_id) TO PUBLIC;


--
-- Name: FUNCTION to_char(degree_id_p _quest.quest_degree_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.to_char(degree_id_p _quest.quest_degree_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.to_char(degree_id_p _quest.quest_degree_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(degree_id_p _quest.quest_degree_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(degree_id_p _quest.quest_degree_id) TO PUBLIC;


--
-- Name: FUNCTION to_char(requisite_id_p _quest.quest_requisite_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.to_char(requisite_id_p _quest.quest_requisite_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.to_char(requisite_id_p _quest.quest_requisite_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(requisite_id_p _quest.quest_requisite_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(requisite_id_p _quest.quest_requisite_id) TO PUBLIC;


--
-- Name: FUNCTION to_char(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.to_char(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.to_char(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION to_char(uw_id_p _quest.quest_uw_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.to_char(uw_id_p _quest.quest_uw_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.to_char(uw_id_p _quest.quest_uw_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(uw_id_p _quest.quest_uw_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.to_char(uw_id_p _quest.quest_uw_id) TO PUBLIC;


--
-- Name: FUNCTION update_check_completion(run_id_p integer); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.update_check_completion(run_id_p integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.update_check_completion(run_id_p integer) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.update_check_completion(run_id_p integer) TO _quest_core;
GRANT ALL ON FUNCTION _quest.update_check_completion(run_id_p integer) TO PUBLIC;


--
-- Name: FUNCTION update_check_notification(notification_id_p integer); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.update_check_notification(notification_id_p integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.update_check_notification(notification_id_p integer) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.update_check_notification(notification_id_p integer) TO _quest_core;
GRANT ALL ON FUNCTION _quest.update_check_notification(notification_id_p integer) TO PUBLIC;


--
-- Name: FUNCTION update_create_run(); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.update_create_run() FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.update_create_run() FROM _quest_core;
GRANT ALL ON FUNCTION _quest.update_create_run() TO _quest_core;
GRANT ALL ON FUNCTION _quest.update_create_run() TO PUBLIC;


--
-- Name: FUNCTION update_current_run(); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.update_current_run() FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.update_current_run() FROM _quest_core;
GRANT ALL ON FUNCTION _quest.update_current_run() TO _quest_core;
GRANT ALL ON FUNCTION _quest.update_current_run() TO PUBLIC;


--
-- Name: FUNCTION update_receive_notification(process_id_p integer, process_code_p text); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.update_receive_notification(process_id_p integer, process_code_p text) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.update_receive_notification(process_id_p integer, process_code_p text) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.update_receive_notification(process_id_p integer, process_code_p text) TO _quest_core;
GRANT ALL ON FUNCTION _quest.update_receive_notification(process_id_p integer, process_code_p text) TO PUBLIC;


--
-- Name: FUNCTION update_record_load_completion(run_id_p integer); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.update_record_load_completion(run_id_p integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.update_record_load_completion(run_id_p integer) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.update_record_load_completion(run_id_p integer) TO _quest_core;
GRANT ALL ON FUNCTION _quest.update_record_load_completion(run_id_p integer) TO PUBLIC;


--
-- Name: FUNCTION util_range_summarize(p integer[], format text); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.util_range_summarize(p integer[], format text) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.util_range_summarize(p integer[], format text) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.util_range_summarize(p integer[], format text) TO _quest_core;
GRANT ALL ON FUNCTION _quest.util_range_summarize(p integer[], format text) TO PUBLIC;


--
-- Name: FUNCTION util_range_to_char(range_start integer, range_end integer, format text); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.util_range_to_char(range_start integer, range_end integer, format text) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.util_range_to_char(range_start integer, range_end integer, format text) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.util_range_to_char(range_start integer, range_end integer, format text) TO _quest_core;
GRANT ALL ON FUNCTION _quest.util_range_to_char(range_start integer, range_end integer, format text) TO PUBLIC;


--
-- Name: FUNCTION uw_business_day_diff(date_1 date, date_2 date); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_business_day_diff(date_1 date, date_2 date) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_business_day_diff(date_1 date, date_2 date) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_business_day_diff(date_1 date, date_2 date) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_business_day_diff(date_1 date, date_2 date) TO PUBLIC;


--
-- Name: FUNCTION uw_business_day_offset(date_p date, offset_p integer); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_business_day_offset(date_p date, offset_p integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_business_day_offset(date_p date, offset_p integer) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_business_day_offset(date_p date, offset_p integer) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_business_day_offset(date_p date, offset_p integer) TO PUBLIC;


--
-- Name: FUNCTION uw_date_weekday(date_p date); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_date_weekday(date_p date) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_date_weekday(date_p date) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_date_weekday(date_p date) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_date_weekday(date_p date) TO PUBLIC;


--
-- Name: FUNCTION uw_format_term_academic_year(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_format_term_academic_year(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_format_term_academic_year(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_format_term_academic_year(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_format_term_academic_year(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_format_term_fiscal_year(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_format_term_fiscal_year(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_format_term_fiscal_year(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_format_term_fiscal_year(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_format_term_fiscal_year(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_format_year(year integer); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_format_year(year integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_format_year(year integer) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_format_year(year integer) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_format_year(year integer) TO PUBLIC;


--
-- Name: FUNCTION uw_next_business_day(date_p date); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_next_business_day(date_p date) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_next_business_day(date_p date) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_next_business_day(date_p date) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_next_business_day(date_p date) TO PUBLIC;


--
-- Name: FUNCTION uw_prev_business_day(date_p date); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_prev_business_day(date_p date) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_prev_business_day(date_p date) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_prev_business_day(date_p date) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_prev_business_day(date_p date) TO PUBLIC;


--
-- Name: FUNCTION uw_term_current(); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_current() FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_current() FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_current() TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_current() TO PUBLIC;


--
-- Name: FUNCTION uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_diff(term_id_1 _quest.quest_term_id, term_id_2 _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_term_format(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_format(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_format(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_format(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_format(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_term_format_short(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_format_short(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_format_short(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_format_short(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_format_short(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_term_from_time(when_p date); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_from_time(when_p date) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_from_time(when_p date) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_from_time(when_p date) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_from_time(when_p date) TO PUBLIC;


--
-- Name: FUNCTION uw_term_from_time(when_p timestamp without time zone); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_from_time(when_p timestamp without time zone) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_from_time(when_p timestamp without time zone) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_from_time(when_p timestamp without time zone) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_from_time(when_p timestamp without time zone) TO PUBLIC;


--
-- Name: FUNCTION uw_term_from_time(when_p timestamp with time zone); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_from_time(when_p timestamp with time zone) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_from_time(when_p timestamp with time zone) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_from_time(when_p timestamp with time zone) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_from_time(when_p timestamp with time zone) TO PUBLIC;


--
-- Name: FUNCTION uw_term_next(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_next(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_next(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_next(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_next(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_offset(term_id_p _quest.quest_term_id, offset_p integer) TO PUBLIC;


--
-- Name: FUNCTION uw_term_prev(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_prev(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_prev(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_prev(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_prev(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_term_time(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_time(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_time(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_time(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_time(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_term_year(term_id_p _quest.quest_term_id); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_term_year(term_id_p _quest.quest_term_id) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_term_year(term_id_p _quest.quest_term_id) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_year(term_id_p _quest.quest_term_id) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_term_year(term_id_p _quest.quest_term_id) TO PUBLIC;


--
-- Name: FUNCTION uw_this_next_business_day(date_p date); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_this_next_business_day(date_p date) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_this_next_business_day(date_p date) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_this_next_business_day(date_p date) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_this_next_business_day(date_p date) TO PUBLIC;


--
-- Name: FUNCTION uw_this_prev_business_day(date_p date); Type: ACL; Schema: _quest; Owner: _quest_core
--

REVOKE ALL ON FUNCTION _quest.uw_this_prev_business_day(date_p date) FROM PUBLIC;
REVOKE ALL ON FUNCTION _quest.uw_this_prev_business_day(date_p date) FROM _quest_core;
GRANT ALL ON FUNCTION _quest.uw_this_prev_business_day(date_p date) TO _quest_core;
GRANT ALL ON FUNCTION _quest.uw_this_prev_business_day(date_p date) TO PUBLIC;


--
-- Name: TABLE cal_course_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.cal_course_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.cal_course_history FROM _quest_root;
GRANT ALL ON TABLE _quest.cal_course_history TO _quest_root;
GRANT SELECT ON TABLE _quest.cal_course_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.cal_course_history TO _quest_load;
GRANT SELECT ON TABLE _quest.cal_course_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.cal_course_history TO _quest_references;


--
-- Name: TABLE cal_course_label_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.cal_course_label_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.cal_course_label_history FROM _quest_root;
GRANT ALL ON TABLE _quest.cal_course_label_history TO _quest_root;
GRANT SELECT ON TABLE _quest.cal_course_label_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.cal_course_label_history TO _quest_load;
GRANT SELECT ON TABLE _quest.cal_course_label_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.cal_course_label_history TO _quest_references;


--
-- Name: TABLE cal_course_topic_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.cal_course_topic_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.cal_course_topic_history FROM _quest_root;
GRANT ALL ON TABLE _quest.cal_course_topic_history TO _quest_root;
GRANT SELECT ON TABLE _quest.cal_course_topic_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.cal_course_topic_history TO _quest_load;
GRANT SELECT ON TABLE _quest.cal_course_topic_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.cal_course_topic_history TO _quest_references;


--
-- Name: TABLE off_course_as_of; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_course_as_of FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_course_as_of FROM _quest_root;
GRANT ALL ON TABLE _quest.off_course_as_of TO _quest_root;
GRANT SELECT ON TABLE _quest.off_course_as_of TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_course_as_of TO _quest_load;
GRANT SELECT ON TABLE _quest.off_course_as_of TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_course_as_of TO _quest_references;


--
-- Name: TABLE off_course_section; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_course_section FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_course_section FROM _quest_root;
GRANT ALL ON TABLE _quest.off_course_section TO _quest_root;
GRANT SELECT ON TABLE _quest.off_course_section TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_course_section TO _quest_load;
GRANT SELECT ON TABLE _quest.off_course_section TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_course_section TO _quest_references;


--
-- Name: TABLE off_course_section_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_course_section_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_course_section_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.off_course_section_plus TO _quest_root;
GRANT SELECT ON TABLE _quest.off_course_section_plus TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_course_section_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.off_course_section_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_course_section_plus TO _quest_references;


--
-- Name: TABLE off_course_section_complete; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_course_section_complete FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_course_section_complete FROM _quest_root;
GRANT ALL ON TABLE _quest.off_course_section_complete TO _quest_root;
GRANT SELECT ON TABLE _quest.off_course_section_complete TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_course_section_complete TO _quest_load;
GRANT SELECT ON TABLE _quest.off_course_section_complete TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_course_section_complete TO _quest_references;


--
-- Name: TABLE off_instruct_section_instructor; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_instruct_section_instructor FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_instruct_section_instructor FROM _quest_root;
GRANT ALL ON TABLE _quest.off_instruct_section_instructor TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_instruct_section_instructor TO _quest_load;
GRANT SELECT ON TABLE _quest.off_instruct_section_instructor TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_instruct_section_instructor TO _quest_references;


--
-- Name: TABLE adm_appl_program; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_program FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_program FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_program TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_program TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_program TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_program TO _quest_references;


--
-- Name: TABLE adm_appl_subplan; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_subplan FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_subplan FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_subplan TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_subplan TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_subplan TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_subplan TO _quest_references;


--
-- Name: TABLE pps_plan; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_plan FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_plan FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_plan TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_plan TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_plan TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_plan TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_plan TO _quest_references;


--
-- Name: TABLE adm_appl_plan; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_plan FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_plan FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_plan TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_plan TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_plan TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_plan TO _quest_references;


--
-- Name: TABLE pps_program; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_program FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_program FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_program TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_program TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_program TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_program TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_program TO _quest_references;


--
-- Name: TABLE adm_appl_program_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_program_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_program_history FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_program_history TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_program_history TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_program_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_program_history TO _quest_references;


--
-- Name: TABLE pps_subplan; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_subplan FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_subplan FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_subplan TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_subplan TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_subplan TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_subplan TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_subplan TO _quest_references;


--
-- Name: TABLE std_term_course; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_course FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_course FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_course TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_course TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_course TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_course TO _quest_references;


--
-- Name: TABLE std_term_section; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_section FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_section FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_section TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_section TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_section TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_section TO _quest_references;


--
-- Name: TABLE std_term_course_section; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_course_section FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_course_section FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_course_section TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_course_section TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_course_section TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_course_section TO _quest_references;


--
-- Name: TABLE cal_course; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.cal_course FROM PUBLIC;
REVOKE ALL ON TABLE _quest.cal_course FROM _quest_root;
GRANT ALL ON TABLE _quest.cal_course TO _quest_root;
GRANT SELECT ON TABLE _quest.cal_course TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.cal_course TO _quest_load;
GRANT SELECT ON TABLE _quest.cal_course TO _quest_select;
GRANT REFERENCES ON TABLE _quest.cal_course TO _quest_references;


--
-- Name: TABLE off_instruct_section; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_instruct_section FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_instruct_section FROM _quest_root;
GRANT ALL ON TABLE _quest.off_instruct_section TO _quest_root;
GRANT SELECT ON TABLE _quest.off_instruct_section TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_instruct_section TO _quest_load;
GRANT SELECT ON TABLE _quest.off_instruct_section TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_instruct_section TO _quest_references;


--
-- Name: TABLE uw_term; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_term FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_term FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_term TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_term TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_term TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_term TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_term TO _quest_references;


--
-- Name: TABLE cal_subject; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.cal_subject FROM PUBLIC;
REVOKE ALL ON TABLE _quest.cal_subject FROM _quest_root;
GRANT ALL ON TABLE _quest.cal_subject TO _quest_root;
GRANT SELECT ON TABLE _quest.cal_subject TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.cal_subject TO _quest_load;
GRANT SELECT ON TABLE _quest.cal_subject TO _quest_select;
GRANT REFERENCES ON TABLE _quest.cal_subject TO _quest_references;


--
-- Name: TABLE uw_unit; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_unit FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_unit FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_unit TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_unit TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_unit TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_unit TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_unit TO _quest_references;


--
-- Name: TABLE std_transfer_credit_detail; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_transfer_credit_detail FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_transfer_credit_detail FROM _quest_root;
GRANT ALL ON TABLE _quest.std_transfer_credit_detail TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_transfer_credit_detail TO _quest_load;
GRANT SELECT ON TABLE _quest.std_transfer_credit_detail TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_transfer_credit_detail TO _quest_references;


--
-- Name: TABLE std_transfer_credit_detail_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_transfer_credit_detail_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_transfer_credit_detail_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.std_transfer_credit_detail_plus TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_transfer_credit_detail_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.std_transfer_credit_detail_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_transfer_credit_detail_plus TO _quest_references;


--
-- Name: TABLE std_transfer_credit_school; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_transfer_credit_school FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_transfer_credit_school FROM _quest_root;
GRANT ALL ON TABLE _quest.std_transfer_credit_school TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_transfer_credit_school TO _quest_load;
GRANT SELECT ON TABLE _quest.std_transfer_credit_school TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_transfer_credit_school TO _quest_references;


--
-- Name: TABLE off_instruct_section_meet; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_instruct_section_meet FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_instruct_section_meet FROM _quest_root;
GRANT ALL ON TABLE _quest.off_instruct_section_meet TO _quest_root;
GRANT SELECT ON TABLE _quest.off_instruct_section_meet TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_instruct_section_meet TO _quest_load;
GRANT SELECT ON TABLE _quest.off_instruct_section_meet TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_instruct_section_meet TO _quest_references;


--
-- Name: TABLE uw_room; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_room FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_room FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_room TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_room TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_room TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_room TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_room TO _quest_references;


--
-- Name: TABLE std_student; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_student FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_student FROM _quest_root;
GRANT ALL ON TABLE _quest.std_student TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_student TO _quest_load;
GRANT SELECT ON TABLE _quest.std_student TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_student TO _quest_references;


--
-- Name: TABLE std_term; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term TO _quest_references;


--
-- Name: TABLE std_term_plan; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_plan FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_plan FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_plan TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_plan TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_plan TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_plan TO _quest_references;


--
-- Name: TABLE std_term_program; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_program FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_program FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_program TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_program TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_program TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_program TO _quest_references;


--
-- Name: TABLE adm_appl; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl TO _quest_references;


--
-- Name: TABLE adm_appl_condition; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_condition FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_condition FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_condition TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_condition TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_condition TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_condition TO _quest_references;


--
-- Name: TABLE adm_appl_program_comment; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_program_comment FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_program_comment FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_program_comment TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_program_comment TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_program_comment TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_program_comment TO _quest_references;


--
-- Name: TABLE adm_appl_program_evaluation; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_program_evaluation FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_program_evaluation FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_program_evaluation TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_program_evaluation TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_program_evaluation TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_program_evaluation TO _quest_references;


--
-- Name: TABLE adm_appl_program_evaluation_cmp; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_program_evaluation_cmp FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_program_evaluation_cmp FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_program_evaluation_cmp TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_program_evaluation_cmp TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_program_evaluation_cmp TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_program_evaluation_cmp TO _quest_references;


--
-- Name: TABLE adm_appl_program_financial_aid_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_program_financial_aid_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_program_financial_aid_history FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_program_financial_aid_history TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_program_financial_aid_history TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_program_financial_aid_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_program_financial_aid_history TO _quest_references;


--
-- Name: TABLE adm_appl_referee; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_appl_referee FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_appl_referee FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_appl_referee TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_appl_referee TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_appl_referee TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_appl_referee TO _quest_references;


--
-- Name: TABLE adm_std_academic; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_std_academic FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_std_academic FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_std_academic TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_std_academic TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_std_academic TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_std_academic TO _quest_references;


--
-- Name: TABLE adm_std_academic_attendance; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_std_academic_attendance FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_std_academic_attendance FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_std_academic_attendance TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_std_academic_attendance TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_std_academic_attendance TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_std_academic_attendance TO _quest_references;


--
-- Name: TABLE adm_std_academic_course; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_std_academic_course FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_std_academic_course FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_std_academic_course TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_std_academic_course TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_std_academic_course TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_std_academic_course TO _quest_references;


--
-- Name: TABLE adm_std_academic_degree; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_std_academic_degree FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_std_academic_degree FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_std_academic_degree TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_std_academic_degree TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_std_academic_degree TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_std_academic_degree TO _quest_references;


--
-- Name: TABLE adm_std_academic_gpa; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_std_academic_gpa FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_std_academic_gpa FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_std_academic_gpa TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_std_academic_gpa TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_std_academic_gpa TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_std_academic_gpa TO _quest_references;


--
-- Name: TABLE adm_std_employment; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_std_employment FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_std_employment FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_std_employment TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_std_employment TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_std_employment TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_std_employment TO _quest_references;


--
-- Name: TABLE adm_std_language; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_std_language FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_std_language FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_std_language TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_std_language TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_std_language TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_std_language TO _quest_references;


--
-- Name: TABLE adm_std_test; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.adm_std_test FROM PUBLIC;
REVOKE ALL ON TABLE _quest.adm_std_test FROM _quest_root;
GRANT ALL ON TABLE _quest.adm_std_test TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.adm_std_test TO _quest_load;
GRANT SELECT ON TABLE _quest.adm_std_test TO _quest_select;
GRANT REFERENCES ON TABLE _quest.adm_std_test TO _quest_references;


--
-- Name: TABLE cal_requisite; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.cal_requisite FROM PUBLIC;
REVOKE ALL ON TABLE _quest.cal_requisite FROM _quest_root;
GRANT ALL ON TABLE _quest.cal_requisite TO _quest_root;
GRANT SELECT ON TABLE _quest.cal_requisite TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.cal_requisite TO _quest_load;
GRANT SELECT ON TABLE _quest.cal_requisite TO _quest_select;
GRANT REFERENCES ON TABLE _quest.cal_requisite TO _quest_references;


--
-- Name: TABLE cal_requisite_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.cal_requisite_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.cal_requisite_history FROM _quest_root;
GRANT ALL ON TABLE _quest.cal_requisite_history TO _quest_root;
GRANT SELECT ON TABLE _quest.cal_requisite_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.cal_requisite_history TO _quest_load;
GRANT SELECT ON TABLE _quest.cal_requisite_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.cal_requisite_history TO _quest_references;


--
-- Name: TABLE cal_subject_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.cal_subject_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.cal_subject_history FROM _quest_root;
GRANT ALL ON TABLE _quest.cal_subject_history TO _quest_root;
GRANT SELECT ON TABLE _quest.cal_subject_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.cal_subject_history TO _quest_load;
GRANT SELECT ON TABLE _quest.cal_subject_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.cal_subject_history TO _quest_references;


--
-- Name: TABLE iso_639_3_language; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.iso_639_3_language FROM PUBLIC;
REVOKE ALL ON TABLE _quest.iso_639_3_language FROM _quest_root;
GRANT ALL ON TABLE _quest.iso_639_3_language TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.iso_639_3_language TO _quest_load;
GRANT SELECT ON TABLE _quest.iso_639_3_language TO _quest_select;
GRANT REFERENCES ON TABLE _quest.iso_639_3_language TO _quest_references;


--
-- Name: TABLE off_association; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_association FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_association FROM _quest_root;
GRANT ALL ON TABLE _quest.off_association TO _quest_root;
GRANT SELECT ON TABLE _quest.off_association TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_association TO _quest_load;
GRANT SELECT ON TABLE _quest.off_association TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_association TO _quest_references;


--
-- Name: TABLE off_course; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_course FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_course FROM _quest_root;
GRANT ALL ON TABLE _quest.off_course TO _quest_root;
GRANT SELECT ON TABLE _quest.off_course TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_course TO _quest_load;
GRANT SELECT ON TABLE _quest.off_course TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_course TO _quest_references;


--
-- Name: TABLE off_course_section_note; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_course_section_note FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_course_section_note FROM _quest_root;
GRANT ALL ON TABLE _quest.off_course_section_note TO _quest_root;
GRANT SELECT ON TABLE _quest.off_course_section_note TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_course_section_note TO _quest_load;
GRANT SELECT ON TABLE _quest.off_course_section_note TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_course_section_note TO _quest_references;


--
-- Name: TABLE off_course_section_reserve; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_course_section_reserve FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_course_section_reserve FROM _quest_root;
GRANT ALL ON TABLE _quest.off_course_section_reserve TO _quest_root;
GRANT SELECT ON TABLE _quest.off_course_section_reserve TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_course_section_reserve TO _quest_load;
GRANT SELECT ON TABLE _quest.off_course_section_reserve TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_course_section_reserve TO _quest_references;


--
-- Name: TABLE off_default_note; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_default_note FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_default_note FROM _quest_root;
GRANT ALL ON TABLE _quest.off_default_note TO _quest_root;
GRANT SELECT ON TABLE _quest.off_default_note TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_default_note TO _quest_load;
GRANT SELECT ON TABLE _quest.off_default_note TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_default_note TO _quest_references;


--
-- Name: TABLE off_default_note_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_default_note_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_default_note_history FROM _quest_root;
GRANT ALL ON TABLE _quest.off_default_note_history TO _quest_root;
GRANT SELECT ON TABLE _quest.off_default_note_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_default_note_history TO _quest_load;
GRANT SELECT ON TABLE _quest.off_default_note_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_default_note_history TO _quest_references;


--
-- Name: TABLE off_instruct_section_instructor_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_instruct_section_instructor_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_instruct_section_instructor_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.off_instruct_section_instructor_plus TO _quest_root;
GRANT SELECT ON TABLE _quest.off_instruct_section_instructor_plus TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_instruct_section_instructor_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.off_instruct_section_instructor_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_instruct_section_instructor_plus TO _quest_references;


--
-- Name: TABLE off_instruct_section_meet_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.off_instruct_section_meet_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.off_instruct_section_meet_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.off_instruct_section_meet_plus TO _quest_root;
GRANT SELECT ON TABLE _quest.off_instruct_section_meet_plus TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.off_instruct_section_meet_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.off_instruct_section_meet_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.off_instruct_section_meet_plus TO _quest_references;


--
-- Name: TABLE pps_degree; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_degree FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_degree FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_degree TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_degree TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_degree TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_degree TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_degree TO _quest_references;


--
-- Name: TABLE pps_degree_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_degree_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_degree_history FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_degree_history TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_degree_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_degree_history TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_degree_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_degree_history TO _quest_references;


--
-- Name: TABLE pps_milestone; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_milestone FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_milestone FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_milestone TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_milestone TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_milestone TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_milestone TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_milestone TO _quest_references;


--
-- Name: TABLE pps_plan_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_plan_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_plan_history FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_plan_history TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_plan_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_plan_history TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_plan_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_plan_history TO _quest_references;


--
-- Name: TABLE pps_program_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_program_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_program_history FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_program_history TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_program_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_program_history TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_program_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_program_history TO _quest_references;


--
-- Name: TABLE pps_service_indicator; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_service_indicator FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_service_indicator FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_service_indicator TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_service_indicator TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_service_indicator TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_service_indicator TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_service_indicator TO _quest_references;


--
-- Name: TABLE pps_service_indicator_impact; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_service_indicator_impact FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_service_indicator_impact FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_service_indicator_impact TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_service_indicator_impact TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_service_indicator_impact TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_service_indicator_impact TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_service_indicator_impact TO _quest_references;


--
-- Name: TABLE pps_service_indicator_reason; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_service_indicator_reason FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_service_indicator_reason FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_service_indicator_reason TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_service_indicator_reason TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_service_indicator_reason TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_service_indicator_reason TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_service_indicator_reason TO _quest_references;


--
-- Name: TABLE pps_standing; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_standing FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_standing FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_standing TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_standing TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_standing TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_standing TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_standing TO _quest_references;


--
-- Name: TABLE pps_subplan_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_subplan_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_subplan_history FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_subplan_history TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_subplan_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_subplan_history TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_subplan_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_subplan_history TO _quest_references;


--
-- Name: TABLE pps_term_award; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.pps_term_award FROM PUBLIC;
REVOKE ALL ON TABLE _quest.pps_term_award FROM _quest_root;
GRANT ALL ON TABLE _quest.pps_term_award TO _quest_root;
GRANT SELECT ON TABLE _quest.pps_term_award TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.pps_term_award TO _quest_load;
GRANT SELECT ON TABLE _quest.pps_term_award TO _quest_select;
GRANT REFERENCES ON TABLE _quest.pps_term_award TO _quest_references;


--
-- Name: TABLE std_address; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_address FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_address FROM _quest_root;
GRANT ALL ON TABLE _quest.std_address TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_address TO _quest_load;
GRANT SELECT ON TABLE _quest.std_address TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_address TO _quest_references;


--
-- Name: TABLE std_citizenship; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_citizenship FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_citizenship FROM _quest_root;
GRANT ALL ON TABLE _quest.std_citizenship TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_citizenship TO _quest_load;
GRANT SELECT ON TABLE _quest.std_citizenship TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_citizenship TO _quest_references;


--
-- Name: TABLE std_degree; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_degree FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_degree FROM _quest_root;
GRANT ALL ON TABLE _quest.std_degree TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_degree TO _quest_load;
GRANT SELECT ON TABLE _quest.std_degree TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_degree TO _quest_references;


--
-- Name: TABLE std_degree_honour; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_degree_honour FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_degree_honour FROM _quest_root;
GRANT ALL ON TABLE _quest.std_degree_honour TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_degree_honour TO _quest_load;
GRANT SELECT ON TABLE _quest.std_degree_honour TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_degree_honour TO _quest_references;


--
-- Name: TABLE std_degree_plan; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_degree_plan FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_degree_plan FROM _quest_root;
GRANT ALL ON TABLE _quest.std_degree_plan TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_degree_plan TO _quest_load;
GRANT SELECT ON TABLE _quest.std_degree_plan TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_degree_plan TO _quest_references;


--
-- Name: TABLE std_degree_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_degree_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_degree_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.std_degree_plus TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_degree_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.std_degree_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_degree_plus TO _quest_references;


--
-- Name: TABLE std_degree_subplan; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_degree_subplan FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_degree_subplan FROM _quest_root;
GRANT ALL ON TABLE _quest.std_degree_subplan TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_degree_subplan TO _quest_load;
GRANT SELECT ON TABLE _quest.std_degree_subplan TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_degree_subplan TO _quest_references;


--
-- Name: TABLE std_grad_supervision_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_grad_supervision_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_grad_supervision_history FROM _quest_root;
GRANT ALL ON TABLE _quest.std_grad_supervision_history TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_grad_supervision_history TO _quest_load;
GRANT SELECT ON TABLE _quest.std_grad_supervision_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_grad_supervision_history TO _quest_references;


--
-- Name: TABLE std_grad_supervision; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_grad_supervision FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_grad_supervision FROM _quest_root;
GRANT ALL ON TABLE _quest.std_grad_supervision TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_grad_supervision TO _quest_load;
GRANT SELECT ON TABLE _quest.std_grad_supervision TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_grad_supervision TO _quest_references;


--
-- Name: TABLE std_grad_supervisor; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_grad_supervisor FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_grad_supervisor FROM _quest_root;
GRANT ALL ON TABLE _quest.std_grad_supervisor TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_grad_supervisor TO _quest_load;
GRANT SELECT ON TABLE _quest.std_grad_supervisor TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_grad_supervisor TO _quest_references;


--
-- Name: TABLE std_milestone; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_milestone FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_milestone FROM _quest_root;
GRANT ALL ON TABLE _quest.std_milestone TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_milestone TO _quest_load;
GRANT SELECT ON TABLE _quest.std_milestone TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_milestone TO _quest_references;


--
-- Name: TABLE std_name; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_name FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_name FROM _quest_root;
GRANT ALL ON TABLE _quest.std_name TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_name TO _quest_load;
GRANT SELECT ON TABLE _quest.std_name TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_name TO _quest_references;


--
-- Name: TABLE std_name_preferred; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_name_preferred FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_name_preferred FROM _quest_root;
GRANT ALL ON TABLE _quest.std_name_preferred TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_name_preferred TO _quest_load;
GRANT SELECT ON TABLE _quest.std_name_preferred TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_name_preferred TO _quest_references;


--
-- Name: TABLE std_name_primary; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_name_primary FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_name_primary FROM _quest_root;
GRANT ALL ON TABLE _quest.std_name_primary TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_name_primary TO _quest_load;
GRANT SELECT ON TABLE _quest.std_name_primary TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_name_primary TO _quest_references;


--
-- Name: TABLE std_photo; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_photo FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_photo FROM _quest_root;
GRANT ALL ON TABLE _quest.std_photo TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_photo TO _quest_load;
GRANT SELECT ON TABLE _quest.std_photo TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_photo TO _quest_references;


--
-- Name: TABLE std_plan_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_plan_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_plan_history FROM _quest_root;
GRANT ALL ON TABLE _quest.std_plan_history TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_plan_history TO _quest_load;
GRANT SELECT ON TABLE _quest.std_plan_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_plan_history TO _quest_references;


--
-- Name: TABLE std_program_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_program_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_program_history FROM _quest_root;
GRANT ALL ON TABLE _quest.std_program_history TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_program_history TO _quest_load;
GRANT SELECT ON TABLE _quest.std_program_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_program_history TO _quest_references;


--
-- Name: TABLE std_service_indicator; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_service_indicator FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_service_indicator FROM _quest_root;
GRANT ALL ON TABLE _quest.std_service_indicator TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_service_indicator TO _quest_load;
GRANT SELECT ON TABLE _quest.std_service_indicator TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_service_indicator TO _quest_references;


--
-- Name: TABLE std_subplan_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_subplan_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_subplan_history FROM _quest_root;
GRANT ALL ON TABLE _quest.std_subplan_history TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_subplan_history TO _quest_load;
GRANT SELECT ON TABLE _quest.std_subplan_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_subplan_history TO _quest_references;


--
-- Name: TABLE std_term_award; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_award FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_award FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_award TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_award TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_award TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_award TO _quest_references;


--
-- Name: TABLE std_term_course_demand; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_course_demand FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_course_demand FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_course_demand TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_course_demand TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_course_demand TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_course_demand TO _quest_references;


--
-- Name: TABLE std_term_course_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_course_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_course_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_course_plus TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_course_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_course_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_course_plus TO _quest_references;


--
-- Name: TABLE std_term_grad_supervision; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_grad_supervision FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_grad_supervision FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_grad_supervision TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_grad_supervision TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_grad_supervision TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_grad_supervision TO _quest_references;


--
-- Name: TABLE std_term_plan_gpa; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_plan_gpa FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_plan_gpa FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_plan_gpa TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_plan_gpa TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_plan_gpa TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_plan_gpa TO _quest_references;


--
-- Name: TABLE std_term_plan_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_plan_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_plan_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_plan_plus TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_plan_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_plan_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_plan_plus TO _quest_references;


--
-- Name: TABLE std_term_program_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_program_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_program_history FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_program_history TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_program_history TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_program_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_program_history TO _quest_references;


--
-- Name: TABLE std_term_program_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_program_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_program_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_program_plus TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_program_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_program_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_program_plus TO _quest_references;


--
-- Name: TABLE std_term_subplan; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_subplan FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_subplan FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_subplan TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_subplan TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_subplan TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_subplan TO _quest_references;


--
-- Name: TABLE std_term_subplan_gpa; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_subplan_gpa FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_subplan_gpa FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_subplan_gpa TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_subplan_gpa TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_subplan_gpa TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_subplan_gpa TO _quest_references;


--
-- Name: TABLE std_term_units; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_term_units FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_term_units FROM _quest_root;
GRANT ALL ON TABLE _quest.std_term_units TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_term_units TO _quest_load;
GRANT SELECT ON TABLE _quest.std_term_units TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_term_units TO _quest_references;


--
-- Name: TABLE std_transfer_credit_school_plus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.std_transfer_credit_school_plus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.std_transfer_credit_school_plus FROM _quest_root;
GRANT ALL ON TABLE _quest.std_transfer_credit_school_plus TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.std_transfer_credit_school_plus TO _quest_load;
GRANT SELECT ON TABLE _quest.std_transfer_credit_school_plus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.std_transfer_credit_school_plus TO _quest_references;


--
-- Name: TABLE update_notification; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.update_notification FROM PUBLIC;
REVOKE ALL ON TABLE _quest.update_notification FROM _quest_root;
GRANT ALL ON TABLE _quest.update_notification TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.update_notification TO _quest_load;
GRANT SELECT ON TABLE _quest.update_notification TO _quest_select;
GRANT REFERENCES ON TABLE _quest.update_notification TO _quest_references;


--
-- Name: SEQUENCE update_notification_notification_id_seq; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON SEQUENCE _quest.update_notification_notification_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE _quest.update_notification_notification_id_seq FROM _quest_root;
GRANT ALL ON SEQUENCE _quest.update_notification_notification_id_seq TO _quest_root;
GRANT USAGE ON SEQUENCE _quest.update_notification_notification_id_seq TO _quest_load;
GRANT SELECT ON SEQUENCE _quest.update_notification_notification_id_seq TO _quest_select;


--
-- Name: TABLE update_process; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.update_process FROM PUBLIC;
REVOKE ALL ON TABLE _quest.update_process FROM _quest_root;
GRANT ALL ON TABLE _quest.update_process TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.update_process TO _quest_load;
GRANT SELECT ON TABLE _quest.update_process TO _quest_select;
GRANT REFERENCES ON TABLE _quest.update_process TO _quest_references;


--
-- Name: TABLE update_run; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.update_run FROM PUBLIC;
REVOKE ALL ON TABLE _quest.update_run FROM _quest_root;
GRANT ALL ON TABLE _quest.update_run TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.update_run TO _quest_load;
GRANT SELECT ON TABLE _quest.update_run TO _quest_select;
GRANT REFERENCES ON TABLE _quest.update_run TO _quest_references;


--
-- Name: TABLE update_run_notification; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.update_run_notification FROM PUBLIC;
REVOKE ALL ON TABLE _quest.update_run_notification FROM _quest_root;
GRANT ALL ON TABLE _quest.update_run_notification TO _quest_root;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.update_run_notification TO _quest_load;
GRANT SELECT ON TABLE _quest.update_run_notification TO _quest_select;
GRANT REFERENCES ON TABLE _quest.update_run_notification TO _quest_references;


--
-- Name: SEQUENCE update_run_run_id_seq; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON SEQUENCE _quest.update_run_run_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE _quest.update_run_run_id_seq FROM _quest_root;
GRANT ALL ON SEQUENCE _quest.update_run_run_id_seq TO _quest_root;
GRANT USAGE ON SEQUENCE _quest.update_run_run_id_seq TO _quest_load;
GRANT SELECT ON SEQUENCE _quest.update_run_run_id_seq TO _quest_select;


--
-- Name: TABLE uw_adm_comment; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_adm_comment FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_adm_comment FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_adm_comment TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_adm_comment TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_adm_comment TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_adm_comment TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_adm_comment TO _quest_references;


--
-- Name: TABLE uw_aid_category; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_aid_category FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_aid_category FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_aid_category TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_aid_category TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_aid_category TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_aid_category TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_aid_category TO _quest_references;


--
-- Name: TABLE uw_aid_status; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_aid_status FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_aid_status FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_aid_status TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_aid_status TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_aid_status TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_aid_status TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_aid_status TO _quest_references;


--
-- Name: TABLE uw_appl_method; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_appl_method FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_appl_method FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_appl_method TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_appl_method TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_appl_method TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_appl_method TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_appl_method TO _quest_references;


--
-- Name: TABLE uw_building; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_building FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_building FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_building TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_building TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_building TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_building TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_building TO _quest_references;


--
-- Name: TABLE uw_building_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_building_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_building_history FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_building_history TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_building_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_building_history TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_building_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_building_history TO _quest_references;


--
-- Name: TABLE uw_campus; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_campus FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_campus FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_campus TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_campus TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_campus TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_campus TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_campus TO _quest_references;


--
-- Name: TABLE uw_campus_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_campus_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_campus_history FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_campus_history TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_campus_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_campus_history TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_campus_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_campus_history TO _quest_references;


--
-- Name: TABLE uw_citizenship; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_citizenship FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_citizenship FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_citizenship TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_citizenship TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_citizenship TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_citizenship TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_citizenship TO _quest_references;


--
-- Name: TABLE uw_condition; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_condition FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_condition FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_condition TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_condition TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_condition TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_condition TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_condition TO _quest_references;


--
-- Name: TABLE uw_condition_status; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_condition_status FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_condition_status FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_condition_status TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_condition_status TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_condition_status TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_condition_status TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_condition_status TO _quest_references;


--
-- Name: TABLE uw_coop_term_type; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_coop_term_type FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_coop_term_type FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_coop_term_type TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_coop_term_type TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_coop_term_type TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_coop_term_type TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_coop_term_type TO _quest_references;


--
-- Name: TABLE uw_coop_workterm_status; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_coop_workterm_status FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_coop_workterm_status FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_coop_workterm_status TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_coop_workterm_status TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_coop_workterm_status TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_coop_workterm_status TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_coop_workterm_status TO _quest_references;


--
-- Name: TABLE uw_country; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_country FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_country FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_country TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_country TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_country TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_country TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_country TO _quest_references;


--
-- Name: TABLE uw_country_citizenship; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_country_citizenship FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_country_citizenship FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_country_citizenship TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_country_citizenship TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_country_citizenship TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_country_citizenship TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_country_citizenship TO _quest_references;


--
-- Name: TABLE uw_course_level; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_course_level FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_course_level FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_course_level TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_course_level TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_course_level TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_course_level TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_course_level TO _quest_references;


--
-- Name: TABLE uw_date; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_date FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_date FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_date TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_date TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_date TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_date TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_date TO _quest_references;


--
-- Name: TABLE uw_ext_academic_level; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_academic_level FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_academic_level FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_academic_level TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_academic_level TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_academic_level TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_academic_level TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_academic_level TO _quest_references;


--
-- Name: TABLE uw_ext_career; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_career FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_career FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_career TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_career TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_career TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_career TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_career TO _quest_references;


--
-- Name: TABLE uw_ext_course_type; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_course_type FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_course_type FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_course_type TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_course_type TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_course_type TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_course_type TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_course_type TO _quest_references;


--
-- Name: TABLE uw_ext_degree_status; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_degree_status FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_degree_status FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_degree_status TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_degree_status TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_degree_status TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_degree_status TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_degree_status TO _quest_references;


--
-- Name: TABLE uw_ext_gpa_type; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_gpa_type FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_gpa_type FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_gpa_type TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_gpa_type TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_gpa_type TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_gpa_type TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_gpa_type TO _quest_references;


--
-- Name: TABLE uw_ext_org; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_org FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_org FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_org TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_org TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_org TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_org TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_org TO _quest_references;


--
-- Name: TABLE uw_ext_subject; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_subject FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_subject FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_subject TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_subject TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_subject TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_subject TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_subject TO _quest_references;


--
-- Name: TABLE uw_ext_term; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_term FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_term FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_term TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_term TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_term TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_term TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_term TO _quest_references;


--
-- Name: TABLE uw_ext_term_type; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_ext_term_type FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_ext_term_type FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_ext_term_type TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_ext_term_type TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_ext_term_type TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_ext_term_type TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_ext_term_type TO _quest_references;


--
-- Name: TABLE uw_form_of_study; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_form_of_study FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_form_of_study FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_form_of_study TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_form_of_study TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_form_of_study TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_form_of_study TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_form_of_study TO _quest_references;


--
-- Name: TABLE uw_gender; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_gender FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_gender FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_gender TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_gender TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_gender TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_gender TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_gender TO _quest_references;


--
-- Name: TABLE uw_grading_basis; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_grading_basis FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_grading_basis FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_grading_basis TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_grading_basis TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_grading_basis TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_grading_basis TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_grading_basis TO _quest_references;


--
-- Name: TABLE uw_group; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_group FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_group FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_group TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_group TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_group TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_group TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_group TO _quest_references;


--
-- Name: TABLE uw_group_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_group_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_group_history FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_group_history TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_group_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_group_history TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_group_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_group_history TO _quest_references;


--
-- Name: TABLE uw_holiday_type; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_holiday_type FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_holiday_type FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_holiday_type TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_holiday_type TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_holiday_type TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_holiday_type TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_holiday_type TO _quest_references;


--
-- Name: TABLE uw_location; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_location FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_location FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_location TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_location TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_location TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_location TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_location TO _quest_references;


--
-- Name: TABLE uw_location_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_location_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_location_history FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_location_history TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_location_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_location_history TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_location_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_location_history TO _quest_references;


--
-- Name: TABLE uw_program_action; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_program_action FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_program_action FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_program_action TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_program_action TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_program_action TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_program_action TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_program_action TO _quest_references;


--
-- Name: TABLE uw_program_status; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_program_status FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_program_status FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_program_status TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_program_status TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_program_status TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_program_status TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_program_status TO _quest_references;


--
-- Name: TABLE uw_unit_history; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_unit_history FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_unit_history FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_unit_history TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_unit_history TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_unit_history TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_unit_history TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_unit_history TO _quest_references;


--
-- Name: TABLE uw_visible_minority; Type: ACL; Schema: _quest; Owner: _quest_root
--

REVOKE ALL ON TABLE _quest.uw_visible_minority FROM PUBLIC;
REVOKE ALL ON TABLE _quest.uw_visible_minority FROM _quest_root;
GRANT ALL ON TABLE _quest.uw_visible_minority TO _quest_root;
GRANT SELECT ON TABLE _quest.uw_visible_minority TO PUBLIC;
GRANT INSERT,DELETE,UPDATE ON TABLE _quest.uw_visible_minority TO _quest_load;
GRANT SELECT ON TABLE _quest.uw_visible_minority TO _quest_select;
GRANT REFERENCES ON TABLE _quest.uw_visible_minority TO _quest_references;


--
--

