--
--


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

--
-- Name: drugbank; Type: SCHEMA; Schema: -; Owner: pharm_su
--

CREATE SCHEMA drugbank;


ALTER SCHEMA drugbank OWNER TO pharm_su;

--
-- Name: drugs_at_fda; Type: SCHEMA; Schema: -; Owner: pharm_su
--

CREATE SCHEMA drugs_at_fda;


ALTER SCHEMA drugs_at_fda OWNER TO pharm_su;

--
-- Name: fda; Type: SCHEMA; Schema: -; Owner: pharm_su
--

CREATE SCHEMA fda;


ALTER SCHEMA fda OWNER TO pharm_su;

--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

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


--
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA public;


--
-- Name: EXTENSION fuzzystrmatch; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION fuzzystrmatch IS 'determine similarities and distance between strings';


--
-- Name: check_integrity_d_appl_drugusage_pharmaproduct(); Type: FUNCTION; Schema: public; Owner: pharm_su
--

CREATE FUNCTION public.check_integrity_d_appl_drugusage_pharmaproduct() RETURNS trigger
    LANGUAGE plpgsql
    AS $$

BEGIN

    IF (SELECT count(DA.*) FROM public.D_APPL DA WHERE EXISTS (SELECT * FROM

public.DRUGUSAGE DD WHERE DD.drug_seq=DA.drug_seq and DD.brandname is not Null and DA.drugname is not null)) > 0

    THEN

       RAISE EXCEPTION 'At-least-once constraint on table D_APPL violated!';

       ROLLBACK TRANSACTION;

    END IF;

    RETURN NULL;

END;

$$;


ALTER FUNCTION public.check_integrity_d_appl_drugusage_pharmaproduct() OWNER TO pharm_su;

--
-- Name: check_integrity_drugusage_d_appl_pharmaproduct(); Type: FUNCTION; Schema: public; Owner: pharm_su
--

CREATE FUNCTION public.check_integrity_drugusage_d_appl_pharmaproduct() RETURNS trigger
    LANGUAGE plpgsql
    AS $$

BEGIN

    IF (SELECT count(DD.*) FROM public.DRUGUSAGE DD WHERE EXISTS (SELECT * FROM

public.D_APPL DA WHERE DD.drug_seq=DA.drug_seq and DA.drugname is not Null and DD.brandname is not null)) > 0

    THEN

       RAISE EXCEPTION 'At-least-once constraint on table DRUGUSAGE violated!';

       ROLLBACK TRANSACTION;

    END IF;

    RETURN NULL;

END;

$$;


ALTER FUNCTION public.check_integrity_drugusage_d_appl_pharmaproduct() OWNER TO pharm_su;

--
-- Name: check_integrity_report(); Type: FUNCTION; Schema: public; Owner: pharm_su
--

CREATE FUNCTION public.check_integrity_report() RETURNS trigger
    LANGUAGE plpgsql
    AS $$

BEGIN

IF (SELECT COUNT(R.*) FROM Report R WHERE NOT EXISTS (SELECT * FROM

Drugusage D WHERE D.isr=R.isr)) > 0

THEN

RAISE EXCEPTION 'At-least-once constraint on table Report violated!';

ROLLBACK TRANSACTION;

END IF;

RETURN NULL;

END;

$$;


ALTER FUNCTION public.check_integrity_report() OWNER TO pharm_su;



--
-- Name: clean_import; Type: TABLE; Schema: drugbank; Owner: pharm_su
--

CREATE TABLE drugbank.clean_import (
    id integer NOT NULL,
    drugname text NOT NULL,
    brandname text,
    release text,
    biological boolean,
    route text,
    unit text,
    classes text,
    "REM" text
);


ALTER TABLE drugbank.clean_import OWNER TO pharm_su;

--
-- Name: clean_import_id_seq; Type: SEQUENCE; Schema: drugbank; Owner: pharm_su
--

CREATE SEQUENCE drugbank.clean_import_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE drugbank.clean_import_id_seq OWNER TO pharm_su;

--
-- Name: clean_import_id_seq; Type: SEQUENCE OWNED BY; Schema: drugbank; Owner: pharm_su
--

ALTER SEQUENCE drugbank.clean_import_id_seq OWNED BY drugbank.clean_import.id;


--
-- Name: csv_raw; Type: TABLE; Schema: drugbank; Owner: pharm_su
--

CREATE TABLE drugbank.csv_raw (
    id integer NOT NULL,
    count text DEFAULT ''::text NOT NULL,
    drugname text DEFAULT ''::text NOT NULL,
    brandname text DEFAULT ''::text NOT NULL,
    usan text DEFAULT ''::text NOT NULL,
    enatiomer text DEFAULT ''::text NOT NULL,
    salt text DEFAULT ''::text NOT NULL,
    release text DEFAULT ''::text NOT NULL,
    biological text DEFAULT ''::text NOT NULL,
    route text DEFAULT ''::text NOT NULL,
    dose text DEFAULT ''::text NOT NULL,
    unit text DEFAULT ''::text NOT NULL,
    classes text DEFAULT ''::text NOT NULL,
    "REM" text DEFAULT ''::text NOT NULL
);


ALTER TABLE drugbank.csv_raw OWNER TO pharm_su;

--
-- Name: csv_raw_id_seq; Type: SEQUENCE; Schema: drugbank; Owner: pharm_su
--

CREATE SEQUENCE drugbank.csv_raw_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE drugbank.csv_raw_id_seq OWNER TO pharm_su;

--
-- Name: csv_raw_id_seq; Type: SEQUENCE OWNED BY; Schema: drugbank; Owner: pharm_su
--

ALTER SEQUENCE drugbank.csv_raw_id_seq OWNED BY drugbank.csv_raw.id;


--
-- Name: csv_splittet; Type: TABLE; Schema: drugbank; Owner: pharm_su
--

CREATE TABLE drugbank.csv_splittet (
    id integer NOT NULL,
    id_raw integer NOT NULL,
    count text DEFAULT ''::text NOT NULL,
    drugname text DEFAULT ''::text NOT NULL,
    brandname text DEFAULT ''::text NOT NULL,
    usan text DEFAULT ''::text NOT NULL,
    enatiomer text DEFAULT ''::text NOT NULL,
    salt text DEFAULT ''::text NOT NULL,
    release text DEFAULT ''::text NOT NULL,
    biological text DEFAULT ''::text NOT NULL,
    route text DEFAULT ''::text NOT NULL,
    dose text DEFAULT ''::text NOT NULL,
    unit text DEFAULT ''::text NOT NULL,
    classes text DEFAULT ''::text NOT NULL,
    "REM" text DEFAULT ''::text NOT NULL
);


ALTER TABLE drugbank.csv_splittet OWNER TO pharm_su;

--
-- Name: csv_splittet_id_seq; Type: SEQUENCE; Schema: drugbank; Owner: pharm_su
--

CREATE SEQUENCE drugbank.csv_splittet_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE drugbank.csv_splittet_id_seq OWNER TO pharm_su;

--
-- Name: csv_splittet_id_seq; Type: SEQUENCE OWNED BY; Schema: drugbank; Owner: pharm_su
--

ALTER SEQUENCE drugbank.csv_splittet_id_seq OWNED BY drugbank.csv_splittet.id;


--
-- Name: drug_characteristic; Type: TABLE; Schema: drugbank; Owner: pharm_su
--

CREATE TABLE drugbank.drug_characteristic (
    name text NOT NULL,
    type text NOT NULL
);


ALTER TABLE drugbank.drug_characteristic OWNER TO pharm_su;

--
-- Name: mixture_invalid; Type: TABLE; Schema: drugbank; Owner: pharm_su
--

CREATE TABLE drugbank.mixture_invalid (
    id integer NOT NULL,
    pharmaproduct text NOT NULL,
    component text NOT NULL,
    allocable boolean NOT NULL,
    decision_background_id smallint
);


ALTER TABLE drugbank.mixture_invalid OWNER TO pharm_su;

--
-- Name: mixture_invalid_id_seq; Type: SEQUENCE; Schema: drugbank; Owner: pharm_su
--

CREATE SEQUENCE drugbank.mixture_invalid_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE drugbank.mixture_invalid_id_seq OWNER TO pharm_su;

--
-- Name: mixture_invalid_id_seq; Type: SEQUENCE OWNED BY; Schema: drugbank; Owner: pharm_su
--

ALTER SEQUENCE drugbank.mixture_invalid_id_seq OWNED BY drugbank.mixture_invalid.id;


--
-- Name: matching_activeingredsplit; Type: TABLE; Schema: drugs_at_fda; Owner: pharm_su
--

CREATE TABLE drugs_at_fda.matching_activeingredsplit (
    id integer NOT NULL,
    productid integer NOT NULL,
    activeingredpart character varying NOT NULL,
    decision_background_id smallint
);


ALTER TABLE drugs_at_fda.matching_activeingredsplit OWNER TO pharm_su;

--
-- Name: matching_activeingredsplit_id_seq; Type: SEQUENCE; Schema: drugs_at_fda; Owner: pharm_su
--

CREATE SEQUENCE drugs_at_fda.matching_activeingredsplit_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE drugs_at_fda.matching_activeingredsplit_id_seq OWNER TO pharm_su;

--
-- Name: matching_activeingredsplit_id_seq; Type: SEQUENCE OWNED BY; Schema: drugs_at_fda; Owner: pharm_su
--

ALTER SEQUENCE drugs_at_fda.matching_activeingredsplit_id_seq OWNED BY drugs_at_fda.matching_activeingredsplit.id;


--
-- Name: matching_characteristicsplit; Type: TABLE; Schema: drugs_at_fda; Owner: pharm_su
--

CREATE TABLE drugs_at_fda.matching_characteristicsplit (
    activeingredpartid integer NOT NULL,
    drugname character varying NOT NULL,
    characteristic character varying NOT NULL
);


ALTER TABLE drugs_at_fda.matching_characteristicsplit OWNER TO pharm_su;

--
-- Name: not_matchable_split; Type: TABLE; Schema: drugs_at_fda; Owner: pharm_su
--

CREATE TABLE drugs_at_fda.not_matchable_split (
    drugname character varying NOT NULL,
    salt character varying NOT NULL,
    drugpart character varying NOT NULL
);


ALTER TABLE drugs_at_fda.not_matchable_split OWNER TO pharm_su;

--
-- Name: product; Type: TABLE; Schema: drugs_at_fda; Owner: pharm_su
--

CREATE TABLE drugs_at_fda.product (
    id integer NOT NULL,
    name character varying NOT NULL,
    activeingred character varying NOT NULL,
    migrated boolean,
    decision_background_id smallint
);


ALTER TABLE drugs_at_fda.product OWNER TO pharm_su;

--
-- Name: product_id_seq; Type: SEQUENCE; Schema: drugs_at_fda; Owner: pharm_su
--

CREATE SEQUENCE drugs_at_fda.product_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE drugs_at_fda.product_id_seq OWNER TO pharm_su;

--
-- Name: product_id_seq; Type: SEQUENCE OWNED BY; Schema: drugs_at_fda; Owner: pharm_su
--

ALTER SEQUENCE drugs_at_fda.product_id_seq OWNED BY drugs_at_fda.product.id;


--
-- Name: demo; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.demo (
    id integer NOT NULL,
    isr text,
    case_no text,
    i_f_cod text,
    foll_seq text,
    image text,
    event_dt text,
    mfr_dt text,
    fda_dt text,
    rept_cod text,
    mfr_num text,
    mfr_sndr text,
    age text,
    age_cod text,
    gndr_cod text,
    e_sub text,
    wt text,
    wt_cod text,
    rept_dt text,
    occp_cod text,
    death_dt text,
    to_mfr text,
    confid text,
    reporter_country text,
    caseversion text,
    init_fda_dt text,
    occr_country text,
    auth_num text,
    lit_ref text,
    age_grp text,
    event_dt_type text
);


ALTER TABLE fda.demo OWNER TO pharm_su;

--
-- Name: demo_age; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.demo_age (
    id integer NOT NULL,
    age_years integer,
    age_days integer,
    age_hours numeric(4,2)
);


ALTER TABLE fda.demo_age OWNER TO pharm_su;

--
-- Name: demo_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.demo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.demo_id_seq OWNER TO pharm_su;

--
-- Name: demo_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.demo_id_seq OWNED BY fda.demo.id;


--
-- Name: drug; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.drug (
    id integer NOT NULL,
    isr text,
    drug_seq text,
    role_cod text,
    drugname text,
    val_vbm text,
    route text,
    dose_vbm text,
    dechal text,
    rechal text,
    lot_num text,
    exp_dt text,
    nda_num text,
    caseid text,
    cum_dose_chr text,
    cum_dose_unit text,
    dose_amt text,
    dose_unit text,
    dose_form text,
    dose_freq text,
    prod_ai text
);


ALTER TABLE fda.drug OWNER TO pharm_su;

--
-- Name: drug_application; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.drug_application (
    id integer NOT NULL,
    drug_seq text,
    drugname_part text,
    name text,
    type character varying(7)
);


ALTER TABLE fda.drug_application OWNER TO pharm_su;

--
-- Name: drug_application_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.drug_application_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.drug_application_id_seq OWNER TO pharm_su;

--
-- Name: drug_application_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.drug_application_id_seq OWNED BY fda.drug_application.id;


--
-- Name: drug_dose; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.drug_dose (
    id integer NOT NULL,
    dailymgdose numeric(10,3)
);


ALTER TABLE fda.drug_dose OWNER TO pharm_su;

--
-- Name: drug_drugname_not_matchable; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.drug_drugname_not_matchable (
    drugname text,
    drug_seq text NOT NULL
);


ALTER TABLE fda.drug_drugname_not_matchable OWNER TO pharm_su;

--
-- Name: drug_drugname_not_matchable_drugname_saltsplit; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.drug_drugname_not_matchable_drugname_saltsplit (
    id integer NOT NULL,
    drugpart character varying(300) NOT NULL,
    saltpart character varying(300) NOT NULL
);


ALTER TABLE fda.drug_drugname_not_matchable_drugname_saltsplit OWNER TO pharm_su;

--
-- Name: drug_drugname_not_matchable_drugname_saltsplit_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.drug_drugname_not_matchable_drugname_saltsplit_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.drug_drugname_not_matchable_drugname_saltsplit_id_seq OWNER TO pharm_su;

--
-- Name: drug_drugname_not_matchable_drugname_saltsplit_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.drug_drugname_not_matchable_drugname_saltsplit_id_seq OWNED BY fda.drug_drugname_not_matchable_drugname_saltsplit.id;


--
-- Name: drug_drugname_split; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.drug_drugname_split (
    id integer NOT NULL,
    drug_seq text,
    drugname_part text
);


ALTER TABLE fda.drug_drugname_split OWNER TO pharm_su;

--
-- Name: drug_drugname_split_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.drug_drugname_split_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.drug_drugname_split_id_seq OWNER TO pharm_su;

--
-- Name: drug_drugname_split_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.drug_drugname_split_id_seq OWNED BY fda.drug_drugname_split.id;


--
-- Name: drug_drugname_split_initial; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.drug_drugname_split_initial (
    id integer NOT NULL,
    drug_seq text,
    drugname_part text
);


ALTER TABLE fda.drug_drugname_split_initial OWNER TO pharm_su;

--
-- Name: drug_drugname_split_initial_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.drug_drugname_split_initial_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.drug_drugname_split_initial_id_seq OWNER TO pharm_su;

--
-- Name: drug_drugname_split_initial_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.drug_drugname_split_initial_id_seq OWNED BY fda.drug_drugname_split_initial.id;


--
-- Name: drug_drugname_split_without_bad_endings; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.drug_drugname_split_without_bad_endings (
    id integer NOT NULL,
    drug_seq text,
    drugname_part text
);


ALTER TABLE fda.drug_drugname_split_without_bad_endings OWNER TO pharm_su;

--
-- Name: drug_drugname_split_without_bad_endings_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.drug_drugname_split_without_bad_endings_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.drug_drugname_split_without_bad_endings_id_seq OWNER TO pharm_su;

--
-- Name: drug_drugname_split_without_bad_endings_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.drug_drugname_split_without_bad_endings_id_seq OWNED BY fda.drug_drugname_split_without_bad_endings.id;


--
-- Name: drug_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.drug_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.drug_id_seq OWNER TO pharm_su;

--
-- Name: drug_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.drug_id_seq OWNED BY fda.drug.id;


--
-- Name: indi; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.indi (
    id integer NOT NULL,
    isr text,
    drug_seq text,
    indi_pt text,
    caseid text
);


ALTER TABLE fda.indi OWNER TO pharm_su;

--
-- Name: indi_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.indi_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.indi_id_seq OWNER TO pharm_su;

--
-- Name: indi_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.indi_id_seq OWNED BY fda.indi.id;


--
-- Name: invalid; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.invalid (
    id integer NOT NULL,
    file character varying(20) NOT NULL,
    line_number integer,
    line text NOT NULL
);


ALTER TABLE fda.invalid OWNER TO pharm_su;

--
-- Name: invalid_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.invalid_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.invalid_id_seq OWNER TO pharm_su;

--
-- Name: invalid_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.invalid_id_seq OWNED BY fda.invalid.id;


--
-- Name: invalid_isrs; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.invalid_isrs (
    isr text NOT NULL,
    reason character(2)
);


ALTER TABLE fda.invalid_isrs OWNER TO pharm_su;

--
-- Name: outc; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.outc (
    id integer NOT NULL,
    isr text,
    outc_cod text,
    caseid text
);


ALTER TABLE fda.outc OWNER TO pharm_su;

--
-- Name: outc_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.outc_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.outc_id_seq OWNER TO pharm_su;

--
-- Name: outc_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.outc_id_seq OWNED BY fda.outc.id;


--
-- Name: reac; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.reac (
    id integer NOT NULL,
    isr text,
    pt text,
    caseid text,
    drug_rec_act text
);


ALTER TABLE fda.reac OWNER TO pharm_su;

--
-- Name: reac_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.reac_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.reac_id_seq OWNER TO pharm_su;

--
-- Name: reac_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.reac_id_seq OWNED BY fda.reac.id;


--
-- Name: rpsr; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.rpsr (
    id integer NOT NULL,
    isr text,
    rpsr_cod text,
    caseid text
);


ALTER TABLE fda.rpsr OWNER TO pharm_su;

--
-- Name: rpsr_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.rpsr_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.rpsr_id_seq OWNER TO pharm_su;

--
-- Name: rpsr_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.rpsr_id_seq OWNED BY fda.rpsr.id;


--
-- Name: ther; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.ther (
    id integer NOT NULL,
    isr text,
    drug_seq text,
    start_dt text,
    end_dt text,
    dur text,
    dur_cod text,
    caseid text
);


ALTER TABLE fda.ther OWNER TO pharm_su;

--
-- Name: ther_duration; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.ther_duration (
    id integer NOT NULL,
    dur_years integer,
    dur_days integer,
    dur_seconds integer
);


ALTER TABLE fda.ther_duration OWNER TO pharm_su;

--
-- Name: ther_id_seq; Type: SEQUENCE; Schema: fda; Owner: pharm_su
--

CREATE SEQUENCE fda.ther_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fda.ther_id_seq OWNER TO pharm_su;

--
-- Name: ther_id_seq; Type: SEQUENCE OWNED BY; Schema: fda; Owner: pharm_su
--

ALTER SEQUENCE fda.ther_id_seq OWNED BY fda.ther.id;


--
-- Name: ther_t_id; Type: TABLE; Schema: fda; Owner: pharm_su
--

CREATE TABLE fda.ther_t_id (
    id integer NOT NULL,
    t_id integer NOT NULL
);


ALTER TABLE fda.ther_t_id OWNER TO pharm_su;

--
-- Name: atc_code; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.atc_code (
    code character varying(100) NOT NULL,
    drugname character varying(300) NOT NULL,
    decision_background_id smallint
);


ALTER TABLE public.atc_code OWNER TO pharm_su;

--
-- Name: codes; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.codes (
    name character varying(20) NOT NULL,
    code character(3) NOT NULL,
    meaning character varying(100) NOT NULL
);


ALTER TABLE public.codes OWNER TO pharm_su;

--
-- Name: component; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.component (
    name character varying(100) NOT NULL,
    drugname character varying(300) NOT NULL,
    decision_background_id smallint
);


ALTER TABLE public.component OWNER TO pharm_su;

--
-- Name: countries; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.countries (
    country text NOT NULL,
    continent character varying(100),
    code character(2)
);


ALTER TABLE public.countries OWNER TO pharm_su;

--
-- Name: d_appl; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.d_appl (
    drugname character varying(300) NOT NULL,
    drug_seq bigint NOT NULL
);


ALTER TABLE public.d_appl OWNER TO pharm_su;

--
-- Name: drug; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.drug (
    drugname character varying(300) NOT NULL,
    lastupdate date,
    drugbank_id character(15),
    ddd numeric(7,2),
    decision_background_id smallint
);


ALTER TABLE public.drug OWNER TO pharm_su;

--
-- Name: drugusage; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.drugusage (
    drug_seq bigint NOT NULL,
    role_cod character(2),
    val_vbm character(1),
    route character varying(37),
    dose_vbm character varying(100),
    dechal character(1),
    rechal character(1),
    lot_num character varying(36),
    exp_dt date,
    nda_num character varying(35),
    dailydosis numeric(10,3),
    isr bigint NOT NULL,
    brandname character varying(300),
    drugname_orig text,
    cum_dose_chr character varying(20),
    cum_dose_unit character(9),
    dose_amt character varying(20),
    dose_unit character(9),
    dose_form character varying(50),
    dose_freq character(9)
);


ALTER TABLE public.drugusage OWNER TO pharm_su;

--
-- Name: drugusview; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.drugusview (
    drug_seq bigint NOT NULL,
    brandname character varying(300),
    isr integer
);


ALTER TABLE public.drugusview OWNER TO postgres;

--
-- Name: drugusviewdrug; Type: TABLE; Schema: public; Owner: pharm_admin
--

CREATE TABLE public.drugusviewdrug (
    drug_seq bigint NOT NULL,
    drugname character varying(300) NOT NULL,
    isr integer
);


ALTER TABLE public.drugusviewdrug OWNER TO pharm_admin;

--
-- Name: event; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.event (
    pt character varying(100) NOT NULL,
    sysorgclass smallint
);


ALTER TABLE public.event OWNER TO pharm_su;

--
-- Name: hlt; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.hlt (
    hlt_code integer NOT NULL,
    hlt_name character varying(100) NOT NULL
);


ALTER TABLE public.hlt OWNER TO pharm_su;

--
-- Name: hlt_pt; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.hlt_pt (
    hlt_code integer NOT NULL,
    pt_code integer NOT NULL
);


ALTER TABLE public.hlt_pt OWNER TO pharm_su;

--
-- Name: hlt_pt_temp; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.hlt_pt_temp (
    hlt_code integer NOT NULL,
    pt_code integer NOT NULL,
    nothing text
);


ALTER TABLE public.hlt_pt_temp OWNER TO pharm_su;

--
-- Name: hlt_temp; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.hlt_temp (
    hlt_code integer NOT NULL,
    hlt_name character varying(100) NOT NULL,
    a text,
    b text,
    c text,
    d text,
    e text,
    f text,
    g text
);


ALTER TABLE public.hlt_temp OWNER TO postgres;

--
-- Name: imported_files; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.imported_files (
    id integer NOT NULL,
    filename text,
    import_dt timestamp without time zone
);


ALTER TABLE public.imported_files OWNER TO pharm_su;

--
-- Name: imported_files_id_seq; Type: SEQUENCE; Schema: public; Owner: pharm_su
--

CREATE SEQUENCE public.imported_files_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.imported_files_id_seq OWNER TO pharm_su;

--
-- Name: imported_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pharm_su
--

ALTER SEQUENCE public.imported_files_id_seq OWNED BY public.imported_files.id;


--
-- Name: incomplete; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.incomplete (
    name character varying(200) NOT NULL,
    decision_background_id smallint
);


ALTER TABLE public.incomplete OWNER TO pharm_su;

--
-- Name: indication; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.indication (
    indi_pt character varying(100) NOT NULL,
    anatomgrp smallint
);


ALTER TABLE public.indication OWNER TO pharm_su;

--
-- Name: llt; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.llt (
    llt_code integer NOT NULL,
    llt_name character varying(100) NOT NULL,
    pt_code integer NOT NULL
);


ALTER TABLE public.llt OWNER TO pharm_su;

--
-- Name: llt_temp; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.llt_temp (
    llt_code integer NOT NULL,
    llt_name character varying(100) NOT NULL,
    pt_code integer NOT NULL,
    a text,
    b text,
    c text,
    d text,
    e text,
    f text,
    g text,
    h text
);


ALTER TABLE public.llt_temp OWNER TO postgres;

--
-- Name: misspellings; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.misspellings (
    type character varying(7) NOT NULL,
    name character varying(300),
    misspelling character varying(400) NOT NULL
);


ALTER TABLE public.misspellings OWNER TO pharm_su;

--
-- Name: mrisr; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.mrisr (
    isr bigint NOT NULL,
    case_id bigint
);


ALTER TABLE public.mrisr OWNER TO postgres;

--
-- Name: notconsidered; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.notconsidered (
    id integer NOT NULL,
    drug_seq text,
    drugname text,
    quarter text
);


ALTER TABLE public.notconsidered OWNER TO pharm_su;

--
-- Name: notconsidered_count; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.notconsidered_count (
    id integer NOT NULL,
    drugname text,
    drugnamescount text
);


ALTER TABLE public.notconsidered_count OWNER TO pharm_su;

--
-- Name: notconsidered_count_id_seq; Type: SEQUENCE; Schema: public; Owner: pharm_su
--

CREATE SEQUENCE public.notconsidered_count_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.notconsidered_count_id_seq OWNER TO pharm_su;

--
-- Name: notconsidered_count_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pharm_su
--

ALTER SEQUENCE public.notconsidered_count_id_seq OWNED BY public.notconsidered_count.id;


--
-- Name: notconsidered_id_seq; Type: SEQUENCE; Schema: public; Owner: pharm_su
--

CREATE SEQUENCE public.notconsidered_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.notconsidered_id_seq OWNER TO pharm_su;

--
-- Name: notconsidered_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pharm_su
--

ALTER SEQUENCE public.notconsidered_id_seq OWNED BY public.notconsidered.id;


--
-- Name: outcome; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.outcome (
    outc_cod character(2) NOT NULL,
    meaning character varying(70)
);


ALTER TABLE public.outcome OWNER TO pharm_su;

--
-- Name: pharmaproduct; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.pharmaproduct (
    brandname character varying(300) NOT NULL,
    form character varying(40),
    salt character varying(300),
    biologic character varying(20),
    type character(1),
    producer_name character varying(100),
    enantiomer_rs character(1),
    enantiomer_dl character(1),
    enantiomer_plusminus character(1),
    decision_background_id smallint
);


ALTER TABLE public.pharmaproduct OWNER TO pharm_su;

--
-- Name: producer; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.producer (
    name character varying(100) NOT NULL
);


ALTER TABLE public.producer OWNER TO pharm_su;

--
-- Name: product; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.product (
    brandname character varying(300) NOT NULL,
    drugname character varying(300) NOT NULL,
    decision_background_id smallint
);


ALTER TABLE public.product OWNER TO pharm_su;

--
-- Name: pt; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.pt (
    pt_code integer NOT NULL,
    pt_name character varying(100) NOT NULL,
    pt_soc_code integer NOT NULL
);


ALTER TABLE public.pt OWNER TO pharm_su;

--
-- Name: pt_temp; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.pt_temp (
    pt_code integer NOT NULL,
    pt_name character varying(100) NOT NULL,
    null_field character(1),
    pt_soc_code integer NOT NULL,
    a text,
    b text,
    c text,
    d text,
    e text,
    f text,
    g text,
    h text
);


ALTER TABLE public.pt_temp OWNER TO postgres;

--
-- Name: rep_event; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.rep_event (
    pt character varying(100) NOT NULL,
    isr bigint NOT NULL
);


ALTER TABLE public.rep_event OWNER TO pharm_su;

--
-- Name: rep_hlt; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.rep_hlt (
    hlt_code integer NOT NULL,
    isr bigint NOT NULL
);


ALTER TABLE public.rep_hlt OWNER TO pharm_su;

--
-- Name: rep_outcome; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.rep_outcome (
    outc_cod character(2) NOT NULL,
    isr bigint NOT NULL
);


ALTER TABLE public.rep_outcome OWNER TO pharm_su;

--
-- Name: rep_pt; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.rep_pt (
    pt character varying(100) NOT NULL,
    isr bigint NOT NULL,
    pt_code integer NOT NULL
);


ALTER TABLE public.rep_pt OWNER TO pharm_su;

--
-- Name: rep_rpsr; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.rep_rpsr (
    rpsr_cod character(3) NOT NULL,
    isr bigint NOT NULL
);


ALTER TABLE public.rep_rpsr OWNER TO pharm_su;

--
-- Name: rep_smq_b; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.rep_smq_b (
    smq_code integer NOT NULL,
    isr bigint NOT NULL
);


ALTER TABLE public.rep_smq_b OWNER TO pharm_su;

--
-- Name: rep_smq_n; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.rep_smq_n (
    smq_code integer NOT NULL,
    isr bigint NOT NULL
);


ALTER TABLE public.rep_smq_n OWNER TO pharm_su;

--
-- Name: report; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.report (
    isr bigint NOT NULL,
    i_f_cod character(1),
    foll_seq character(2),
    event_dt date,
    mfr_dt date,
    fda_dt date,
    rept_cod character(3),
    mfr_num character varying(100),
    mfr_sndr character varying(60),
    age numeric(7,2),
    age_cod character(3),
    gndr_cod character(3),
    e_sub character(1),
    occp_cod character(2),
    death_dt date,
    to_mfr character(1),
    confid character(1),
    reporter_country character varying(50),
    image character varying(12),
    wt numeric(11,5),
    wt_cod character(3),
    rept_dt date,
    case_id bigint,
    age_years integer,
    age_days integer,
    age_hours numeric(4,2),
    caseversion integer,
    init_fda_dt date,
    occr_country character(5),
    event_dt_type character(1)
);


ALTER TABLE public.report OWNER TO pharm_su;

--
-- Name: rpsr; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.rpsr (
    rpsr_cod character(3) NOT NULL,
    meaning character varying(30)
);


ALTER TABLE public.rpsr OWNER TO pharm_su;

--
-- Name: smq; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.smq (
    smq_code integer NOT NULL,
    smq_name character varying(100) NOT NULL,
    smq_level smallint
);


ALTER TABLE public.smq OWNER TO pharm_su;

--
-- Name: smq_content; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.smq_content (
    smq_code integer NOT NULL,
    term_code integer NOT NULL,
    term_level smallint NOT NULL,
    term_scope smallint NOT NULL
);


ALTER TABLE public.smq_content OWNER TO pharm_su;

--
-- Name: smq_content_temp; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.smq_content_temp (
    smq_code integer NOT NULL,
    term_code integer NOT NULL,
    term_level smallint,
    term_scope smallint,
    a text,
    b text,
    c text,
    d text,
    e text,
    f text
);


ALTER TABLE public.smq_content_temp OWNER TO pharm_su;

--
-- Name: smq_temp; Type: TABLE; Schema: public; Owner: postgres
--

CREATE TABLE public.smq_temp (
    smq_code integer NOT NULL,
    smq_name character varying(100) NOT NULL,
    smq_level smallint,
    b text,
    c text,
    d text,
    e text,
    f text,
    g text,
    h text
);


ALTER TABLE public.smq_temp OWNER TO postgres;

--
-- Name: substructures; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.substructures (
    name character varying(100) NOT NULL,
    decision_background_id smallint
);


ALTER TABLE public.substructures OWNER TO pharm_su;

--
-- Name: synonyms; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.synonyms (
    name character varying(300) NOT NULL,
    drugname character varying(300) NOT NULL,
    decision_background_id smallint
);


ALTER TABLE public.synonyms OWNER TO pharm_su;

--
-- Name: therapy; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.therapy (
    drug_seq bigint NOT NULL,
    start_dt date,
    end_dt date,
    dur_cod character(3),
    dur integer,
    t_id smallint NOT NULL,
    dur_years integer,
    dur_days integer,
    dur_seconds integer
);


ALTER TABLE public.therapy OWNER TO pharm_su;

--
-- Name: unclassified; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.unclassified (
    name character varying(200) NOT NULL,
    brandname character varying(300) NOT NULL,
    decision_background_id smallint
);


ALTER TABLE public.unclassified OWNER TO pharm_su;

--
-- Name: used; Type: TABLE; Schema: public; Owner: pharm_su
--

CREATE TABLE public.used (
    drug_seq bigint NOT NULL,
    indi_pt character varying(100) NOT NULL
);


ALTER TABLE public.used OWNER TO pharm_su;

--
-- Name: clean_import id; Type: DEFAULT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.clean_import ALTER COLUMN id SET DEFAULT nextval('drugbank.clean_import_id_seq'::regclass);


--
-- Name: csv_raw id; Type: DEFAULT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.csv_raw ALTER COLUMN id SET DEFAULT nextval('drugbank.csv_raw_id_seq'::regclass);


--
-- Name: csv_splittet id; Type: DEFAULT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.csv_splittet ALTER COLUMN id SET DEFAULT nextval('drugbank.csv_splittet_id_seq'::regclass);


--
-- Name: mixture_invalid id; Type: DEFAULT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.mixture_invalid ALTER COLUMN id SET DEFAULT nextval('drugbank.mixture_invalid_id_seq'::regclass);


--
-- Name: matching_activeingredsplit id; Type: DEFAULT; Schema: drugs_at_fda; Owner: pharm_su
--

ALTER TABLE ONLY drugs_at_fda.matching_activeingredsplit ALTER COLUMN id SET DEFAULT nextval('drugs_at_fda.matching_activeingredsplit_id_seq'::regclass);


--
-- Name: product id; Type: DEFAULT; Schema: drugs_at_fda; Owner: pharm_su
--

ALTER TABLE ONLY drugs_at_fda.product ALTER COLUMN id SET DEFAULT nextval('drugs_at_fda.product_id_seq'::regclass);


--
-- Name: demo id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.demo ALTER COLUMN id SET DEFAULT nextval('fda.demo_id_seq'::regclass);


--
-- Name: drug id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug ALTER COLUMN id SET DEFAULT nextval('fda.drug_id_seq'::regclass);


--
-- Name: drug_application id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_application ALTER COLUMN id SET DEFAULT nextval('fda.drug_application_id_seq'::regclass);


--
-- Name: drug_drugname_not_matchable_drugname_saltsplit id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_drugname_not_matchable_drugname_saltsplit ALTER COLUMN id SET DEFAULT nextval('fda.drug_drugname_not_matchable_drugname_saltsplit_id_seq'::regclass);


--
-- Name: drug_drugname_split id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_drugname_split ALTER COLUMN id SET DEFAULT nextval('fda.drug_drugname_split_id_seq'::regclass);


--
-- Name: drug_drugname_split_initial id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_drugname_split_initial ALTER COLUMN id SET DEFAULT nextval('fda.drug_drugname_split_initial_id_seq'::regclass);


--
-- Name: drug_drugname_split_without_bad_endings id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_drugname_split_without_bad_endings ALTER COLUMN id SET DEFAULT nextval('fda.drug_drugname_split_without_bad_endings_id_seq'::regclass);


--
-- Name: indi id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.indi ALTER COLUMN id SET DEFAULT nextval('fda.indi_id_seq'::regclass);


--
-- Name: invalid id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.invalid ALTER COLUMN id SET DEFAULT nextval('fda.invalid_id_seq'::regclass);


--
-- Name: outc id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.outc ALTER COLUMN id SET DEFAULT nextval('fda.outc_id_seq'::regclass);


--
-- Name: reac id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.reac ALTER COLUMN id SET DEFAULT nextval('fda.reac_id_seq'::regclass);


--
-- Name: rpsr id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.rpsr ALTER COLUMN id SET DEFAULT nextval('fda.rpsr_id_seq'::regclass);


--
-- Name: ther id; Type: DEFAULT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.ther ALTER COLUMN id SET DEFAULT nextval('fda.ther_id_seq'::regclass);


--
-- Name: imported_files id; Type: DEFAULT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.imported_files ALTER COLUMN id SET DEFAULT nextval('public.imported_files_id_seq'::regclass);


--
-- Name: notconsidered id; Type: DEFAULT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.notconsidered ALTER COLUMN id SET DEFAULT nextval('public.notconsidered_id_seq'::regclass);


--
-- Name: notconsidered_count id; Type: DEFAULT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.notconsidered_count ALTER COLUMN id SET DEFAULT nextval('public.notconsidered_count_id_seq'::regclass);


--
-- Name: clean_import clean_import_pkey; Type: CONSTRAINT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.clean_import
    ADD CONSTRAINT clean_import_pkey PRIMARY KEY (id);


--
-- Name: csv_raw csv_raw_pkey; Type: CONSTRAINT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.csv_raw
    ADD CONSTRAINT csv_raw_pkey PRIMARY KEY (id);


--
-- Name: csv_splittet csv_splittet_pkey; Type: CONSTRAINT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.csv_splittet
    ADD CONSTRAINT csv_splittet_pkey PRIMARY KEY (id);


--
-- Name: drug_characteristic drug_characteristic_pkey; Type: CONSTRAINT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.drug_characteristic
    ADD CONSTRAINT drug_characteristic_pkey PRIMARY KEY (name, type);


--
-- Name: mixture_invalid mixture_invalid_pkey; Type: CONSTRAINT; Schema: drugbank; Owner: pharm_su
--

ALTER TABLE ONLY drugbank.mixture_invalid
    ADD CONSTRAINT mixture_invalid_pkey PRIMARY KEY (id);


--
-- Name: matching_activeingredsplit matching_activeingredsplit_pkey; Type: CONSTRAINT; Schema: drugs_at_fda; Owner: pharm_su
--

ALTER TABLE ONLY drugs_at_fda.matching_activeingredsplit
    ADD CONSTRAINT matching_activeingredsplit_pkey PRIMARY KEY (id);


--
-- Name: matching_characteristicsplit matching_characteristicsplit_pkey; Type: CONSTRAINT; Schema: drugs_at_fda; Owner: pharm_su
--

ALTER TABLE ONLY drugs_at_fda.matching_characteristicsplit
    ADD CONSTRAINT matching_characteristicsplit_pkey PRIMARY KEY (activeingredpartid, drugname, characteristic);


--
-- Name: not_matchable_split not_matchable_split_pkey; Type: CONSTRAINT; Schema: drugs_at_fda; Owner: pharm_su
--

ALTER TABLE ONLY drugs_at_fda.not_matchable_split
    ADD CONSTRAINT not_matchable_split_pkey PRIMARY KEY (drugname, salt);


--
-- Name: product product_pkey; Type: CONSTRAINT; Schema: drugs_at_fda; Owner: pharm_su
--

ALTER TABLE ONLY drugs_at_fda.product
    ADD CONSTRAINT product_pkey PRIMARY KEY (id);


--
-- Name: demo_age demo_age_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.demo_age
    ADD CONSTRAINT demo_age_pkey PRIMARY KEY (id);


--
-- Name: demo demo_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.demo
    ADD CONSTRAINT demo_pkey PRIMARY KEY (id);


--
-- Name: drug_application drug_application_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_application
    ADD CONSTRAINT drug_application_pkey PRIMARY KEY (id);


--
-- Name: drug_dose drug_dose_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_dose
    ADD CONSTRAINT drug_dose_pkey PRIMARY KEY (id);


--
-- Name: drug_drugname_not_matchable_drugname_saltsplit drug_drugname_not_matchable_drugname_saltsplit_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_drugname_not_matchable_drugname_saltsplit
    ADD CONSTRAINT drug_drugname_not_matchable_drugname_saltsplit_pkey PRIMARY KEY (id);


--
-- Name: drug_drugname_split_initial drug_drugname_split_initial_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_drugname_split_initial
    ADD CONSTRAINT drug_drugname_split_initial_pkey PRIMARY KEY (id);


--
-- Name: drug_drugname_split drug_drugname_split_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_drugname_split
    ADD CONSTRAINT drug_drugname_split_pkey PRIMARY KEY (id);


--
-- Name: drug_drugname_split_without_bad_endings drug_drugname_split_without_bad_endings_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_drugname_split_without_bad_endings
    ADD CONSTRAINT drug_drugname_split_without_bad_endings_pkey PRIMARY KEY (id);


--
-- Name: drug drug_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug
    ADD CONSTRAINT drug_pkey PRIMARY KEY (id);


--
-- Name: indi indi_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.indi
    ADD CONSTRAINT indi_pkey PRIMARY KEY (id);


--
-- Name: invalid invalid_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.invalid
    ADD CONSTRAINT invalid_pkey PRIMARY KEY (id);


--
-- Name: outc outc_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.outc
    ADD CONSTRAINT outc_pkey PRIMARY KEY (id);


--
-- Name: reac reac_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.reac
    ADD CONSTRAINT reac_pkey PRIMARY KEY (id);


--
-- Name: rpsr rpsr_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.rpsr
    ADD CONSTRAINT rpsr_pkey PRIMARY KEY (id);


--
-- Name: ther_duration ther_duration_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.ther_duration
    ADD CONSTRAINT ther_duration_pkey PRIMARY KEY (id);


--
-- Name: ther ther_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.ther
    ADD CONSTRAINT ther_pkey PRIMARY KEY (id);


--
-- Name: ther_t_id ther_t_id_pkey; Type: CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.ther_t_id
    ADD CONSTRAINT ther_t_id_pkey PRIMARY KEY (id);


--
-- Name: atc_code atc_code_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.atc_code
    ADD CONSTRAINT atc_code_pkey PRIMARY KEY (code, drugname);


--
-- Name: codes codes_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.codes
    ADD CONSTRAINT codes_pkey PRIMARY KEY (name, code);


--
-- Name: component component_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.component
    ADD CONSTRAINT component_pkey PRIMARY KEY (name, drugname);


--
-- Name: countries countrys_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.countries
    ADD CONSTRAINT countrys_pkey PRIMARY KEY (country);


--
-- Name: d_appl d_appl_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.d_appl
    ADD CONSTRAINT d_appl_pkey PRIMARY KEY (drug_seq, drugname);


--
-- Name: drugusage drugusage_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.drugusage
    ADD CONSTRAINT drugusage_pkey PRIMARY KEY (drug_seq);


--
-- Name: drugusviewdrug drugusview_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_admin
--

ALTER TABLE ONLY public.drugusviewdrug
    ADD CONSTRAINT drugusview_pkey PRIMARY KEY (drug_seq, drugname);


--
-- Name: hlt hlt_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.hlt
    ADD CONSTRAINT hlt_pkey PRIMARY KEY (hlt_code);


--
-- Name: hlt_pt hlt_pt_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.hlt_pt
    ADD CONSTRAINT hlt_pt_pkey PRIMARY KEY (hlt_code, pt_code);


--
-- Name: imported_files imported_files_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.imported_files
    ADD CONSTRAINT imported_files_pkey PRIMARY KEY (id);


--
-- Name: incomplete incomplete_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.incomplete
    ADD CONSTRAINT incomplete_pkey PRIMARY KEY (name);


--
-- Name: indication indication_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.indication
    ADD CONSTRAINT indication_pkey PRIMARY KEY (indi_pt);


--
-- Name: llt llt_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.llt
    ADD CONSTRAINT llt_pkey PRIMARY KEY (llt_code);


--
-- Name: misspellings misspellings_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.misspellings
    ADD CONSTRAINT misspellings_pkey PRIMARY KEY (misspelling, type);


--
-- Name: mrisr mrisr_pk; Type: CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.mrisr
    ADD CONSTRAINT mrisr_pk PRIMARY KEY (isr);


--
-- Name: notconsidered_count notconsidered_count_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.notconsidered_count
    ADD CONSTRAINT notconsidered_count_pkey PRIMARY KEY (id);


--
-- Name: notconsidered notconsidered_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.notconsidered
    ADD CONSTRAINT notconsidered_pkey PRIMARY KEY (id);


--
-- Name: outcome outcome_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.outcome
    ADD CONSTRAINT outcome_pkey PRIMARY KEY (outc_cod);


--
-- Name: pharmaproduct pharmaproduct_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.pharmaproduct
    ADD CONSTRAINT pharmaproduct_pkey PRIMARY KEY (brandname);


--
-- Name: producer producer_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.producer
    ADD CONSTRAINT producer_pkey PRIMARY KEY (name);


--
-- Name: product product_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.product
    ADD CONSTRAINT product_pkey PRIMARY KEY (brandname, drugname);


--
-- Name: pt pt_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.pt
    ADD CONSTRAINT pt_pkey PRIMARY KEY (pt_name);


--
-- Name: rep_event rep_event_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_event
    ADD CONSTRAINT rep_event_pkey PRIMARY KEY (isr, pt);


--
-- Name: rep_hlt rep_hlt_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_hlt
    ADD CONSTRAINT rep_hlt_pkey PRIMARY KEY (hlt_code, isr);


--
-- Name: rep_outcome rep_outcome_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_outcome
    ADD CONSTRAINT rep_outcome_pkey PRIMARY KEY (outc_cod, isr);


--
-- Name: rep_pt rep_pt_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_pt
    ADD CONSTRAINT rep_pt_pkey PRIMARY KEY (pt, isr);


--
-- Name: rep_rpsr rep_rpsr_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_rpsr
    ADD CONSTRAINT rep_rpsr_pkey PRIMARY KEY (rpsr_cod, isr);


--
-- Name: rep_smq_b rep_smq_b_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_smq_b
    ADD CONSTRAINT rep_smq_b_pkey PRIMARY KEY (smq_code, isr);


--
-- Name: rep_smq_n rep_smq_n_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_smq_n
    ADD CONSTRAINT rep_smq_n_pkey PRIMARY KEY (smq_code, isr);


--
-- Name: report report_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.report
    ADD CONSTRAINT report_pkey PRIMARY KEY (isr);


--
-- Name: rpsr rpsr_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rpsr
    ADD CONSTRAINT rpsr_pkey PRIMARY KEY (rpsr_cod);


--
-- Name: smq_content smq_content_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.smq_content
    ADD CONSTRAINT smq_content_pkey PRIMARY KEY (smq_code, term_code);


--
-- Name: smq_content_temp smq_content_temp_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.smq_content_temp
    ADD CONSTRAINT smq_content_temp_pkey PRIMARY KEY (smq_code, term_code);


--
-- Name: smq smq_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.smq
    ADD CONSTRAINT smq_pkey PRIMARY KEY (smq_code);


--
-- Name: substructures substructures_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.substructures
    ADD CONSTRAINT substructures_pkey PRIMARY KEY (name);


--
-- Name: synonyms synonyms_drugname_name_key; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.synonyms
    ADD CONSTRAINT synonyms_drugname_name_key UNIQUE (drugname, name);


--
-- Name: synonyms synonyms_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.synonyms
    ADD CONSTRAINT synonyms_pkey PRIMARY KEY (name);


--
-- Name: therapy therapy_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.therapy
    ADD CONSTRAINT therapy_pkey PRIMARY KEY (drug_seq, t_id);


--
-- Name: unclassified unclassified_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.unclassified
    ADD CONSTRAINT unclassified_pkey PRIMARY KEY (name, brandname);


--
-- Name: used used_pkey; Type: CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.used
    ADD CONSTRAINT used_pkey PRIMARY KEY (drug_seq, indi_pt);


--
-- Name: age_cod_demo__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX age_cod_demo__hash_idx ON fda.demo USING hash (age_cod);


--
-- Name: age_demo__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX age_demo__hash_idx ON fda.demo USING hash (age);


--
-- Name: drug_seq__drug_drugname_split__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drug_seq__drug_drugname_split__hash_idx ON fda.drug_drugname_split USING hash (drug_seq);


--
-- Name: drug_seq__drug_drugname_split_initial__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drug_seq__drug_drugname_split_initial__hash_idx ON fda.drug_drugname_split_initial USING hash (drug_seq);


--
-- Name: drug_seq__drug_drugname_split_without_bad_endings__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drug_seq__drug_drugname_split_without_bad_endings__hash_idx ON fda.drug_drugname_split_without_bad_endings USING hash (drug_seq);


--
-- Name: drug_seq_drug__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drug_seq_drug__hash_idx ON fda.drug USING hash (drug_seq);


--
-- Name: drug_seq_drug_application; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drug_seq_drug_application ON fda.drug_application USING btree (drug_seq);


--
-- Name: drug_seq_drug_drugname_not_matchable__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drug_seq_drug_drugname_not_matchable__hash_idx ON fda.drug_drugname_not_matchable USING hash (drug_seq);


--
-- Name: drug_seq_ther__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drug_seq_ther__hash_idx ON fda.ther USING hash (drug_seq);


--
-- Name: drugname_part__drug_drugname_split__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drugname_part__drug_drugname_split__hash_idx ON fda.drug_drugname_split USING hash (drugname_part);


--
-- Name: drugname_part_drug_application_new__btree_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX drugname_part_drug_application_new__btree_idx ON fda.drug_application USING btree (drugname_part);


--
-- Name: isr_demo__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_demo__hash_idx ON fda.demo USING hash (isr);


--
-- Name: isr_drug__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_drug__hash_idx ON fda.drug USING hash (isr);


--
-- Name: isr_indi__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_indi__hash_idx ON fda.indi USING hash (isr);


--
-- Name: isr_invalid__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_invalid__hash_idx ON fda.invalid USING hash (file);


--
-- Name: isr_invalid_isrs__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_invalid_isrs__hash_idx ON fda.invalid_isrs USING hash (isr);


--
-- Name: isr_outc__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_outc__hash_idx ON fda.outc USING hash (isr);


--
-- Name: isr_outc_cod__outc__btree_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_outc_cod__outc__btree_idx ON fda.outc USING btree (isr, outc_cod);


--
-- Name: isr_reac__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_reac__hash_idx ON fda.reac USING hash (isr);


--
-- Name: isr_rpsr__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_rpsr__hash_idx ON fda.rpsr USING hash (isr);


--
-- Name: isr_ther__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX isr_ther__hash_idx ON fda.ther USING hash (isr);


--
-- Name: line_number_invalid__hash_idx; Type: INDEX; Schema: fda; Owner: pharm_su
--

CREATE INDEX line_number_invalid__hash_idx ON fda.invalid USING hash (line_number);


--
-- Name: d_appl_lower_drugname; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX d_appl_lower_drugname ON public.d_appl USING hash (lower((drugname)::text));


--
-- Name: d_appl_lower_pk; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX d_appl_lower_pk ON public.d_appl USING btree (drug_seq, lower((drugname)::text));


--
-- Name: drugusage__isr; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX drugusage__isr ON public.drugusage USING btree (isr);


--
-- Name: drugusage_drugseq_as_text; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX drugusage_drugseq_as_text ON public.drugusage USING btree (((drug_seq)::text));


--
-- Name: event_pt_lower; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX event_pt_lower ON public.event USING btree (lower((pt)::text));


--
-- Name: hlt_name; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX hlt_name ON public.hlt USING hash (hlt_name);


--
-- Name: indication_indipt_lower; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX indication_indipt_lower ON public.indication USING btree (lower((indi_pt)::text));


--
-- Name: isr_i; Type: INDEX; Schema: public; Owner: postgres
--

CREATE INDEX isr_i ON public.drugusview USING btree (isr);


--
-- Name: llt_pt; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX llt_pt ON public.llt USING hash (pt_code);


--
-- Name: pharmaproduct_unique_brandname; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE UNIQUE INDEX pharmaproduct_unique_brandname ON public.pharmaproduct USING btree (lower((brandname)::text));


--
-- Name: product__lower_drugname; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX product__lower_drugname ON public.product USING btree (lower((drugname)::text));


--
-- Name: product_lower_pk; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX product_lower_pk ON public.product USING btree (lower((brandname)::text), lower((drugname)::text));


--
-- Name: pt_pt_code; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX pt_pt_code ON public.pt USING hash (pt_code);


--
-- Name: rep_event__isr; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX rep_event__isr ON public.rep_event USING hash (isr);


--
-- Name: rep_hlt__isr; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX rep_hlt__isr ON public.rep_hlt USING hash (isr);


--
-- Name: rep_pt__isr; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX rep_pt__isr ON public.rep_pt USING hash (isr);


--
-- Name: rep_smq_b_isr; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX rep_smq_b_isr ON public.rep_smq_b USING hash (isr);


--
-- Name: rep_smq_n_isr; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX rep_smq_n_isr ON public.rep_smq_n USING hash (isr);


--
-- Name: report_isr_as_text; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX report_isr_as_text ON public.report USING btree (((isr)::text));


--
-- Name: smq_name; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE INDEX smq_name ON public.smq USING hash (smq_name);


--
-- Name: unclassified_unique; Type: INDEX; Schema: public; Owner: pharm_su
--

CREATE UNIQUE INDEX unclassified_unique ON public.unclassified USING btree (lower((name)::text), lower((brandname)::text));


--
-- Name: drugusage drugusage_d_appl_pharmaproduct; Type: TRIGGER; Schema: public; Owner: pharm_su
--

CREATE CONSTRAINT TRIGGER drugusage_d_appl_pharmaproduct AFTER DELETE OR UPDATE ON public.drugusage DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE public.check_integrity_drugusage_d_appl_pharmaproduct();

ALTER TABLE public.drugusage DISABLE TRIGGER drugusage_d_appl_pharmaproduct;


--
-- Name: drugusage trigger_on_DRUGUSAGE; Type: TRIGGER; Schema: public; Owner: pharm_su
--

CREATE CONSTRAINT TRIGGER "trigger_on_DRUGUSAGE" AFTER DELETE OR UPDATE ON public.drugusage DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE public.check_integrity_report();


--
-- Name: report trigger_on_REPORT; Type: TRIGGER; Schema: public; Owner: pharm_su
--

CREATE CONSTRAINT TRIGGER "trigger_on_REPORT" AFTER INSERT OR UPDATE ON public.report DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE public.check_integrity_report();

ALTER TABLE public.report DISABLE TRIGGER "trigger_on_REPORT";


--
-- Name: d_appl trigger_on_d_appl; Type: TRIGGER; Schema: public; Owner: pharm_su
--

CREATE CONSTRAINT TRIGGER trigger_on_d_appl AFTER INSERT OR UPDATE ON public.d_appl DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE public.check_integrity_d_appl_drugusage_pharmaproduct();

ALTER TABLE public.d_appl DISABLE TRIGGER trigger_on_d_appl;


--
-- Name: demo_age demo_age_id_fkey; Type: FK CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.demo_age
    ADD CONSTRAINT demo_age_id_fkey FOREIGN KEY (id) REFERENCES fda.demo(id) ON DELETE CASCADE;


--
-- Name: drug_dose drug_dose_id_fkey; Type: FK CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.drug_dose
    ADD CONSTRAINT drug_dose_id_fkey FOREIGN KEY (id) REFERENCES fda.drug(id) ON DELETE CASCADE;


--
-- Name: ther_duration ther_duration_id_fkey; Type: FK CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.ther_duration
    ADD CONSTRAINT ther_duration_id_fkey FOREIGN KEY (id) REFERENCES fda.ther(id) ON DELETE CASCADE;


--
-- Name: ther_t_id ther_t_id_id_fkey; Type: FK CONSTRAINT; Schema: fda; Owner: pharm_su
--

ALTER TABLE ONLY fda.ther_t_id
    ADD CONSTRAINT ther_t_id_id_fkey FOREIGN KEY (id) REFERENCES fda.ther(id) ON DELETE CASCADE;


--
-- Name: component component_name_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.component
    ADD CONSTRAINT component_name_fkey FOREIGN KEY (name) REFERENCES public.substructures(name);


--
-- Name: d_appl d_appl_drug_seq_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.d_appl
    ADD CONSTRAINT d_appl_drug_seq_fkey FOREIGN KEY (drug_seq) REFERENCES public.drugusage(drug_seq);


--
-- Name: drugusage drugusage_brandname_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.drugusage
    ADD CONSTRAINT drugusage_brandname_fkey FOREIGN KEY (brandname) REFERENCES public.pharmaproduct(brandname);


--
-- Name: drugusage drugusage_fk; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.drugusage
    ADD CONSTRAINT drugusage_fk FOREIGN KEY (isr) REFERENCES public.report(isr) DEFERRABLE INITIALLY DEFERRED;


--
-- Name: drugusview drugusview_isr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--

ALTER TABLE ONLY public.drugusview
    ADD CONSTRAINT drugusview_isr_fkey FOREIGN KEY (isr) REFERENCES public.report(isr);


--
-- Name: pharmaproduct pharmaproduct_p_name_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.pharmaproduct
    ADD CONSTRAINT pharmaproduct_p_name_fkey FOREIGN KEY (producer_name) REFERENCES public.producer(name);


--
-- Name: product product_brandname_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.product
    ADD CONSTRAINT product_brandname_fkey FOREIGN KEY (brandname) REFERENCES public.pharmaproduct(brandname);


--
-- Name: rep_event rep_event_isr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_event
    ADD CONSTRAINT rep_event_isr_fkey FOREIGN KEY (isr) REFERENCES public.report(isr);


--
-- Name: rep_hlt rep_hlt_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_hlt
    ADD CONSTRAINT rep_hlt_code_fkey FOREIGN KEY (hlt_code) REFERENCES public.hlt(hlt_code);


--
-- Name: rep_hlt rep_hlt_isr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_hlt
    ADD CONSTRAINT rep_hlt_isr_fkey FOREIGN KEY (isr) REFERENCES public.report(isr);


--
-- Name: rep_outcome rep_outcome_isr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_outcome
    ADD CONSTRAINT rep_outcome_isr_fkey FOREIGN KEY (isr) REFERENCES public.report(isr);


--
-- Name: rep_outcome rep_outcome_outc_cod_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_outcome
    ADD CONSTRAINT rep_outcome_outc_cod_fkey FOREIGN KEY (outc_cod) REFERENCES public.outcome(outc_cod);


--
-- Name: rep_pt rep_pt_isr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_pt
    ADD CONSTRAINT rep_pt_isr_fkey FOREIGN KEY (isr) REFERENCES public.report(isr);


--
-- Name: rep_pt rep_pt_pt_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_pt
    ADD CONSTRAINT rep_pt_pt_fkey FOREIGN KEY (pt_code) REFERENCES public.llt(llt_code);


--
-- Name: rep_rpsr rep_rpsr_isr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_rpsr
    ADD CONSTRAINT rep_rpsr_isr_fkey FOREIGN KEY (isr) REFERENCES public.report(isr);


--
-- Name: rep_rpsr rep_rpsr_rpsr_cod_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_rpsr
    ADD CONSTRAINT rep_rpsr_rpsr_cod_fkey FOREIGN KEY (rpsr_cod) REFERENCES public.rpsr(rpsr_cod);


--
-- Name: rep_smq_b rep_smq_b_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_smq_b
    ADD CONSTRAINT rep_smq_b_code_fkey FOREIGN KEY (smq_code) REFERENCES public.smq(smq_code);


--
-- Name: rep_smq_b rep_smq_b_isr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_smq_b
    ADD CONSTRAINT rep_smq_b_isr_fkey FOREIGN KEY (isr) REFERENCES public.report(isr);


--
-- Name: rep_smq_n rep_smq_n_code_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_smq_n
    ADD CONSTRAINT rep_smq_n_code_fkey FOREIGN KEY (smq_code) REFERENCES public.smq(smq_code);


--
-- Name: rep_smq_n rep_smq_n_isr_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.rep_smq_n
    ADD CONSTRAINT rep_smq_n_isr_fkey FOREIGN KEY (isr) REFERENCES public.report(isr);


--
-- Name: therapy therapy_drug_seq_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.therapy
    ADD CONSTRAINT therapy_drug_seq_fkey FOREIGN KEY (drug_seq) REFERENCES public.drugusage(drug_seq);


--
-- Name: unclassified unclassified_brandname_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.unclassified
    ADD CONSTRAINT unclassified_brandname_fkey FOREIGN KEY (brandname) REFERENCES public.pharmaproduct(brandname);


--
-- Name: unclassified unclassified_name_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.unclassified
    ADD CONSTRAINT unclassified_name_fkey FOREIGN KEY (name) REFERENCES public.incomplete(name);


--
-- Name: used used_drug_seq_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.used
    ADD CONSTRAINT used_drug_seq_fkey FOREIGN KEY (drug_seq) REFERENCES public.drugusage(drug_seq);


--
-- Name: used used_indi_pt_fkey; Type: FK CONSTRAINT; Schema: public; Owner: pharm_su
--

ALTER TABLE ONLY public.used
    ADD CONSTRAINT used_indi_pt_fkey FOREIGN KEY (indi_pt) REFERENCES public.indication(indi_pt);


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

GRANT ALL ON SCHEMA public TO pharm_su;


--
-- Name: TABLE atc_code; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.atc_code TO pharm_data;


--
-- Name: TABLE codes; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.codes TO pharm_data;


--
-- Name: TABLE component; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.component TO pharm_data;


--
-- Name: TABLE countries; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.countries TO pharm_data;


--
-- Name: TABLE d_appl; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.d_appl TO pharm_data;


--
-- Name: TABLE drug; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.drug TO pharm_data;


--
-- Name: TABLE drugusage; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.drugusage TO pharm_data;


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

GRANT SELECT ON TABLE public.drugusview TO pharm_data;


--
-- Name: TABLE event; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.event TO pharm_data;


--
-- Name: TABLE hlt; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.hlt TO pharm_data;


--
-- Name: TABLE hlt_pt; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.hlt_pt TO pharm_data;


--
-- Name: TABLE hlt_pt_temp; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.hlt_pt_temp TO pharm_data;


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

GRANT SELECT ON TABLE public.hlt_temp TO pharm_data;


--
-- Name: TABLE imported_files; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.imported_files TO pharm_data;


--
-- Name: TABLE incomplete; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.incomplete TO pharm_data;


--
-- Name: TABLE indication; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.indication TO pharm_data;


--
-- Name: TABLE llt; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.llt TO pharm_data;


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

GRANT SELECT ON TABLE public.llt_temp TO pharm_data;


--
-- Name: TABLE misspellings; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.misspellings TO pharm_data;


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

GRANT SELECT ON TABLE public.mrisr TO pharm_data;


--
-- Name: TABLE notconsidered; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.notconsidered TO pharm_data;


--
-- Name: TABLE notconsidered_count; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.notconsidered_count TO pharm_data;


--
-- Name: TABLE outcome; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.outcome TO pharm_data;


--
-- Name: TABLE pharmaproduct; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.pharmaproduct TO pharm_data;


--
-- Name: TABLE producer; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.producer TO pharm_data;


--
-- Name: TABLE product; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.product TO pharm_data;


--
-- Name: TABLE pt; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.pt TO pharm_data;


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

GRANT SELECT ON TABLE public.pt_temp TO pharm_data;


--
-- Name: TABLE rep_event; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.rep_event TO pharm_data;


--
-- Name: TABLE rep_hlt; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.rep_hlt TO pharm_data;


--
-- Name: TABLE rep_outcome; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.rep_outcome TO pharm_data;


--
-- Name: TABLE rep_pt; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.rep_pt TO pharm_data;


--
-- Name: TABLE rep_rpsr; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.rep_rpsr TO pharm_data;


--
-- Name: TABLE rep_smq_b; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.rep_smq_b TO pharm_data;


--
-- Name: TABLE rep_smq_n; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.rep_smq_n TO pharm_data;


--
-- Name: TABLE report; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.report TO pharm_data;


--
-- Name: TABLE rpsr; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.rpsr TO pharm_data;


--
-- Name: TABLE smq; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.smq TO pharm_data;


--
-- Name: TABLE smq_content; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.smq_content TO pharm_data;


--
-- Name: TABLE smq_content_temp; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.smq_content_temp TO pharm_data;


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

GRANT SELECT ON TABLE public.smq_temp TO pharm_data;


--
-- Name: TABLE substructures; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.substructures TO pharm_data;


--
-- Name: TABLE synonyms; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.synonyms TO pharm_data;


--
-- Name: TABLE therapy; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.therapy TO pharm_data;


--
-- Name: TABLE unclassified; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.unclassified TO pharm_data;


--
-- Name: TABLE used; Type: ACL; Schema: public; Owner: pharm_su
--

GRANT SELECT ON TABLE public.used TO pharm_data;


--
-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: postgres
--

ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES  FROM postgres;
ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT SELECT ON TABLES  TO pharm_data;


--
--

