--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres
--

CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql;


ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: c_customer; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE c_customer (
    c_id integer NOT NULL,
    c_first character(16),
    c_last character(16),
    c_street1 character(20),
    c_street2 character(20),
    c_city character(20),
    c_state character(2),
    c_country character(10),
    c_zip character(9),
    c_phone character(16),
    c_contact character(25),
    c_since date,
    c_balance numeric(12,2),
    c_credit character(2),
    c_credit_limit numeric(12,2),
    c_ytd_payment numeric(12,2)
);


ALTER TABLE public.c_customer OWNER TO spec;

--
-- Name: c_customerinventory; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE c_customerinventory (
    ci_id integer NOT NULL,
    ci_itemid character(20),
    ci_quantity integer,
    ci_customerid integer,
    ci_value numeric(12,2)
);


ALTER TABLE public.c_customerinventory OWNER TO spec;

--
-- Name: c_parts; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE c_parts (
    p_id character(20) NOT NULL,
    p_name character(35),
    p_desc character varying(100),
    p_rev character(6),
    p_unit character(10),
    p_cost numeric(12,2),
    p_price numeric(12,2),
    p_planner integer,
    p_type integer,
    p_ind integer,
    p_lomark integer,
    p_himark integer
);


ALTER TABLE public.c_parts OWNER TO spec;

--
-- Name: c_site; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE c_site (
    site_id integer NOT NULL,
    site_name character(16),
    site_street1 character(20),
    site_street2 character(20),
    site_city character(20),
    site_state character(2),
    site_country character(10),
    site_zip character(9)
);


ALTER TABLE public.c_site OWNER TO spec;

--
-- Name: c_supplier; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE c_supplier (
    supp_id integer NOT NULL,
    supp_name character(16),
    supp_street1 character(20),
    supp_street2 character(20),
    supp_city character(20),
    supp_state character(2),
    supp_country character(10),
    supp_zip character(9),
    supp_phone character(16),
    supp_contact character(25)
);


ALTER TABLE public.c_supplier OWNER TO spec;

--
-- Name: m_bom; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE m_bom (
    b_comp_id character(20) NOT NULL,
    b_assembly_id character(20) NOT NULL,
    b_line_no integer NOT NULL,
    b_qty integer,
    b_ops integer,
    b_eng_change character(10),
    b_ops_desc character varying(100)
);


ALTER TABLE public.m_bom OWNER TO spec;

--
-- Name: m_inventory; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE m_inventory (
    in_p_id character(20) NOT NULL,
    in_qty integer,
    in_ordered integer,
    in_location character(20),
    in_acc_code integer,
    in_act_date date
);


ALTER TABLE public.m_inventory OWNER TO spec;

--
-- Name: m_largeorder; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE m_largeorder (
    lo_id integer NOT NULL,
    lo_o_id integer,
    lo_ol_id integer,
    lo_assembly_id character(20),
    lo_qty integer,
    lo_due_date date,
    lo_category integer
);


ALTER TABLE public.m_largeorder OWNER TO spec;

--
-- Name: m_parts; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE m_parts (
    p_id character(20) NOT NULL,
    p_name character(35),
    p_desc character varying(100),
    p_rev character(6),
    p_planner integer,
    p_type integer,
    p_ind integer,
    p_lomark integer,
    p_himark integer
);


ALTER TABLE public.m_parts OWNER TO spec;

--
-- Name: m_workorder; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE m_workorder (
    wo_number integer NOT NULL,
    wo_o_id integer,
    wo_ol_id integer,
    wo_status integer,
    wo_assembly_id character(20),
    wo_orig_qty integer,
    wo_comp_qty integer,
    wo_due_date date,
    wo_start_date timestamp without time zone
);


ALTER TABLE public.m_workorder OWNER TO spec;

--
-- Name: o_item; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE o_item (
    i_id character(20) NOT NULL,
    i_name character(35),
    i_desc character varying(100),
    i_price numeric(12,2),
    i_discount numeric(6,4),
    i_category integer NOT NULL
);


ALTER TABLE public.o_item OWNER TO spec;

--
-- Name: o_orderline; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE o_orderline (
    ol_id integer NOT NULL,
    ol_o_id integer NOT NULL,
    ol_i_id character(20),
    ol_qty integer,
    ol_total_value numeric(12,2),
    ol_msrp numeric(12,2),
    ol_status integer,
    ol_ship_date date
);


ALTER TABLE public.o_orderline OWNER TO spec;

--
-- Name: o_orders; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE o_orders (
    o_id integer NOT NULL,
    o_c_id integer,
    o_ol_cnt integer,
    o_discount numeric(4,2),
    o_total numeric(12,2),
    o_status integer,
    o_entry_date timestamp without time zone,
    o_ship_date date
);


ALTER TABLE public.o_orders OWNER TO spec;

--
-- Name: s_component; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE s_component (
    comp_id character(20) NOT NULL,
    comp_name character(10),
    comp_desc character varying(100),
    comp_unit character(10),
    comp_cost numeric(12,2),
    qty_on_order integer,
    qty_demanded integer,
    lead_time integer,
    container_size integer
);


ALTER TABLE public.s_component OWNER TO spec;

--
-- Name: s_purchase_order; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE s_purchase_order (
    po_number integer NOT NULL,
    po_supp_id integer,
    po_site_id integer
);


ALTER TABLE public.s_purchase_order OWNER TO spec;

--
-- Name: s_purchase_orderline; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE s_purchase_orderline (
    pol_number integer NOT NULL,
    pol_po_id integer NOT NULL,
    pol_p_id character(20),
    pol_qty integer,
    pol_balance numeric(12,2),
    pol_deldate date,
    pol_message character varying(100)
);


ALTER TABLE public.s_purchase_orderline OWNER TO spec;

--
-- Name: s_site; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE s_site (
    site_id integer NOT NULL,
    site_name character(16),
    site_street1 character(20),
    site_street2 character(20),
    site_city character(20),
    site_state character(2),
    site_country character(10),
    site_zip character(9)
);


ALTER TABLE public.s_site OWNER TO spec;

--
-- Name: s_supp_component; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE s_supp_component (
    sc_p_id character(20) NOT NULL,
    sc_supp_id integer NOT NULL,
    sc_price numeric(12,2),
    sc_qty integer,
    sc_discount numeric(6,4),
    sc_del_date integer
);


ALTER TABLE public.s_supp_component OWNER TO spec;

--
-- Name: s_supplier; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE s_supplier (
    supp_id integer NOT NULL,
    supp_name character(16),
    supp_street1 character(20),
    supp_street2 character(20),
    supp_city character(20),
    supp_state character(2),
    supp_country character(10),
    supp_zip character(9),
    supp_phone character(16),
    supp_contact character(25)
);


ALTER TABLE public.s_supplier OWNER TO spec;

--
-- Name: txn_log_table; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE txn_log_table (
    localtid character varying(8) NOT NULL,
    instancename character varying(32) NOT NULL,
    servername character varying(8) NOT NULL,
    gtrid bytea
);


ALTER TABLE public.txn_log_table OWNER TO spec;

--
-- Name: u_sequences; Type: TABLE; Schema: public; Owner: spec; Tablespace: 
--

CREATE TABLE u_sequences (
    s_id character varying(50) NOT NULL,
    s_nextnum integer,
    s_blocksize integer
);


ALTER TABLE public.u_sequences OWNER TO spec;

--
-- Name: c_customer_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY c_customer
    ADD CONSTRAINT c_customer_pkey PRIMARY KEY (c_id);


--
-- Name: c_customerinventory_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY c_customerinventory
    ADD CONSTRAINT c_customerinventory_pkey PRIMARY KEY (ci_id);


--
-- Name: c_parts_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY c_parts
    ADD CONSTRAINT c_parts_pkey PRIMARY KEY (p_id);


--
-- Name: c_site_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY c_site
    ADD CONSTRAINT c_site_pkey PRIMARY KEY (site_id);


--
-- Name: c_supplier_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY c_supplier
    ADD CONSTRAINT c_supplier_pkey PRIMARY KEY (supp_id);


--
-- Name: m_bom_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY m_bom
    ADD CONSTRAINT m_bom_pkey PRIMARY KEY (b_assembly_id, b_comp_id, b_line_no);


--
-- Name: m_inventory_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY m_inventory
    ADD CONSTRAINT m_inventory_pkey PRIMARY KEY (in_p_id);


--
-- Name: m_largeorder_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY m_largeorder
    ADD CONSTRAINT m_largeorder_pkey PRIMARY KEY (lo_id);


--
-- Name: m_parts_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY m_parts
    ADD CONSTRAINT m_parts_pkey PRIMARY KEY (p_id);


--
-- Name: m_workorder_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY m_workorder
    ADD CONSTRAINT m_workorder_pkey PRIMARY KEY (wo_number);


--
-- Name: o_item_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY o_item
    ADD CONSTRAINT o_item_pkey PRIMARY KEY (i_id);


--
-- Name: o_orderline_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY o_orderline
    ADD CONSTRAINT o_orderline_pkey PRIMARY KEY (ol_o_id, ol_id);


--
-- Name: o_orders_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY o_orders
    ADD CONSTRAINT o_orders_pkey PRIMARY KEY (o_id);


--
-- Name: s_component_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY s_component
    ADD CONSTRAINT s_component_pkey PRIMARY KEY (comp_id);


--
-- Name: s_purchase_order_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY s_purchase_order
    ADD CONSTRAINT s_purchase_order_pkey PRIMARY KEY (po_number);


--
-- Name: s_purchase_orderline_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY s_purchase_orderline
    ADD CONSTRAINT s_purchase_orderline_pkey PRIMARY KEY (pol_po_id, pol_number);


--
-- Name: s_site_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY s_site
    ADD CONSTRAINT s_site_pkey PRIMARY KEY (site_id);


--
-- Name: s_supp_component_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY s_supp_component
    ADD CONSTRAINT s_supp_component_pkey PRIMARY KEY (sc_p_id, sc_supp_id);


--
-- Name: s_supplier_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY s_supplier
    ADD CONSTRAINT s_supplier_pkey PRIMARY KEY (supp_id);


--
-- Name: txn_log_table_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY txn_log_table
    ADD CONSTRAINT txn_log_table_pkey PRIMARY KEY (localtid);


--
-- Name: u_sequences_pkey; Type: CONSTRAINT; Schema: public; Owner: spec; Tablespace: 
--

ALTER TABLE ONLY u_sequences
    ADD CONSTRAINT u_sequences_pkey PRIMARY KEY (s_id);


--
-- Name: c_custci_idx; Type: INDEX; Schema: public; Owner: spec; Tablespace: 
--

CREATE INDEX c_custci_idx ON c_customerinventory USING btree (ci_customerid);


--
-- Name: m_lo_cat_idx; Type: INDEX; Schema: public; Owner: spec; Tablespace: 
--

CREATE INDEX m_lo_cat_idx ON m_largeorder USING btree (lo_category);


--
-- Name: m_lo_o_idx; Type: INDEX; Schema: public; Owner: spec; Tablespace: 
--

CREATE UNIQUE INDEX m_lo_o_idx ON m_largeorder USING btree (lo_o_id, lo_ol_id);


--
-- Name: o_icat_idx; Type: INDEX; Schema: public; Owner: spec; Tablespace: 
--

CREATE INDEX o_icat_idx ON o_item USING btree (i_category);


--
-- Name: o_oc_idx; Type: INDEX; Schema: public; Owner: spec; Tablespace: 
--

CREATE INDEX o_oc_idx ON o_orders USING btree (o_c_id);


--
-- 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;


--
-- PostgreSQL database dump complete
--

