-- Table: public.components

-- DROP TABLE IF EXISTS public.components;

CREATE TABLE IF NOT EXISTS public.components
(
    component_id integer NOT NULL DEFAULT nextval('seq_components_id'::regclass),
    header_id integer NOT NULL,
    units numeric(9,2) NOT NULL,
    uom_id integer NOT NULL,
    ingredient_id integer NOT NULL,
    qual_ingred_id_1 integer,
    remark character varying(100) COLLATE pg_catalog."default",
    "group" character varying(30) COLLATE pg_catalog."default",
    qual_prep_id integer,
    qual_ingred_id_2 integer,
    qual_prep2_id integer,
    uom_system character varying(10) COLLATE pg_catalog."default",
    uom_system_id integer,
    seq integer,
    CONSTRAINT components_pkey PRIMARY KEY (component_id),
    CONSTRAINT fk_ingredient FOREIGN KEY (ingredient_id)
        REFERENCES public.ingredients (ingredient_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID,
    CONSTRAINT fk_qual_ingred_1 FOREIGN KEY (qual_ingred_id_1)
        REFERENCES public.qual_ingred (qual_ingred_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID,
    CONSTRAINT fk_qual_ingred_2 FOREIGN KEY (qual_ingred_id_2)
        REFERENCES public.qual_ingred (qual_ingred_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID,
    CONSTRAINT fk_qual_prep FOREIGN KEY (qual_prep_id)
        REFERENCES public.qual_prep (qual_prep_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID,
    CONSTRAINT fk_qual_prep2 FOREIGN KEY (qual_prep2_id)
        REFERENCES public.qual_prep (qual_prep_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID,
    CONSTRAINT fk_uom FOREIGN KEY (uom_id)
        REFERENCES public.uom (uom_id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        NOT VALID
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.components
    OWNER to grahamj;
