--
--


--
-- Name: compute; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA compute;


ALTER SCHEMA compute OWNER TO postgres;

--
-- Name: define; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA define;


ALTER SCHEMA define OWNER TO postgres;

--
-- Name: format; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA format;


ALTER SCHEMA format OWNER TO postgres;

--
-- Name: groupdata; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA groupdata;


ALTER SCHEMA groupdata OWNER TO postgres;

--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON SCHEMA public IS 'Standard public schema';


--
-- Name: selection; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA selection;


ALTER SCHEMA selection OWNER TO postgres;




--
-- Name: absenteeism; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE absenteeism (
    empid integer NOT NULL,
    deptid integer NOT NULL,
    missdate date NOT NULL,
    reason character varying(40) NOT NULL,
    severity integer NOT NULL,
    CONSTRAINT valid_severity CHECK (((severity >= 0) AND (severity <= 4)))
);


ALTER TABLE define.absenteeism OWNER TO postgres;

--
-- Name: badges; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE badges (
    badgeno serial NOT NULL,
    empno integer NOT NULL,
    issuedate date NOT NULL,
    status character(1) NOT NULL,
    CONSTRAINT badges_status_check CHECK (((status = 'A'::bpchar) OR (status = 'I'::bpchar)))
);


ALTER TABLE define.badges OWNER TO postgres;

--
-- Name: badges_badgeno_seq; Type: SEQUENCE SET; Schema: define; Owner: postgres
--

SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('badges', 'badgeno'), 3, true);


--
-- Name: department_seq_id; Type: SEQUENCE; Schema: define; Owner: postgres
--

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


ALTER TABLE define.department_seq_id OWNER TO postgres;

--
-- Name: department_seq_id; Type: SEQUENCE SET; Schema: define; Owner: postgres
--

SELECT pg_catalog.setval('department_seq_id', 10, false);


--
-- Name: employees_seq_id; Type: SEQUENCE; Schema: define; Owner: postgres
--

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


ALTER TABLE define.employees_seq_id OWNER TO postgres;

--
-- Name: employees_seq_id; Type: SEQUENCE SET; Schema: define; Owner: postgres
--

SELECT pg_catalog.setval('employees_seq_id', 10, false);


--
-- Name: departments; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE departments (
    deptid integer DEFAULT nextval('employees_seq_id'::regclass) NOT NULL,
    deptname text NOT NULL
);


ALTER TABLE define.departments OWNER TO postgres;

--
-- Name: doctors; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE doctors (
    anest character varying NOT NULL
);


ALTER TABLE define.doctors OWNER TO postgres;

--
-- Name: employees; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE employees (
    empid integer DEFAULT nextval('employees_seq_id'::regclass) NOT NULL,
    empname text NOT NULL
);


ALTER TABLE define.employees OWNER TO postgres;

--
-- Name: procs; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE procs (
    proc_id serial NOT NULL,
    anest character varying NOT NULL,
    start_time timestamp without time zone,
    end_time timestamp without time zone
);


ALTER TABLE define.procs OWNER TO postgres;

--
-- Name: events; Type: VIEW; Schema: define; Owner: postgres
--

CREATE VIEW events AS
    SELECT p1.proc_id AS subject_proc, p2.proc_id AS comparison_proc, p1.anest, p2.start_time AS event_time, (+ 1) AS event_type FROM procs p1, procs p2 WHERE (((p1.anest)::text = (p2.anest)::text) AND (NOT ((p2.end_time <= p1.start_time) OR (p2.start_time >= p1.end_time)))) UNION SELECT p1.proc_id AS subject_proc, p2.proc_id AS comparison_proc, p1.anest, p2.end_time AS event_time, -1 AS event_type FROM procs p1, procs p2 WHERE (((p1.anest)::text = (p2.anest)::text) AND (NOT ((p2.end_time <= p1.start_time) OR (p2.start_time >= p1.end_time))));


ALTER TABLE define.events OWNER TO postgres;

--
-- Name: excuselist; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE excuselist (
    reason character varying(40) NOT NULL
);


ALTER TABLE define.excuselist OWNER TO postgres;

--
-- Name: fiscalyeartable1; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE fiscalyeartable1 (
    fiscalyear smallint NOT NULL,
    startdate date NOT NULL,
    enddate date NOT NULL,
    CONSTRAINT fiscalyeartable1_check CHECK ((startdate <= enddate))
);


ALTER TABLE define.fiscalyeartable1 OWNER TO postgres;

--
-- Name: fiscalyeartable2; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE fiscalyeartable2 (
    fiscalyear smallint NOT NULL,
    startdate date NOT NULL,
    enddate date NOT NULL,
    CONSTRAINT valid_enddate CHECK ((((date_part('year'::text, enddate) = (fiscalyear)::double precision) AND (date_part('month'::text, enddate) = (9)::double precision)) AND (date_part('day'::text, enddate) = (30)::double precision))),
    CONSTRAINT valid_startdate CHECK ((((date_part('year'::text, startdate) = ((fiscalyear - 1))::double precision) AND (date_part('month'::text, startdate) = (10)::double precision)) AND (date_part('day'::text, startdate) = (1)::double precision)))
);


ALTER TABLE define.fiscalyeartable2 OWNER TO postgres;

--
-- Name: foobar; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE foobar (
    alpha_only character varying(6),
    CONSTRAINT foobar_apha_only_check_re CHECK (((alpha_only)::text ~ similar_escape('[A-Za-z]+'::text, NULL::text)))
);


ALTER TABLE define.foobar OWNER TO postgres;

--
-- Name: printercontrol; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE printercontrol (
    userid_start character varying(8) NOT NULL,
    userid_finish character varying(8) NOT NULL,
    printer_name character varying(4) NOT NULL,
    description character varying(40) NOT NULL
);


ALTER TABLE define.printercontrol OWNER TO postgres;

--
-- Name: procs_proc_id_seq; Type: SEQUENCE SET; Schema: define; Owner: postgres
--

SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('procs', 'proc_id'), 9, true);


--
-- Name: projects; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE projects (
    workorder character varying(5) NOT NULL,
    leg integer NOT NULL,
    status character(1) NOT NULL,
    CONSTRAINT projects_leg_check CHECK (((leg >= 0) AND (leg <= 1000))),
    CONSTRAINT projects_status_check CHECK (((status = 'C'::bpchar) OR (status = 'R'::bpchar)))
);


ALTER TABLE define.projects OWNER TO postgres;

--
-- Name: secemployees; Type: TABLE; Schema: define; Owner: postgres; Tablespace: 
--

CREATE TABLE secemployees (
    empno serial NOT NULL,
    empname character varying NOT NULL
);


ALTER TABLE define.secemployees OWNER TO postgres;

--
-- Name: secemployees_empno_seq; Type: SEQUENCE SET; Schema: define; Owner: postgres
--

SELECT pg_catalog.setval(pg_catalog.pg_get_serial_sequence('secemployees', 'empno'), 1, true);



--
-- Name: candidateskills; Type: TABLE; Schema: format; Owner: postgres; Tablespace: 
--

CREATE TABLE candidateskills (
    candidateid integer NOT NULL,
    skill_code character varying(15) NOT NULL
);


ALTER TABLE format.candidateskills OWNER TO postgres;

--
-- Name: claimdefendant; Type: TABLE; Schema: format; Owner: postgres; Tablespace: 
--

CREATE TABLE claimdefendant (
    claimid integer NOT NULL,
    defendant character varying(20) NOT NULL
);


ALTER TABLE format.claimdefendant OWNER TO postgres;

--
-- Name: claims; Type: TABLE; Schema: format; Owner: postgres; Tablespace: 
--

CREATE TABLE claims (
    claimid integer NOT NULL,
    patient character varying(20) NOT NULL
);


ALTER TABLE format.claims OWNER TO postgres;

--
-- Name: events; Type: TABLE; Schema: format; Owner: postgres; Tablespace: 
--

CREATE TABLE events (
    claimid integer NOT NULL,
    defendant character varying(20) NOT NULL,
    status character(2) NOT NULL,
    changedate date NOT NULL
);


ALTER TABLE format.events OWNER TO postgres;

--
-- Name: salaries; Type: TABLE; Schema: format; Owner: postgres; Tablespace: 
--

CREATE TABLE salaries (
    emp character varying(10) NOT NULL,
    sal_date date NOT NULL,
    sal_amt numeric(8,2) NOT NULL
);


ALTER TABLE format.salaries OWNER TO postgres;

--
-- Name: statuscodes; Type: TABLE; Schema: format; Owner: postgres; Tablespace: 
--

CREATE TABLE statuscodes (
    status character(2) NOT NULL,
    statusdesc character varying(40) NOT NULL,
    seq integer NOT NULL,
    CONSTRAINT statuscodes_status_check CHECK (((((status = 'AP'::bpchar) OR (status = 'OR'::bpchar)) OR (status = 'SF'::bpchar)) OR (status = 'CL'::bpchar)))
);


ALTER TABLE format.statuscodes OWNER TO postgres;


--
-- Data for Name: absenteeism; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO absenteeism VALUES (1, 1, '2006-06-30', 'DA', 1);


--
-- Data for Name: badges; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO badges VALUES (1, 1, '2006-06-30', 'A');
INSERT INTO badges VALUES (2, 1, '2006-06-30', 'I');


--
-- Data for Name: departments; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO departments VALUES (1, 'Piping');
INSERT INTO departments VALUES (2, 'Electrical');
INSERT INTO departments VALUES (3, 'Instrumentation');
INSERT INTO departments VALUES (4, 'Process');
INSERT INTO departments VALUES (5, 'Mechanical');


--
-- Data for Name: doctors; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO doctors VALUES ('Baker');
INSERT INTO doctors VALUES ('Dow');
INSERT INTO doctors VALUES ('DOW');


--
-- Data for Name: employees; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO employees VALUES (1, 'Richard Broersma');
INSERT INTO employees VALUES (2, 'Katheryn Whitehead');
INSERT INTO employees VALUES (3, 'Dave Knauer');


--
-- Data for Name: excuselist; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO excuselist VALUES ('DA');
INSERT INTO excuselist VALUES ('UE');
INSERT INTO excuselist VALUES ('DE');


--
-- Data for Name: fiscalyeartable1; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO fiscalyeartable1 VALUES (1995, '1994-10-01', '1995-09-30');
INSERT INTO fiscalyeartable1 VALUES (1996, '1995-10-01', '1996-08-30');
INSERT INTO fiscalyeartable1 VALUES (1997, '1996-10-01', '1997-09-30');
INSERT INTO fiscalyeartable1 VALUES (1998, '1997-10-01', '1998-09-30');


--
-- Data for Name: fiscalyeartable2; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO fiscalyeartable2 VALUES (1995, '1994-10-01', '1995-09-30');
INSERT INTO fiscalyeartable2 VALUES (1997, '1996-10-01', '1997-09-30');
INSERT INTO fiscalyeartable2 VALUES (1998, '1997-10-01', '1998-09-30');
INSERT INTO fiscalyeartable2 VALUES (1996, '1995-10-01', '1996-09-30');
INSERT INTO fiscalyeartable2 VALUES (1999, '1998-10-01', '1999-09-30');
INSERT INTO fiscalyeartable2 VALUES (1994, '1993-10-01', '1994-09-30');


--
-- Data for Name: foobar; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO foobar VALUES ('a');
INSERT INTO foobar VALUES ('a');
INSERT INTO foobar VALUES ('aaaaaa');
INSERT INTO foobar VALUES ('aa');
INSERT INTO foobar VALUES ('a');


--
-- Data for Name: printercontrol; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO printercontrol VALUES ('chacha', 'chacha', 'lpt1', 'first floor''s printer');
INSERT INTO printercontrol VALUES ('lee', 'lee', 'lpt2', 'second floor''s printer');
INSERT INTO printercontrol VALUES ('thomas', 'thomas', 'lpt3', 'third floor''s printer');
INSERT INTO printercontrol VALUES ('aaaaaaaa', 'mzzzzzzz', 'lpt4', 'common printer #1');
INSERT INTO printercontrol VALUES ('nzzzzzzz', 'zzzzzzzz', 'lpt5', 'common printer #2');


--
-- Data for Name: procs; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO procs VALUES (1, 'Baker', '2006-06-30 08:00:00', '2006-06-30 11:00:00');
INSERT INTO procs VALUES (2, 'Baker', '2006-06-30 09:00:00', '2006-06-30 13:00:00');
INSERT INTO procs VALUES (4, 'DOW', '2006-06-30 09:00:00', '2006-06-30 15:30:00');
INSERT INTO procs VALUES (5, 'DOW', '2006-06-30 08:00:00', '2006-06-30 13:30:00');
INSERT INTO procs VALUES (6, 'DOW', '2006-06-30 10:00:00', '2006-06-30 11:30:00');
INSERT INTO procs VALUES (7, 'DOW', '2006-06-30 12:30:00', '2006-06-30 13:30:00');
INSERT INTO procs VALUES (8, 'DOW', '2006-06-30 13:30:00', '2006-06-30 14:30:00');
INSERT INTO procs VALUES (9, 'DOW', '2006-06-30 18:00:00', '2006-06-30 19:00:00');


--
-- Data for Name: projects; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO projects VALUES ('AA100', 0, 'C');
INSERT INTO projects VALUES ('AA100', 1, 'R');
INSERT INTO projects VALUES ('AA100', 2, 'R');
INSERT INTO projects VALUES ('AA200', 0, 'R');
INSERT INTO projects VALUES ('AA200', 1, 'R');
INSERT INTO projects VALUES ('AA300', 0, 'C');
INSERT INTO projects VALUES ('AA300', 1, 'C');


--
-- Data for Name: secemployees; Type: TABLE DATA; Schema: define; Owner: postgres
--

INSERT INTO secemployees VALUES (1, 'Richard');



--
-- Data for Name: candidateskills; Type: TABLE DATA; Schema: format; Owner: postgres
--

INSERT INTO candidateskills VALUES (100, 'accounting');
INSERT INTO candidateskills VALUES (100, 'inventory');
INSERT INTO candidateskills VALUES (100, 'manufacturing');
INSERT INTO candidateskills VALUES (200, 'accounting');
INSERT INTO candidateskills VALUES (200, 'inventory');
INSERT INTO candidateskills VALUES (300, 'manufacturing');
INSERT INTO candidateskills VALUES (400, 'inventory');
INSERT INTO candidateskills VALUES (400, 'manufacturing');
INSERT INTO candidateskills VALUES (500, 'accounting');
INSERT INTO candidateskills VALUES (500, 'manufacturing');


--
-- Data for Name: claimdefendant; Type: TABLE DATA; Schema: format; Owner: postgres
--

INSERT INTO claimdefendant VALUES (10, 'Johnson');
INSERT INTO claimdefendant VALUES (10, 'Meyer');
INSERT INTO claimdefendant VALUES (10, 'Dow');
INSERT INTO claimdefendant VALUES (20, 'Baker');
INSERT INTO claimdefendant VALUES (20, 'Meyer');
INSERT INTO claimdefendant VALUES (30, 'Johnson');


--
-- Data for Name: claims; Type: TABLE DATA; Schema: format; Owner: postgres
--

INSERT INTO claims VALUES (10, 'Smith');
INSERT INTO claims VALUES (20, 'Jones');
INSERT INTO claims VALUES (30, 'Brown');


--
-- Data for Name: events; Type: TABLE DATA; Schema: format; Owner: postgres
--

INSERT INTO events VALUES (10, 'Johnson', 'AP', '1994-01-01');
INSERT INTO events VALUES (10, 'Johnson', 'OR', '1994-02-01');
INSERT INTO events VALUES (10, 'Johnson', 'SF', '1994-03-01');
INSERT INTO events VALUES (10, 'Meyer', 'AP', '1994-01-01');
INSERT INTO events VALUES (10, 'Meyer', 'OR', '1994-02-01');
INSERT INTO events VALUES (10, 'Dow', 'AP', '1994-01-01');
INSERT INTO events VALUES (10, 'Dow', 'OR', '1994-02-01');
INSERT INTO events VALUES (20, 'Meyer', 'AP', '1994-01-01');
INSERT INTO events VALUES (20, 'Baker', 'AP', '1994-01-01');
INSERT INTO events VALUES (30, 'Johnson', 'AP', '1994-01-01');
INSERT INTO events VALUES (10, 'Johnson', 'CL', '1994-04-01');
INSERT INTO events VALUES (20, 'Meyer', 'OR', '1994-02-01');
INSERT INTO events VALUES (10, 'Meyer', 'SF', '1994-03-01');


--
-- Data for Name: salaries; Type: TABLE DATA; Schema: format; Owner: postgres
--

INSERT INTO salaries VALUES ('Tom', '1996-06-20', 500.00);
INSERT INTO salaries VALUES ('Tom', '1996-08-20', 700.00);
INSERT INTO salaries VALUES ('Tom', '1996-10-20', 800.00);
INSERT INTO salaries VALUES ('Tom', '1996-12-20', 900.00);
INSERT INTO salaries VALUES ('Dick', '1996-06-20', 500.00);
INSERT INTO salaries VALUES ('Harry', '1996-07-20', 500.00);
INSERT INTO salaries VALUES ('Harry', '1996-09-20', 700.00);


--
-- Data for Name: statuscodes; Type: TABLE DATA; Schema: format; Owner: postgres
--

INSERT INTO statuscodes VALUES ('AP', 'Awaiting Panel Review', 1);
INSERT INTO statuscodes VALUES ('OR', 'Panel Opinion Rendered', 2);
INSERT INTO statuscodes VALUES ('SF', 'Suite Filed', 3);
INSERT INTO statuscodes VALUES ('CL', 'Closed', 4);



--
-- Name: absenteeism_pk; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY absenteeism
    ADD CONSTRAINT absenteeism_pk PRIMARY KEY (empid, deptid, missdate);


--
-- Name: badges_pkey; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY badges
    ADD CONSTRAINT badges_pkey PRIMARY KEY (badgeno);


--
-- Name: departments_pk; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY departments
    ADD CONSTRAINT departments_pk PRIMARY KEY (deptid);


--
-- Name: departments_uc2; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY departments
    ADD CONSTRAINT departments_uc2 UNIQUE (deptname);


--
-- Name: doctors_pkey; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY doctors
    ADD CONSTRAINT doctors_pkey PRIMARY KEY (anest);


--
-- Name: employees_pk; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY employees
    ADD CONSTRAINT employees_pk PRIMARY KEY (empid);


--
-- Name: employees_uc2; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY employees
    ADD CONSTRAINT employees_uc2 UNIQUE (empname);


--
-- Name: excuselist_pk; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY excuselist
    ADD CONSTRAINT excuselist_pk PRIMARY KEY (reason);


--
-- Name: fiscalyeartable2_pkey; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY fiscalyeartable2
    ADD CONSTRAINT fiscalyeartable2_pkey PRIMARY KEY (fiscalyear);


--
-- Name: printercontrol_pkey; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY printercontrol
    ADD CONSTRAINT printercontrol_pkey PRIMARY KEY (userid_start, userid_finish);


--
-- Name: procs_pkey; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY procs
    ADD CONSTRAINT procs_pkey PRIMARY KEY (proc_id);


--
-- Name: secemployees_empname_key; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY secemployees
    ADD CONSTRAINT secemployees_empname_key UNIQUE (empname);


--
-- Name: secemployees_pkey; Type: CONSTRAINT; Schema: define; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY secemployees
    ADD CONSTRAINT secemployees_pkey PRIMARY KEY (empno);



--
-- Name: candidateskills_pk; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY candidateskills
    ADD CONSTRAINT candidateskills_pk PRIMARY KEY (candidateid, skill_code);


--
-- Name: claimdefendant_pk; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY claimdefendant
    ADD CONSTRAINT claimdefendant_pk PRIMARY KEY (claimid, defendant);


--
-- Name: claims_claimid_key; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY claims
    ADD CONSTRAINT claims_claimid_key UNIQUE (claimid);


--
-- Name: claims_patient_key; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY claims
    ADD CONSTRAINT claims_patient_key UNIQUE (patient);


--
-- Name: events_pk; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY events
    ADD CONSTRAINT events_pk PRIMARY KEY (claimid, defendant, status);


--
-- Name: salaries_pk; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY salaries
    ADD CONSTRAINT salaries_pk PRIMARY KEY (emp, sal_date);


--
-- Name: statuscodes_pkey; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY statuscodes
    ADD CONSTRAINT statuscodes_pkey PRIMARY KEY (status);


--
-- Name: statuscodes_seq_key; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY statuscodes
    ADD CONSTRAINT statuscodes_seq_key UNIQUE (seq);


--
-- Name: statuscodes_statusdesc_key; Type: CONSTRAINT; Schema: format; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY statuscodes
    ADD CONSTRAINT statuscodes_statusdesc_key UNIQUE (statusdesc);



--
-- Name: badges_active_idx; Type: INDEX; Schema: define; Owner: postgres; Tablespace: 
--

CREATE UNIQUE INDEX badges_active_idx ON badges USING btree (empno, status) WHERE (status = 'A'::bpchar);


--
-- Name: excuselist_idx1; Type: INDEX; Schema: define; Owner: postgres; Tablespace: 
--

CREATE UNIQUE INDEX excuselist_idx1 ON excuselist USING btree (reason);


--
-- Name: index_enddate; Type: INDEX; Schema: define; Owner: postgres; Tablespace: 
--

CREATE UNIQUE INDEX index_enddate ON fiscalyeartable1 USING btree (enddate);


--
-- Name: index_fiscaldate; Type: INDEX; Schema: define; Owner: postgres; Tablespace: 
--

CREATE UNIQUE INDEX index_fiscaldate ON fiscalyeartable1 USING btree (fiscalyear);


--
-- Name: index_startdate; Type: INDEX; Schema: define; Owner: postgres; Tablespace: 
--

CREATE UNIQUE INDEX index_startdate ON fiscalyeartable1 USING btree (startdate);


--
-- Name: absenteeism_deptid_fk; Type: FK CONSTRAINT; Schema: define; Owner: postgres
--

ALTER TABLE ONLY absenteeism
    ADD CONSTRAINT absenteeism_deptid_fk FOREIGN KEY (deptid) REFERENCES departments(deptid) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- Name: absenteeism_empid_fk; Type: FK CONSTRAINT; Schema: define; Owner: postgres
--

ALTER TABLE ONLY absenteeism
    ADD CONSTRAINT absenteeism_empid_fk FOREIGN KEY (empid) REFERENCES employees(empid) ON UPDATE RESTRICT ON DELETE CASCADE;


--
-- Name: absenteeism_reason_fk; Type: FK CONSTRAINT; Schema: define; Owner: postgres
--

ALTER TABLE ONLY absenteeism
    ADD CONSTRAINT absenteeism_reason_fk FOREIGN KEY (reason) REFERENCES excuselist(reason) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- Name: badges_empno_fkey; Type: FK CONSTRAINT; Schema: define; Owner: postgres
--

ALTER TABLE ONLY badges
    ADD CONSTRAINT badges_empno_fkey FOREIGN KEY (empno) REFERENCES secemployees(empno);


--
-- Name: procs_anest_fkey; Type: FK CONSTRAINT; Schema: define; Owner: postgres
--

ALTER TABLE ONLY procs
    ADD CONSTRAINT procs_anest_fkey FOREIGN KEY (anest) REFERENCES doctors(anest);



--
-- Name: claimdefendant_claimid_fkey; Type: FK CONSTRAINT; Schema: format; Owner: postgres
--

ALTER TABLE ONLY claimdefendant
    ADD CONSTRAINT claimdefendant_claimid_fkey FOREIGN KEY (claimid) REFERENCES claims(claimid);


--
-- Name: events_fk; Type: FK CONSTRAINT; Schema: format; Owner: postgres
--

ALTER TABLE ONLY events
    ADD CONSTRAINT events_fk FOREIGN KEY (claimid, defendant) REFERENCES claimdefendant(claimid, defendant);


--
-- Name: events_status_fkey; Type: FK CONSTRAINT; Schema: format; Owner: postgres
--

ALTER TABLE ONLY events
    ADD CONSTRAINT events_status_fkey FOREIGN KEY (status) REFERENCES statuscodes(status);


--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
--

