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

SET search_path = public, pg_catalog;

--
-- Name: establishmentmeans_dwc; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE establishmentmeans_dwc AS ENUM (
    'cultivated',
    'wild',
    'native',
    'exotic',
    'invasive',
    'escaped from captivity'
);


--
-- Name: TYPE establishmentmeans_dwc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TYPE establishmentmeans_dwc IS 'See http://rs.tdwg.org/dwc/terms/#establishmentMeans';


--
-- Name: growthform; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE growthform AS ENUM (
    'tree',
    'shrub',
    'liana',
    'vine',
    'herb',
    'hemiepiphyte',
    'epiphyte',
    'grass',
    'forb',
    'moss',
    'lichen',
    'fungus',
    'floating aquatic',
    'submerged aquatic'
);


--
-- Name: occurrencestatus_dwc; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE occurrencestatus_dwc AS ENUM (
    'present',
    'absent',
    'common',
    'irregular',
    'rare',
    'doubtful'
);


--
-- Name: placerank; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE placerank AS ENUM (
    'continent',
    'country',
    'stateProvince',
    'county',
    'municipality',
    'village',
    'site',
    'territory',
    'region',
    'waterBody',
    'island',
    'islandGroup'
);


--
-- Name: TYPE placerank; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TYPE placerank IS 'county = parish, canton
municipality = city
';


--
-- Name: role; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE role AS ENUM (
    'collector',
    'identifier',
    'computer',
    'contributor'
);


--
-- Name: taxonclass; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE taxonclass AS ENUM (
    'tree',
    'shrub',
    'liana',
    'vine',
    'herb',
    'hemiepiphyte',
    'epiphyte',
    'grass',
    'forb',
    'moss',
    'lichen',
    'fungus',
    'floating aquatic',
    'submerged aquatic',
    'cultivated',
    'wild',
    'native',
    'exotic',
    'invasive',
    'escaped from captivity',
    'dominant',
    'vascular',
    'woody'
);


--
-- Name: TYPE taxonclass; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TYPE taxonclass IS '= growthform + establishmentmeans_dwc + some others';


--
-- Name: taxonrank; Type: TYPE; Schema: public; Owner: -
--

CREATE TYPE taxonrank AS ENUM (
    'binomial',
    'kingdom',
    'subkingdom',
    'superdivision',
    'division',
    'class',
    'subclass',
    'order',
    'suborder',
    'family',
    'subfamily',
    'tribe',
    'subtribe',
    'genus',
    'subgenus',
    'section',
    'species aggregate',
    'species',
    'subspecies',
    'authority',
    'variety',
    'cultivar/forma'
);


--
-- Name: aggregateoccurrence_plantobs_count_1(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION aggregateoccurrence_plantobs_count_1() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    IF new.plantobservation_id IS NOT NULL THEN
        new.count = 1;
    END IF;
    RETURN new;
END;
$$;


--
-- Name: namedplace_update_ancestors(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION namedplace_update_ancestors() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    -- Delete existing ancestors
    DELETE FROM namedplace_ancestor WHERE namedplace_id = new.namedplace_id;
    
    IF new.parent_id IS NOT NULL THEN
        -- Copy parent's ancestors to this node's ancestors
        INSERT
        INTO namedplace_ancestor
        (namedplace_id, ancestor_id)
        SELECT
            new.namedplace_id, ancestor_id
        FROM namedplace_ancestor
        WHERE namedplace_id = new.parent_id
        ;
    END IF;
    
    -- Add "ancestor" for this node
    /* This is useful for queries, because you don't have to separately test if
    the leaf node is the one you're looking for, in addition to that leaf node's
    ancestors. */
    INSERT
    INTO namedplace_ancestor
    (namedplace_id, ancestor_id)
    VALUES (new.namedplace_id, new.namedplace_id)
    ;
    
    -- Tell immediate children to update their ancestors lists, which will
    -- recursively tell all descendants
    UPDATE namedplace
    SET namedplace_id = namedplace_id -- need at least one SET statement
    WHERE parent_id = new.namedplace_id -- the namedplace_id passed as param
    ;
    
    /* Note: We don't need an ON DELETE trigger to update the descendants'
    ancestors when a node is deleted, because the namedplace.namedplace_parent_id
    foreign key is set to ON DELETE CASCADE, which just removes all the
    descendants anyway. */
    
    RETURN new;
END;
$$;


--
-- Name: plantname_update_ancestors(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION plantname_update_ancestors() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    -- Delete existing ancestors
    DELETE FROM plantname_ancestor WHERE plantname_id = new.plantname_id;
    
    IF new.parent_id IS NOT NULL THEN
        -- Copy parent's ancestors to this node's ancestors
        INSERT
        INTO plantname_ancestor
        (plantname_id, ancestor_id)
        SELECT
            new.plantname_id, ancestor_id
        FROM plantname_ancestor
        WHERE plantname_id = new.parent_id
        ;
    END IF;
    
    -- Add "ancestor" for this node
    /* This is useful for queries, because you don't have to separately test if
    the leaf node is the one you're looking for, in addition to that leaf node's
    ancestors. */
    INSERT
    INTO plantname_ancestor
    (plantname_id, ancestor_id)
    VALUES (new.plantname_id, new.plantname_id)
    ;
    
    -- Tell immediate children to update their ancestors lists, which will
    -- recursively tell all descendants
    UPDATE plantname
    SET plantname_id = plantname_id -- need at least one SET statement
    WHERE parent_id = new.plantname_id -- the plantname_id passed as param
    ;
    
    /* Note: We don't need an ON DELETE trigger to update the descendants'
    ancestors when a node is deleted, because the plantname.plantname_parent_id
    foreign key is set to ON DELETE CASCADE, which just removes all the
    descendants anyway. */
    
    RETURN new;
END;
$$;


--
-- Name: taxondetermination_taxonoccurrence_id_fkey(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION taxondetermination_taxonoccurrence_id_fkey() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
    IF (
        SELECT count(*) = 0
        FROM taxonoccurrence
        WHERE taxonoccurrence_id = new.taxonoccurrence_id
    ) THEN
        RAISE EXCEPTION 'duplicate key value violates unique constraint '
            '"taxondetermination_taxonoccurrence_id_fkey()"'
            USING ERRCODE = 'unique_violation';
    END IF;
    
    RETURN new;
END;
$$;


--
-- Name: concat(text); Type: AGGREGATE; Schema: public; Owner: -
--

CREATE AGGREGATE concat(text) (
    SFUNC = textcat,
    STYPE = text,
    INITCOND = ''
);


SET default_tablespace = '';

SET default_with_oids = true;

--
-- Name: address; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE address (
    address_id integer NOT NULL,
    party_id integer NOT NULL,
    organization_id integer,
    orgposition text,
    email text,
    deliverypoint text,
    city text,
    administrativearea text,
    postalcode text,
    country text,
    currentflag boolean,
    addressstartdate timestamp with time zone
);


--
-- Name: address_address_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: address_address_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE address_address_id_seq OWNED BY address.address_id;


--
-- Name: aggregateoccurrence; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE aggregateoccurrence (
    aggregateoccurrence_id integer NOT NULL,
    taxonoccurrence_id integer NOT NULL,
    cover double precision,
    basalarea double precision,
    biomass double precision,
    inferencearea double precision,
    count integer,
    sourceaccessioncode text,
    plantobservation_id integer,
    stratum_id integer,
    coverindex_id integer,
    occurrencestatus_dwc occurrencestatus_dwc DEFAULT 'present'::occurrencestatus_dwc NOT NULL,
    method_id integer,
    linecover double precision,
    accessioncode text,
    CONSTRAINT aggregateoccurrence_plantobservation_count_1 CHECK (((plantobservation_id IS NULL) OR (NOT (count IS DISTINCT FROM 1))))
);


--
-- Name: TABLE aggregateoccurrence; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE aggregateoccurrence IS 'VegBank''s taxonimportance table.';


--
-- Name: COLUMN aggregateoccurrence.occurrencestatus_dwc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN aggregateoccurrence.occurrencestatus_dwc IS 'The extent to which the taxon is present. See <http://code.google.com/p/darwincore/wiki/Occurrence#occurrenceStatus>.';


--
-- Name: COLUMN aggregateoccurrence.linecover; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN aggregateoccurrence.linecover IS 'The distance in m along which this occurrence intercepts a line subplot.';


--
-- Name: aggregateoccurrence_aggregateoccurrence_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: aggregateoccurrence_aggregateoccurrence_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE aggregateoccurrence_aggregateoccurrence_id_seq OWNED BY aggregateoccurrence.aggregateoccurrence_id;


--
-- Name: classcontributor; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE classcontributor (
    classcontributor_id integer NOT NULL,
    commclass_id integer NOT NULL,
    party_id integer NOT NULL,
    role role
);


--
-- Name: classcontributor_classcontributor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: classcontributor_classcontributor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE classcontributor_classcontributor_id_seq OWNED BY classcontributor.classcontributor_id;


--
-- Name: commclass; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE commclass (
    commclass_id integer NOT NULL,
    locationevent_id integer NOT NULL,
    inspection boolean,
    tableanalysis boolean,
    multivariateanalysis boolean,
    classpublication_id integer,
    classnotes text,
    commname text,
    commcode text,
    commframework text,
    commlevel text,
    classstartdate timestamp with time zone,
    classstopdate timestamp with time zone,
    expertsystem text,
    accessioncode text
);


--
-- Name: commclass_commclass_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: commclass_commclass_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE commclass_commclass_id_seq OWNED BY commclass.commclass_id;


--
-- Name: commconcept; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE commconcept (
    commconcept_id integer NOT NULL,
    commname_id integer NOT NULL,
    reference_id integer,
    commdescription text,
    d_obscount integer,
    commname text,
    d_currentaccepted boolean,
    accessioncode text
);


--
-- Name: commconcept_commconcept_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: commconcept_commconcept_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE commconcept_commconcept_id_seq OWNED BY commconcept.commconcept_id;


--
-- Name: commcorrelation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE commcorrelation (
    commcorrelation_id integer NOT NULL,
    commstatus_id integer NOT NULL,
    commconcept_id integer NOT NULL,
    commconvergence text NOT NULL,
    correlationstart timestamp with time zone NOT NULL,
    correlationstop timestamp with time zone
);


--
-- Name: commcorrelation_commcorrelation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: commcorrelation_commcorrelation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE commcorrelation_commcorrelation_id_seq OWNED BY commcorrelation.commcorrelation_id;


--
-- Name: commdetermination; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE commdetermination (
    commdetermination_id integer NOT NULL,
    commclass_id integer NOT NULL,
    commconcept_id integer,
    commcode text,
    commname text,
    classfit text,
    classconfidence text,
    commauthority_id integer,
    notes text,
    type boolean,
    nomenclaturaltype boolean
);


--
-- Name: commdetermination_commdetermination_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: commdetermination_commdetermination_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE commdetermination_commdetermination_id_seq OWNED BY commdetermination.commdetermination_id;


--
-- Name: commlineage; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE commlineage (
    commlineage_id integer NOT NULL,
    parentcommstatus_id integer NOT NULL,
    childcommstatus_id integer NOT NULL
);


--
-- Name: commlineage_commlineage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: commlineage_commlineage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE commlineage_commlineage_id_seq OWNED BY commlineage.commlineage_id;


--
-- Name: commname; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE commname (
    commname_id integer NOT NULL,
    commname text NOT NULL,
    reference_id integer,
    dateentered timestamp with time zone DEFAULT now()
);


--
-- Name: commname_commname_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: commname_commname_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE commname_commname_id_seq OWNED BY commname.commname_id;


--
-- Name: commstatus; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE commstatus (
    commstatus_id integer NOT NULL,
    commconcept_id integer NOT NULL,
    reference_id integer,
    commconceptstatus text NOT NULL,
    commparent_id integer,
    commlevel text,
    commpartycomments text,
    party_id integer NOT NULL,
    startdate timestamp with time zone NOT NULL,
    stopdate timestamp with time zone,
    accessioncode text
);


--
-- Name: commstatus_commstatus_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: commstatus_commstatus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE commstatus_commstatus_id_seq OWNED BY commstatus.commstatus_id;


--
-- Name: commusage; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE commusage (
    commusage_id integer NOT NULL,
    commname_id integer NOT NULL,
    commname text,
    commconcept_id integer,
    commnamestatus text,
    classsystem text,
    party_id integer,
    commstatus_id integer,
    usagestart timestamp with time zone,
    usagestop timestamp with time zone
);


--
-- Name: commusage_commusage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: commusage_commusage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE commusage_commusage_id_seq OWNED BY commusage.commusage_id;


--
-- Name: coverindex; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE coverindex (
    coverindex_id integer NOT NULL,
    covermethod_id integer NOT NULL,
    covercode text NOT NULL,
    upperlimit double precision,
    lowerlimit double precision,
    coverpercent double precision NOT NULL,
    indexdescription text
);


--
-- Name: coverindex_coverindex_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: coverindex_coverindex_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE coverindex_coverindex_id_seq OWNED BY coverindex.coverindex_id;


--
-- Name: covermethod; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE covermethod (
    covermethod_id integer NOT NULL,
    reference_id integer,
    covertype text NOT NULL,
    coverestimationmethod text,
    accessioncode text
);


--
-- Name: covermethod_covermethod_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: covermethod_covermethod_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE covermethod_covermethod_id_seq OWNED BY covermethod.covermethod_id;


--
-- Name: dba_preassignacccode_dba_requestnumber_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: definedvalue; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE definedvalue (
    definedvalue_id integer NOT NULL,
    userdefined_id integer NOT NULL,
    tablerecord_id integer NOT NULL,
    definedvalue text
);


--
-- Name: definedvalue_definedvalue_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: definedvalue_definedvalue_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE definedvalue_definedvalue_id_seq OWNED BY definedvalue.definedvalue_id;


--
-- Name: disturbanceobs; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE disturbanceobs (
    disturbanceobs_id integer NOT NULL,
    locationevent_id integer NOT NULL,
    disturbancetype text NOT NULL,
    disturbanceintensity text,
    disturbanceage double precision,
    disturbanceextent double precision,
    disturbancecomment text
);


--
-- Name: disturbanceobs_disturbanceobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: disturbanceobs_disturbanceobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE disturbanceobs_disturbanceobs_id_seq OWNED BY disturbanceobs.disturbanceobs_id;


--
-- Name: graphic; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE graphic (
    graphic_id integer NOT NULL,
    locationevent_id integer NOT NULL,
    graphicname text,
    graphiclocation text,
    graphicdescription text,
    graphictype text,
    graphicdata oid,
    graphicdate timestamp with time zone,
    accessioncode text
);


--
-- Name: graphic_graphic_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: graphic_graphic_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE graphic_graphic_id_seq OWNED BY graphic.graphic_id;


--
-- Name: location; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE location (
    location_id integer NOT NULL,
    parent_id integer,
    datasource_id integer,
    sourceaccessioncode text,
    centerlatitude double precision,
    centerlongitude double precision,
    locationaccuracy double precision,
    confidentialitystatus integer DEFAULT 0 NOT NULL,
    confidentialityreason text,
    publiclatitude double precision,
    publiclongitude double precision,
    sublocationxposition double precision,
    sublocationyposition double precision,
    authore text,
    authorn text,
    authorzone text,
    authordatum text,
    authorlocation text,
    locationnarrative text,
    azimuth double precision,
    shape text,
    area double precision,
    standsize text,
    placementmethod text,
    permanence boolean,
    layoutnarrative text,
    elevation double precision,
    elevationaccuracy double precision,
    elevationrange double precision,
    slopeaspect double precision,
    minslopeaspect double precision,
    maxslopeaspect double precision,
    slopegradient double precision,
    minslopegradient double precision,
    maxslopegradient double precision,
    topoposition text,
    landform text,
    surficialdeposits text,
    rocktype text,
    stateprovince text,
    country text,
    submitter_surname text,
    submitter_givenname text,
    submitter_email text,
    notespublic boolean,
    notesmgt boolean,
    revisions boolean,
    dateentered timestamp with time zone DEFAULT now(),
    locationrationalenarrative text,
    accessioncode text
);


--
-- Name: TABLE location; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE location IS 'VegBank''s plot table.';


--
-- Name: location_location_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: location_location_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE location_location_id_seq OWNED BY location.location_id;


--
-- Name: locationdetermination; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE locationdetermination (
    locationdetermination_id integer NOT NULL,
    location_id integer NOT NULL,
    latitude double precision,
    longitude double precision,
    footprintgeometry_dwc text,
    coordsaccuracy double precision,
    namedplace_id integer,
    identifier_id integer,
    determinationdate timestamp with time zone,
    isoriginal boolean DEFAULT false NOT NULL,
    iscurrent boolean DEFAULT false NOT NULL,
    calculated boolean
);


--
-- Name: TABLE locationdetermination; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE locationdetermination IS 'VegBank''s place table.';


--
-- Name: COLUMN locationdetermination.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN locationdetermination.footprintgeometry_dwc IS 'DwC''s footprintWKT field. "A Well-Known Text (WKT) representation of the shape (footprint, geometry) that defines the Location" (http://rs.tdwg.org/dwc/terms/#footprintWKT).';


--
-- Name: COLUMN locationdetermination.coordsaccuracy; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN locationdetermination.coordsaccuracy IS 'Accuracy of latitude/longitude or footprint geometry, in meters. This should generally be at least 1 m, which is the accuracy of the best GPSes.';


--
-- Name: locationdetermination_locationdetermination_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: locationdetermination_locationdetermination_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE locationdetermination_locationdetermination_id_seq OWNED BY locationdetermination.locationdetermination_id;


--
-- Name: locationevent; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE locationevent (
    locationevent_id integer NOT NULL,
    parent_id integer,
    datasource_id integer,
    location_id integer,
    project_id integer,
    authorlocationcode text,
    sourceaccessioncode text,
    previous_id integer,
    dateaccuracy text,
    method_id integer,
    temperature double precision,
    precipitation double precision,
    autotaxoncover boolean,
    originaldata text,
    effortlevel text,
    floristicquality text,
    bryophytequality text,
    lichenquality text,
    locationeventnarrative text,
    landscapenarrative text,
    homogeneity text,
    phenologicaspect text,
    representativeness text,
    standmaturity text,
    successionalstatus text,
    basalarea double precision,
    hydrologicregime text,
    soilmoistureregime text,
    soildrainage text,
    watersalinity text,
    waterdepth double precision,
    shoredistance double precision,
    soildepth double precision,
    organicdepth double precision,
    soiltaxon_id integer,
    soiltaxonsrc text,
    percentbedrock double precision,
    percentrockgravel double precision,
    percentwood double precision,
    percentlitter double precision,
    percentbaresoil double precision,
    percentwater double precision,
    percentother double precision,
    nameother text,
    treeht double precision,
    shrubht double precision,
    fieldht double precision,
    nonvascularht double precision,
    submergedht double precision,
    treecover double precision,
    shrubcover double precision,
    fieldcover double precision,
    nonvascularcover double precision,
    floatingcover double precision,
    submergedcover double precision,
    dominantstratum text,
    growthform1type text,
    growthform2type text,
    growthform3type text,
    growthform1cover double precision,
    growthform2cover double precision,
    growthform3cover double precision,
    totalcover double precision,
    notespublic boolean,
    notesmgt boolean,
    revisions boolean,
    obsstartdate timestamp with time zone,
    obsenddate timestamp with time zone,
    dateentered timestamp with time zone DEFAULT now(),
    toptaxon1name text,
    toptaxon2name text,
    toptaxon3name text,
    toptaxon4name text,
    toptaxon5name text,
    numberoftaxa integer,
    accessioncode text
);


--
-- Name: TABLE locationevent; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE locationevent IS 'VegBank''s observation table.';


--
-- Name: locationevent_locationevent_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: locationevent_locationevent_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE locationevent_locationevent_id_seq OWNED BY locationevent.locationevent_id;


--
-- Name: locationeventcontributor; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE locationeventcontributor (
    locationeventcontributor_id integer NOT NULL,
    locationevent_id integer NOT NULL,
    party_id integer NOT NULL,
    role role NOT NULL,
    contributiondate timestamp with time zone
);


--
-- Name: locationeventcontributor_locationeventcontributor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: locationeventcontributor_locationeventcontributor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE locationeventcontributor_locationeventcontributor_id_seq OWNED BY locationeventcontributor.locationeventcontributor_id;


--
-- Name: locationeventsynonym; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE locationeventsynonym (
    locationeventsynonym_id integer NOT NULL,
    synonymlocationevent_id integer NOT NULL,
    primarylocationevent_id integer NOT NULL,
    party_id integer NOT NULL,
    role role NOT NULL,
    synonymcomment text,
    classstartdate timestamp with time zone DEFAULT now() NOT NULL,
    classstopdate timestamp with time zone,
    accessioncode text
);


--
-- Name: locationeventsynonym_locationeventsynonym_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: locationeventsynonym_locationeventsynonym_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE locationeventsynonym_locationeventsynonym_id_seq OWNED BY locationeventsynonym.locationeventsynonym_id;


--
-- Name: method; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE method (
    method_id integer NOT NULL,
    reference_id integer,
    name text NOT NULL,
    description text,
    diameterheight double precision,
    mindiameter double precision,
    maxdiameter double precision,
    minheight double precision,
    maxheight double precision,
    observationtype text,
    observationmeasure text,
    covermethod_id integer,
    samplingfactor double precision DEFAULT 1 NOT NULL,
    coverbasis text,
    stemsamplemethod text,
    shape text,
    length double precision,
    width double precision,
    radius double precision,
    area double precision,
    samplearea double precision,
    subplotspacing double precision,
    subplotmethod_id integer,
    pointsperline integer,
    accessioncode text
);


--
-- Name: TABLE method; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE method IS 'A method for sampling and aggregating plants. Replaces VegBank''s stratummethod and stratumtype tables.

Important: *All* length- or area-related measurements throughout VegBIEN must be converted to SI base units, e.g. cm -> m, ha -> m^2.**';


--
-- Name: COLUMN method.reference_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.reference_id IS 'Use the reference table (e.g. reference.url) to store a link to the original plain text description.';


--
-- Name: COLUMN method.name; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.name IS 'A short name for the set of methods used. Although there is no existing standard, many names are widely used, and could be useful for finding plots with similar methodology.';


--
-- Name: COLUMN method.description; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.description IS 'Additional metadata helpful for understanding how the data were collected during the observation event.';


--
-- Name: COLUMN method.diameterheight; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.diameterheight IS 'The height in m at which the diameter is measured. e.g. 1.37 m for breast height (DBH).';


--
-- Name: COLUMN method.mindiameter; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.mindiameter IS 'Lower diameter limit in m for inclusion of a tree.';


--
-- Name: COLUMN method.maxdiameter; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.maxdiameter IS 'Upper diameter limit in m for inclusion of a tree.';


--
-- Name: COLUMN method.minheight; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.minheight IS 'Lower height limit in m for inclusion of a tree.';


--
-- Name: COLUMN method.maxheight; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.maxheight IS 'Upper height limit in m for inclusion of a tree.';


--
-- Name: COLUMN method.observationtype; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.observationtype IS 'values: aggregate, individual, both';


--
-- Name: COLUMN method.observationmeasure; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.observationmeasure IS 'e.g. count, cover, presence, points-intercepted, distance-intercepted';


--
-- Name: COLUMN method.samplingfactor; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.samplingfactor IS 'Here, we could explicitly say that we are sampling a particular area by a different size representative sample area. Simply divide the number of plants connected to this record by this value to get the extrapolated (or interpolated) number of plants in the area in question. This explicitly notes a subsample or supersample.';


--
-- Name: COLUMN method.coverbasis; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.coverbasis IS 'Were cover values for the total taxon list collected from one contiguous area or dispersed subplots?

entire: Cover based on observation of an entire plot consisting of a single contiguous area of land. subplot-contiguous: Cover based on observation of a single contiguous area of land of less spatial extent than the entire plot.

subplot-regular: Cover based on observation of multiple subplots arranged in a regular pattern within the overall plot.

subplot-random: Cover based on observation of multiple randomly dispersed subplots within the overall plot.

subplot-haphazard: Cover based on observation of multiple subplots haphazardly arranged within the overall plot.

line-intercept: Cover based on length of line touching each species present.

point-intercept: Cover based on number of points for each species present.
';


--
-- Name: COLUMN method.stemsamplemethod; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.stemsamplemethod IS 'The method used to obtain basal area or tree stem data (e.g., full census, point quarter, random pairs, Bitterlich, other).

e.g.:
Full census
Point quarter
Random pairs
Bitterlich
Other
Subsample census';


--
-- Name: COLUMN method.shape; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.shape IS 'e.g. square, rectangle, circle, line, point, other';


--
-- Name: COLUMN method.length; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.length IS 'Units: m';


--
-- Name: COLUMN method.width; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.width IS 'Units: m';


--
-- Name: COLUMN method.radius; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.radius IS 'Units: m';


--
-- Name: COLUMN method.area; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.area IS 'Units: m^2';


--
-- Name: COLUMN method.samplearea; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.samplearea IS 'The total surface area used for cover estimates and for which a complete species list is provided. If subplots were used, this would be the total area of the subplots without interstitial space.

Units: m^2';


--
-- Name: COLUMN method.subplotspacing; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.subplotspacing IS 'Spacing in m between adjacent subplots, lines (line-intercept data), or points (point-intercept data).';


--
-- Name: COLUMN method.subplotmethod_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.subplotmethod_id IS 'Method to use for each subplot/line/point, which will specify subplot size, line length, etc.';


--
-- Name: COLUMN method.pointsperline; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN method.pointsperline IS 'The number of points sampled on each line subplot for point-intercept data.';


--
-- Name: method_method_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: method_method_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE method_method_id_seq OWNED BY method.method_id;


SET default_with_oids = false;

--
-- Name: methodtaxonclass; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE methodtaxonclass (
    methodtaxonclass_id integer NOT NULL,
    method_id integer NOT NULL,
    plantconcept_id integer,
    included boolean NOT NULL,
    submethod_id integer,
    taxonclass taxonclass,
    CONSTRAINT methodtaxonclass_key_required CHECK (((plantconcept_id IS NOT NULL) OR (taxonclass IS NOT NULL)))
);


--
-- Name: COLUMN methodtaxonclass.included; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN methodtaxonclass.included IS 'Whether the method includes or excludes this taxon class.';


--
-- Name: COLUMN methodtaxonclass.submethod_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN methodtaxonclass.submethod_id IS 'The submethod used to sample just this taxon class, distinct from the main method.';


--
-- Name: methodtaxonclass_methodtaxonclass_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: methodtaxonclass_methodtaxonclass_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE methodtaxonclass_methodtaxonclass_id_seq OWNED BY methodtaxonclass.methodtaxonclass_id;


SET default_with_oids = true;

--
-- Name: namedplace; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE namedplace (
    namedplace_id integer NOT NULL,
    parent_id integer,
    rank placerank NOT NULL,
    placename text NOT NULL,
    placecode text,
    placedescription text,
    accessioncode text
);


SET default_with_oids = false;

--
-- Name: namedplace_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE namedplace_ancestor (
    namedplace_id integer NOT NULL,
    ancestor_id integer NOT NULL
);


--
-- Name: namedplace_namedplace_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: namedplace_namedplace_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE namedplace_namedplace_id_seq OWNED BY namedplace.namedplace_id;


SET default_with_oids = true;

--
-- Name: namedplacecorrelation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE namedplacecorrelation (
    namedplacecorrelation_id integer NOT NULL,
    parentplace_id integer NOT NULL,
    childplace_id integer NOT NULL,
    placeconvergence text NOT NULL
);


--
-- Name: namedplacecorrelation_namedplacecorrelation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: namedplacecorrelation_namedplacecorrelation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE namedplacecorrelation_namedplacecorrelation_id_seq OWNED BY namedplacecorrelation.namedplacecorrelation_id;


--
-- Name: note; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE note (
    note_id integer NOT NULL,
    notelink_id integer NOT NULL,
    party_id integer NOT NULL,
    role role NOT NULL,
    notetype text NOT NULL,
    notetext text NOT NULL,
    notedate timestamp with time zone,
    accessioncode text
);


--
-- Name: note_note_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: note_note_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE note_note_id_seq OWNED BY note.note_id;


--
-- Name: notelink; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE notelink (
    notelink_id integer NOT NULL,
    tablename text NOT NULL,
    attributename text,
    tablerecord integer NOT NULL
);


--
-- Name: notelink_notelink_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: notelink_notelink_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE notelink_notelink_id_seq OWNED BY notelink.notelink_id;


--
-- Name: party; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE party (
    party_id integer NOT NULL,
    salutation text,
    givenname text,
    middlename text,
    surname text,
    organizationname text,
    currentname_id integer,
    contactinstructions text,
    email text,
    partytype text,
    partypublic boolean DEFAULT true,
    d_obscount integer,
    accessioncode text
);


--
-- Name: party_party_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: party_party_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE party_party_id_seq OWNED BY party.party_id;


--
-- Name: partymember; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE partymember (
    partymember_id integer NOT NULL,
    parentparty_id integer NOT NULL,
    childparty_id integer NOT NULL,
    role role,
    memberstart timestamp with time zone DEFAULT now() NOT NULL,
    memberstop timestamp with time zone
);


--
-- Name: partymember_partymember_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: partymember_partymember_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE partymember_partymember_id_seq OWNED BY partymember.partymember_id;


SET default_with_oids = false;

--
-- Name: plant; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plant (
    plant_id integer NOT NULL
);


--
-- Name: TABLE plant; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE plant IS 'A physical, tagged plant.';


--
-- Name: plant_plant_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plant_plant_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plant_plant_id_seq OWNED BY plant.plant_id;


SET default_with_oids = true;

--
-- Name: plantconcept; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantconcept (
    plantconcept_id integer NOT NULL,
    plantname_id integer NOT NULL,
    plantcode text,
    plantdescription text,
    accessioncode text
);


--
-- Name: plantconcept_plantconcept_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plantconcept_plantconcept_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plantconcept_plantconcept_id_seq OWNED BY plantconcept.plantconcept_id;


--
-- Name: plantcorrelation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantcorrelation (
    plantcorrelation_id integer NOT NULL,
    plantstatus_id integer NOT NULL,
    plantconcept_id integer NOT NULL,
    plantconvergence text NOT NULL,
    correlationstart timestamp with time zone NOT NULL,
    correlationstop timestamp with time zone
);


--
-- Name: plantcorrelation_plantcorrelation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plantcorrelation_plantcorrelation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plantcorrelation_plantcorrelation_id_seq OWNED BY plantcorrelation.plantcorrelation_id;


--
-- Name: plantlineage; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantlineage (
    plantlineage_id integer NOT NULL,
    childplantstatus_id integer NOT NULL,
    parentplantstatus_id integer NOT NULL
);


--
-- Name: plantlineage_plantlineage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plantlineage_plantlineage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plantlineage_plantlineage_id_seq OWNED BY plantlineage.plantlineage_id;


--
-- Name: plantname; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantname (
    plantname_id integer NOT NULL,
    parent_id integer,
    scope_id integer,
    rank taxonrank NOT NULL,
    plantname text NOT NULL,
    accessioncode text
);


SET default_with_oids = false;

--
-- Name: plantname_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantname_ancestor (
    plantname_id integer NOT NULL,
    ancestor_id integer NOT NULL
);


--
-- Name: plantname_plantname_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plantname_plantname_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plantname_plantname_id_seq OWNED BY plantname.plantname_id;


--
-- Name: plantnamescope; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantnamescope (
    plantnamescope_id integer NOT NULL,
    locationevent_id integer,
    project_id integer,
    namedplace_id integer
);


--
-- Name: plantnamescope_plantnamescope_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plantnamescope_plantnamescope_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plantnamescope_plantnamescope_id_seq OWNED BY plantnamescope.plantnamescope_id;


SET default_with_oids = true;

--
-- Name: plantobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantobservation (
    plantobservation_id integer NOT NULL,
    overallheight double precision,
    overallheightaccuracy double precision,
    authorplantcode text,
    stemcount integer,
    sourceaccessioncode text,
    plant_id integer,
    accessioncode text
);


--
-- Name: TABLE plantobservation; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE plantobservation IS 'VegBank''s stemcount table.';


--
-- Name: plantobservation_plantobservation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plantobservation_plantobservation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plantobservation_plantobservation_id_seq OWNED BY plantobservation.plantobservation_id;


--
-- Name: plantstatus; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantstatus (
    plantstatus_id integer NOT NULL,
    plantconcept_id integer NOT NULL,
    party_id integer,
    plantconceptstatus text DEFAULT 'undetermined'::text NOT NULL,
    reference_id integer,
    plantpartycomments text,
    startdate timestamp with time zone,
    stopdate timestamp with time zone,
    accessioncode text
);


--
-- Name: plantstatus_plantstatus_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plantstatus_plantstatus_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plantstatus_plantstatus_id_seq OWNED BY plantstatus.plantstatus_id;


--
-- Name: plantusage; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE plantusage (
    plantusage_id integer NOT NULL,
    plantname_id integer NOT NULL,
    plantconcept_id integer,
    plantnamestatus text,
    plantname text,
    classsystem text,
    acceptedsynonym text,
    party_id integer,
    plantstatus_id integer,
    usagestart timestamp with time zone,
    usagestop timestamp with time zone
);


--
-- Name: plantusage_plantusage_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: plantusage_plantusage_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE plantusage_plantusage_id_seq OWNED BY plantusage.plantusage_id;


--
-- Name: project; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE project (
    project_id integer NOT NULL,
    projectname text NOT NULL,
    projectdescription text,
    startdate timestamp with time zone,
    stopdate timestamp with time zone,
    d_obscount integer,
    d_lastlocationaddeddate timestamp with time zone,
    datasource_id integer,
    accessioncode text
);


--
-- Name: project_project_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: project_project_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE project_project_id_seq OWNED BY project.project_id;


--
-- Name: projectcontributor; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE projectcontributor (
    projectcontributor_id integer NOT NULL,
    project_id integer NOT NULL,
    party_id integer NOT NULL,
    role role,
    surname text,
    cheatrole text
);


--
-- Name: projectcontributor_projectcontributor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: projectcontributor_projectcontributor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE projectcontributor_projectcontributor_id_seq OWNED BY projectcontributor.projectcontributor_id;


--
-- Name: reference; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE reference (
    reference_id integer NOT NULL,
    shortname text,
    fulltext text,
    referencetype text,
    title text,
    titlesuperior text,
    referencejournal_id integer,
    volume text,
    issue text,
    pagerange text,
    totalpages integer,
    publisher text,
    publicationplace text,
    isbn text,
    edition text,
    numberofvolumes integer,
    chapternumber integer,
    reportnumber integer,
    communicationtype text,
    degree text,
    url text,
    doi text,
    additionalinfo text,
    pubdate timestamp with time zone,
    accessdate timestamp with time zone,
    conferencedate timestamp with time zone,
    accessioncode text
);


--
-- Name: reference_reference_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: reference_reference_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE reference_reference_id_seq OWNED BY reference.reference_id;


--
-- Name: referencealtident; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE referencealtident (
    referencealtident_id integer NOT NULL,
    reference_id integer NOT NULL,
    system text,
    identifier text NOT NULL
);


--
-- Name: referencealtident_referencealtident_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: referencealtident_referencealtident_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE referencealtident_referencealtident_id_seq OWNED BY referencealtident.referencealtident_id;


--
-- Name: referencecontributor; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE referencecontributor (
    referencecontributor_id integer NOT NULL,
    reference_id integer NOT NULL,
    referenceparty_id integer NOT NULL,
    roletype text,
    "position" integer
);


--
-- Name: referencecontributor_referencecontributor_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: referencecontributor_referencecontributor_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE referencecontributor_referencecontributor_id_seq OWNED BY referencecontributor.referencecontributor_id;


--
-- Name: referencejournal; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE referencejournal (
    referencejournal_id integer NOT NULL,
    journal text NOT NULL,
    issn text,
    abbreviation text,
    accessioncode text
);


--
-- Name: referencejournal_referencejournal_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: referencejournal_referencejournal_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE referencejournal_referencejournal_id_seq OWNED BY referencejournal.referencejournal_id;


--
-- Name: referenceparty; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE referenceparty (
    referenceparty_id integer NOT NULL,
    type text,
    positionname text,
    salutation text,
    givenname text,
    surname text,
    suffix text,
    organizationname text,
    currentparty_id integer,
    accessioncode text
);


--
-- Name: referenceparty_referenceparty_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: referenceparty_referenceparty_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE referenceparty_referenceparty_id_seq OWNED BY referenceparty.referenceparty_id;


--
-- Name: revision; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE revision (
    revision_id integer NOT NULL,
    tablename text NOT NULL,
    tableattribute text NOT NULL,
    tablerecord integer NOT NULL,
    previousvaluetext text NOT NULL,
    previousvaluetype text NOT NULL,
    previousrevision_id integer,
    revisiondate timestamp with time zone NOT NULL
);


--
-- Name: revision_revision_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: revision_revision_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE revision_revision_id_seq OWNED BY revision.revision_id;


--
-- Name: soilobs; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE soilobs (
    soilobs_id integer NOT NULL,
    locationevent_id integer NOT NULL,
    horizon text DEFAULT 'unknown'::text NOT NULL,
    description text,
    depthtop double precision,
    depthbottom double precision,
    color text,
    texture text,
    organic double precision,
    sand double precision,
    silt double precision,
    clay double precision,
    coarse double precision,
    ph double precision,
    acidity double precision,
    basesaturation double precision,
    cationexchangecapacity double precision,
    conductivity double precision,
    carbon double precision,
    phosphorus double precision,
    potassium double precision,
    magnesium double precision,
    nitrogen double precision,
    calcium double precision,
    sodium double precision
);


--
-- Name: COLUMN soilobs.organic; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.organic IS 'fraction';


--
-- Name: COLUMN soilobs.sand; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.sand IS 'fraction';


--
-- Name: COLUMN soilobs.silt; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.silt IS 'fraction';


--
-- Name: COLUMN soilobs.clay; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.clay IS 'fraction';


--
-- Name: COLUMN soilobs.coarse; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.coarse IS 'fraction';


--
-- Name: COLUMN soilobs.acidity; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.acidity IS 'fraction';


--
-- Name: COLUMN soilobs.basesaturation; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.basesaturation IS 'fraction';


--
-- Name: COLUMN soilobs.carbon; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.carbon IS 'fraction';


--
-- Name: COLUMN soilobs.phosphorus; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.phosphorus IS 'fraction';


--
-- Name: COLUMN soilobs.potassium; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.potassium IS 'fraction';


--
-- Name: COLUMN soilobs.magnesium; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.magnesium IS 'fraction';


--
-- Name: COLUMN soilobs.nitrogen; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.nitrogen IS 'fraction';


--
-- Name: COLUMN soilobs.calcium; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.calcium IS 'fraction';


--
-- Name: COLUMN soilobs.sodium; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN soilobs.sodium IS 'fraction';


--
-- Name: soilobs_soilobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: soilobs_soilobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE soilobs_soilobs_id_seq OWNED BY soilobs.soilobs_id;


--
-- Name: soiltaxon; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE soiltaxon (
    soiltaxon_id integer NOT NULL,
    soilcode text,
    soilname text,
    soillevel integer,
    soilparent_id integer,
    soilframework text,
    accessioncode text
);


--
-- Name: soiltaxon_soiltaxon_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: soiltaxon_soiltaxon_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE soiltaxon_soiltaxon_id_seq OWNED BY soiltaxon.soiltaxon_id;


SET default_with_oids = false;

--
-- Name: specimen; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE specimen (
    specimen_id integer NOT NULL
);


--
-- Name: TABLE specimen; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE specimen IS 'A physical specimen collected from a plant. Used to link replicates of the same specimen together.';


--
-- Name: specimen_specimen_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: specimen_specimen_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE specimen_specimen_id_seq OWNED BY specimen.specimen_id;


--
-- Name: taxonoccurrence; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE taxonoccurrence (
    taxonoccurrence_id integer NOT NULL,
    locationevent_id integer,
    verbatimcollectorname text,
    growthform growthform,
    iscultivated boolean,
    cultivatedbasis text,
    isnative boolean,
    accessioncode text
);


--
-- Name: TABLE taxonoccurrence; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE taxonoccurrence IS 'VegBank''s taxonobservation table.';


--
-- Name: COLUMN taxonoccurrence.iscultivated; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN taxonoccurrence.iscultivated IS 'cultivated or wild';


--
-- Name: COLUMN taxonoccurrence.cultivatedbasis; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN taxonoccurrence.cultivatedbasis IS 'The reason why a taxonoccurrence was marked as cultivated (or not).';


--
-- Name: COLUMN taxonoccurrence.isnative; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN taxonoccurrence.isnative IS 'native or exotic';


--
-- Name: taxonoccurrence_taxonoccurrence_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: taxonoccurrence_taxonoccurrence_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE taxonoccurrence_taxonoccurrence_id_seq OWNED BY taxonoccurrence.taxonoccurrence_id;


SET default_with_oids = true;

--
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE specimenreplicate (
    datasource_id integer NOT NULL,
    collectioncode_dwc text,
    catalognumber_dwc text,
    collectiondate timestamp with time zone,
    institution_id integer,
    sourceaccessioncode text,
    collectionnumber text,
    specimen_id integer,
    description text
)
INHERITS (taxonoccurrence);


--
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE specimenreplicate IS 'A herbarium''s replicate of a specimen. Contains Darwin Core specimen data.';


--
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN specimenreplicate.collectioncode_dwc IS 'The code for the collection that the specimenreplicate is from.';


--
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN specimenreplicate.institution_id IS 'The the institution (such as a museum) that the specimenreplicate is from.';


--
-- Name: COLUMN specimenreplicate.collectionnumber; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN specimenreplicate.collectionnumber IS 'The number of the specimenreplicate within the collection.';


--
-- Name: stemobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE stemobservation (
    stemobservation_id integer NOT NULL,
    plantobservation_id integer NOT NULL,
    sourceaccessioncode text,
    authorstemcode text,
    xposition double precision,
    yposition double precision,
    diameterbreastheight double precision,
    basaldiameter double precision,
    diameteraccuracy double precision,
    height double precision,
    heightfirstbranch double precision,
    heightaccuracy double precision,
    health text,
    age double precision,
    accessioncode text
);


--
-- Name: TABLE stemobservation; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE stemobservation IS 'VegBank''s stemlocation table.';


--
-- Name: stemobservation_stemobservation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: stemobservation_stemobservation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE stemobservation_stemobservation_id_seq OWNED BY stemobservation.stemobservation_id;


SET default_with_oids = false;

--
-- Name: stemtag; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE stemtag (
    stemtag_id integer NOT NULL,
    stemobservation_id integer NOT NULL,
    tag text NOT NULL,
    iscurrent boolean DEFAULT true NOT NULL
);


--
-- Name: stemtag_stemtag_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: stemtag_stemtag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE stemtag_stemtag_id_seq OWNED BY stemtag.stemtag_id;


SET default_with_oids = true;

--
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE stratum (
    stratum_id integer NOT NULL,
    locationevent_id integer NOT NULL,
    stratumheight double precision,
    stratumbase double precision,
    stratumcover double precision,
    area double precision,
    method_id integer
);


--
-- Name: stratum_stratum_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: stratum_stratum_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE stratum_stratum_id_seq OWNED BY stratum.stratum_id;


--
-- Name: taxonalt; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE taxonalt (
    taxonalt_id integer NOT NULL,
    taxondetermination_id integer NOT NULL,
    plantconcept_id integer NOT NULL,
    taxonaltfit text,
    taxonaltconfidence text,
    taxonaltnotes text
);


--
-- Name: taxonalt_taxonalt_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: taxonalt_taxonalt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE taxonalt_taxonalt_id_seq OWNED BY taxonalt.taxonalt_id;


--
-- Name: taxondetermination; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE taxondetermination (
    taxondetermination_id integer NOT NULL,
    taxonoccurrence_id integer NOT NULL,
    plantconcept_id integer NOT NULL,
    party_id integer,
    role role NOT NULL,
    determinationtype text,
    reference_id integer,
    isoriginal boolean DEFAULT false NOT NULL,
    iscurrent boolean DEFAULT false NOT NULL,
    taxonfit text,
    taxonconfidence text,
    grouptype text,
    notes text,
    notespublic boolean,
    notesmgt boolean,
    revisions boolean,
    determinationdate timestamp with time zone,
    accessioncode text
);


--
-- Name: TABLE taxondetermination; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE taxondetermination IS 'VegBank''s taxoninterpretation table.';


--
-- Name: taxondetermination_taxondetermination_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: taxondetermination_taxondetermination_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE taxondetermination_taxondetermination_id_seq OWNED BY taxondetermination.taxondetermination_id;


--
-- Name: telephone; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE telephone (
    telephone_id integer NOT NULL,
    party_id integer NOT NULL,
    phonenumber text NOT NULL,
    phonetype text NOT NULL
);


--
-- Name: telephone_telephone_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: telephone_telephone_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE telephone_telephone_id_seq OWNED BY telephone.telephone_id;


SET default_with_oids = false;

--
-- Name: trait; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE trait (
    trait_id integer NOT NULL,
    stemobservation_id integer NOT NULL,
    type text NOT NULL,
    value text
);


--
-- Name: trait_trait_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: trait_trait_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE trait_trait_id_seq OWNED BY trait.trait_id;


SET default_with_oids = true;

--
-- Name: userdefined; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE userdefined (
    userdefined_id integer NOT NULL,
    userdefinedname text NOT NULL,
    userdefinedmetadata text,
    userdefinedcategory text,
    userdefinedtype text DEFAULT 'text'::text NOT NULL,
    tablename text NOT NULL,
    accessioncode text
);


--
-- Name: userdefined_userdefined_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: userdefined_userdefined_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE userdefined_userdefined_id_seq OWNED BY userdefined.userdefined_id;


SET default_with_oids = false;

--
-- Name: voucher; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE voucher (
    voucher_id integer NOT NULL,
    taxonoccurrence_id integer NOT NULL,
    specimenreplicate_id integer NOT NULL,
    accessioncode text
);


--
-- Name: voucher_voucher_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: voucher_voucher_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE voucher_voucher_id_seq OWNED BY voucher.voucher_id;


--
-- Name: address_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE address ALTER COLUMN address_id SET DEFAULT nextval('address_address_id_seq'::regclass);


--
-- Name: aggregateoccurrence_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE aggregateoccurrence ALTER COLUMN aggregateoccurrence_id SET DEFAULT nextval('aggregateoccurrence_aggregateoccurrence_id_seq'::regclass);


--
-- Name: classcontributor_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE classcontributor ALTER COLUMN classcontributor_id SET DEFAULT nextval('classcontributor_classcontributor_id_seq'::regclass);


--
-- Name: commclass_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE commclass ALTER COLUMN commclass_id SET DEFAULT nextval('commclass_commclass_id_seq'::regclass);


--
-- Name: commconcept_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE commconcept ALTER COLUMN commconcept_id SET DEFAULT nextval('commconcept_commconcept_id_seq'::regclass);


--
-- Name: commcorrelation_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE commcorrelation ALTER COLUMN commcorrelation_id SET DEFAULT nextval('commcorrelation_commcorrelation_id_seq'::regclass);


--
-- Name: commdetermination_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE commdetermination ALTER COLUMN commdetermination_id SET DEFAULT nextval('commdetermination_commdetermination_id_seq'::regclass);


--
-- Name: commlineage_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE commlineage ALTER COLUMN commlineage_id SET DEFAULT nextval('commlineage_commlineage_id_seq'::regclass);


--
-- Name: commname_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE commname ALTER COLUMN commname_id SET DEFAULT nextval('commname_commname_id_seq'::regclass);


--
-- Name: commstatus_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE commstatus ALTER COLUMN commstatus_id SET DEFAULT nextval('commstatus_commstatus_id_seq'::regclass);


--
-- Name: commusage_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE commusage ALTER COLUMN commusage_id SET DEFAULT nextval('commusage_commusage_id_seq'::regclass);


--
-- Name: coverindex_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE coverindex ALTER COLUMN coverindex_id SET DEFAULT nextval('coverindex_coverindex_id_seq'::regclass);


--
-- Name: covermethod_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE covermethod ALTER COLUMN covermethod_id SET DEFAULT nextval('covermethod_covermethod_id_seq'::regclass);


--
-- Name: definedvalue_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE definedvalue ALTER COLUMN definedvalue_id SET DEFAULT nextval('definedvalue_definedvalue_id_seq'::regclass);


--
-- Name: disturbanceobs_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE disturbanceobs ALTER COLUMN disturbanceobs_id SET DEFAULT nextval('disturbanceobs_disturbanceobs_id_seq'::regclass);


--
-- Name: graphic_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE graphic ALTER COLUMN graphic_id SET DEFAULT nextval('graphic_graphic_id_seq'::regclass);


--
-- Name: location_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE location ALTER COLUMN location_id SET DEFAULT nextval('location_location_id_seq'::regclass);


--
-- Name: locationdetermination_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE locationdetermination ALTER COLUMN locationdetermination_id SET DEFAULT nextval('locationdetermination_locationdetermination_id_seq'::regclass);


--
-- Name: locationevent_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE locationevent ALTER COLUMN locationevent_id SET DEFAULT nextval('locationevent_locationevent_id_seq'::regclass);


--
-- Name: locationeventcontributor_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE locationeventcontributor ALTER COLUMN locationeventcontributor_id SET DEFAULT nextval('locationeventcontributor_locationeventcontributor_id_seq'::regclass);


--
-- Name: locationeventsynonym_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE locationeventsynonym ALTER COLUMN locationeventsynonym_id SET DEFAULT nextval('locationeventsynonym_locationeventsynonym_id_seq'::regclass);


--
-- Name: method_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE method ALTER COLUMN method_id SET DEFAULT nextval('method_method_id_seq'::regclass);


--
-- Name: methodtaxonclass_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE methodtaxonclass ALTER COLUMN methodtaxonclass_id SET DEFAULT nextval('methodtaxonclass_methodtaxonclass_id_seq'::regclass);


--
-- Name: namedplace_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE namedplace ALTER COLUMN namedplace_id SET DEFAULT nextval('namedplace_namedplace_id_seq'::regclass);


--
-- Name: namedplacecorrelation_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE namedplacecorrelation ALTER COLUMN namedplacecorrelation_id SET DEFAULT nextval('namedplacecorrelation_namedplacecorrelation_id_seq'::regclass);


--
-- Name: note_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE note ALTER COLUMN note_id SET DEFAULT nextval('note_note_id_seq'::regclass);


--
-- Name: notelink_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE notelink ALTER COLUMN notelink_id SET DEFAULT nextval('notelink_notelink_id_seq'::regclass);


--
-- Name: party_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE party ALTER COLUMN party_id SET DEFAULT nextval('party_party_id_seq'::regclass);


--
-- Name: partymember_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE partymember ALTER COLUMN partymember_id SET DEFAULT nextval('partymember_partymember_id_seq'::regclass);


--
-- Name: plant_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plant ALTER COLUMN plant_id SET DEFAULT nextval('plant_plant_id_seq'::regclass);


--
-- Name: plantconcept_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plantconcept ALTER COLUMN plantconcept_id SET DEFAULT nextval('plantconcept_plantconcept_id_seq'::regclass);


--
-- Name: plantcorrelation_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plantcorrelation ALTER COLUMN plantcorrelation_id SET DEFAULT nextval('plantcorrelation_plantcorrelation_id_seq'::regclass);


--
-- Name: plantlineage_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plantlineage ALTER COLUMN plantlineage_id SET DEFAULT nextval('plantlineage_plantlineage_id_seq'::regclass);


--
-- Name: plantname_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plantname ALTER COLUMN plantname_id SET DEFAULT nextval('plantname_plantname_id_seq'::regclass);


--
-- Name: plantnamescope_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plantnamescope ALTER COLUMN plantnamescope_id SET DEFAULT nextval('plantnamescope_plantnamescope_id_seq'::regclass);


--
-- Name: plantobservation_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plantobservation ALTER COLUMN plantobservation_id SET DEFAULT nextval('plantobservation_plantobservation_id_seq'::regclass);


--
-- Name: plantstatus_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plantstatus ALTER COLUMN plantstatus_id SET DEFAULT nextval('plantstatus_plantstatus_id_seq'::regclass);


--
-- Name: plantusage_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE plantusage ALTER COLUMN plantusage_id SET DEFAULT nextval('plantusage_plantusage_id_seq'::regclass);


--
-- Name: project_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE project ALTER COLUMN project_id SET DEFAULT nextval('project_project_id_seq'::regclass);


--
-- Name: projectcontributor_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE projectcontributor ALTER COLUMN projectcontributor_id SET DEFAULT nextval('projectcontributor_projectcontributor_id_seq'::regclass);


--
-- Name: reference_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE reference ALTER COLUMN reference_id SET DEFAULT nextval('reference_reference_id_seq'::regclass);


--
-- Name: referencealtident_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE referencealtident ALTER COLUMN referencealtident_id SET DEFAULT nextval('referencealtident_referencealtident_id_seq'::regclass);


--
-- Name: referencecontributor_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE referencecontributor ALTER COLUMN referencecontributor_id SET DEFAULT nextval('referencecontributor_referencecontributor_id_seq'::regclass);


--
-- Name: referencejournal_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE referencejournal ALTER COLUMN referencejournal_id SET DEFAULT nextval('referencejournal_referencejournal_id_seq'::regclass);


--
-- Name: referenceparty_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE referenceparty ALTER COLUMN referenceparty_id SET DEFAULT nextval('referenceparty_referenceparty_id_seq'::regclass);


--
-- Name: revision_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE revision ALTER COLUMN revision_id SET DEFAULT nextval('revision_revision_id_seq'::regclass);


--
-- Name: soilobs_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE soilobs ALTER COLUMN soilobs_id SET DEFAULT nextval('soilobs_soilobs_id_seq'::regclass);


--
-- Name: soiltaxon_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE soiltaxon ALTER COLUMN soiltaxon_id SET DEFAULT nextval('soiltaxon_soiltaxon_id_seq'::regclass);


--
-- Name: specimen_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE specimen ALTER COLUMN specimen_id SET DEFAULT nextval('specimen_specimen_id_seq'::regclass);


--
-- Name: stemobservation_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE stemobservation ALTER COLUMN stemobservation_id SET DEFAULT nextval('stemobservation_stemobservation_id_seq'::regclass);


--
-- Name: stemtag_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE stemtag ALTER COLUMN stemtag_id SET DEFAULT nextval('stemtag_stemtag_id_seq'::regclass);


--
-- Name: stratum_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE stratum ALTER COLUMN stratum_id SET DEFAULT nextval('stratum_stratum_id_seq'::regclass);


--
-- Name: taxonalt_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE taxonalt ALTER COLUMN taxonalt_id SET DEFAULT nextval('taxonalt_taxonalt_id_seq'::regclass);


--
-- Name: taxondetermination_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE taxondetermination ALTER COLUMN taxondetermination_id SET DEFAULT nextval('taxondetermination_taxondetermination_id_seq'::regclass);


--
-- Name: taxonoccurrence_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE taxonoccurrence ALTER COLUMN taxonoccurrence_id SET DEFAULT nextval('taxonoccurrence_taxonoccurrence_id_seq'::regclass);


--
-- Name: telephone_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE telephone ALTER COLUMN telephone_id SET DEFAULT nextval('telephone_telephone_id_seq'::regclass);


--
-- Name: trait_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE trait ALTER COLUMN trait_id SET DEFAULT nextval('trait_trait_id_seq'::regclass);


--
-- Name: userdefined_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE userdefined ALTER COLUMN userdefined_id SET DEFAULT nextval('userdefined_userdefined_id_seq'::regclass);


--
-- Name: voucher_id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE voucher ALTER COLUMN voucher_id SET DEFAULT nextval('voucher_voucher_id_seq'::regclass);


--
-- Name: address_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY address
    ADD CONSTRAINT address_pkey PRIMARY KEY (address_id);


--
-- Name: aggregateoccurrence_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY aggregateoccurrence
    ADD CONSTRAINT aggregateoccurrence_pkey PRIMARY KEY (aggregateoccurrence_id);


--
-- Name: aggregateoccurrence_plantobservation_1_to_1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY aggregateoccurrence
    ADD CONSTRAINT aggregateoccurrence_plantobservation_1_to_1 UNIQUE (plantobservation_id);


--
-- Name: aggregateoccurrence_unique_accessioncode; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY aggregateoccurrence
    ADD CONSTRAINT aggregateoccurrence_unique_accessioncode UNIQUE (taxonoccurrence_id, sourceaccessioncode);


--
-- Name: classcontributor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY classcontributor
    ADD CONSTRAINT classcontributor_pkey PRIMARY KEY (classcontributor_id);


--
-- Name: commclass_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commclass
    ADD CONSTRAINT commclass_pkey PRIMARY KEY (commclass_id);


--
-- Name: commclass_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commclass
    ADD CONSTRAINT commclass_unique UNIQUE (locationevent_id, classnotes);


--
-- Name: commconcept_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commconcept
    ADD CONSTRAINT commconcept_pkey PRIMARY KEY (commconcept_id);


--
-- Name: commconcept_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commconcept
    ADD CONSTRAINT commconcept_unique UNIQUE (commname_id);


--
-- Name: commcorrelation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commcorrelation
    ADD CONSTRAINT commcorrelation_pkey PRIMARY KEY (commcorrelation_id);


--
-- Name: commdetermination_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commdetermination
    ADD CONSTRAINT commdetermination_pkey PRIMARY KEY (commdetermination_id);


--
-- Name: commdetermination_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commdetermination
    ADD CONSTRAINT commdetermination_unique UNIQUE (commclass_id, commconcept_id);


--
-- Name: commlineage_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commlineage
    ADD CONSTRAINT commlineage_pkey PRIMARY KEY (commlineage_id);


--
-- Name: commname_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commname
    ADD CONSTRAINT commname_pkey PRIMARY KEY (commname_id);


--
-- Name: commname_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commname
    ADD CONSTRAINT commname_unique UNIQUE (commname);


--
-- Name: commstatus_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commstatus
    ADD CONSTRAINT commstatus_pkey PRIMARY KEY (commstatus_id);


--
-- Name: commusage_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY commusage
    ADD CONSTRAINT commusage_pkey PRIMARY KEY (commusage_id);


--
-- Name: coverindex_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY coverindex
    ADD CONSTRAINT coverindex_pkey PRIMARY KEY (coverindex_id);


--
-- Name: covermethod_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY covermethod
    ADD CONSTRAINT covermethod_pkey PRIMARY KEY (covermethod_id);


--
-- Name: definedvalue_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY definedvalue
    ADD CONSTRAINT definedvalue_pkey PRIMARY KEY (definedvalue_id);


--
-- Name: definedvalue_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY definedvalue
    ADD CONSTRAINT definedvalue_unique UNIQUE (userdefined_id, tablerecord_id);


--
-- Name: disturbanceobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY disturbanceobs
    ADD CONSTRAINT disturbanceobs_pkey PRIMARY KEY (disturbanceobs_id);


--
-- Name: graphic_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY graphic
    ADD CONSTRAINT graphic_pkey PRIMARY KEY (graphic_id);


--
-- Name: location_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY location
    ADD CONSTRAINT location_pkey PRIMARY KEY (location_id);


--
-- Name: location_unique_sourceaccessioncode; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY location
    ADD CONSTRAINT location_unique_sourceaccessioncode UNIQUE (datasource_id, sourceaccessioncode);


--
-- Name: location_unique_subplot_coords; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY location
    ADD CONSTRAINT location_unique_subplot_coords UNIQUE (parent_id, sublocationxposition, sublocationyposition);


--
-- Name: locationdetermination_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY locationdetermination
    ADD CONSTRAINT locationdetermination_pkey PRIMARY KEY (locationdetermination_id);


--
-- Name: locationdetermination_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY locationdetermination
    ADD CONSTRAINT locationdetermination_unique UNIQUE (location_id, namedplace_id);


--
-- Name: locationevent_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_pkey PRIMARY KEY (locationevent_id);


--
-- Name: locationevent_unique_datasource_accessioncode; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_unique_datasource_accessioncode UNIQUE (datasource_id, sourceaccessioncode);


--
-- Name: locationevent_unique_parent_authorcode; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_unique_parent_authorcode UNIQUE (parent_id, authorlocationcode);


--
-- Name: locationevent_unique_parent_location; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_unique_parent_location UNIQUE (parent_id, location_id);


--
-- Name: locationeventcontributor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY locationeventcontributor
    ADD CONSTRAINT locationeventcontributor_pkey PRIMARY KEY (locationeventcontributor_id);


--
-- Name: locationeventsynonym_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY locationeventsynonym
    ADD CONSTRAINT locationeventsynonym_pkey PRIMARY KEY (locationeventsynonym_id);


--
-- Name: method_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY method
    ADD CONSTRAINT method_pkey PRIMARY KEY (method_id);


--
-- Name: methodtaxonclass_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY methodtaxonclass
    ADD CONSTRAINT methodtaxonclass_pkey PRIMARY KEY (methodtaxonclass_id);


--
-- Name: methodtaxonclass_unique_description; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY methodtaxonclass
    ADD CONSTRAINT methodtaxonclass_unique_description UNIQUE (method_id, taxonclass);


--
-- Name: methodtaxonclass_unique_plantconcept_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY methodtaxonclass
    ADD CONSTRAINT methodtaxonclass_unique_plantconcept_id UNIQUE (method_id, plantconcept_id);


--
-- Name: namedplace_ancestor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY namedplace_ancestor
    ADD CONSTRAINT namedplace_ancestor_pkey PRIMARY KEY (namedplace_id, ancestor_id);


--
-- Name: namedplace_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY namedplace
    ADD CONSTRAINT namedplace_pkey PRIMARY KEY (namedplace_id);


--
-- Name: namedplacecorrelation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY namedplacecorrelation
    ADD CONSTRAINT namedplacecorrelation_pkey PRIMARY KEY (namedplacecorrelation_id);


--
-- Name: note_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY note
    ADD CONSTRAINT note_pkey PRIMARY KEY (note_id);


--
-- Name: notelink_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY notelink
    ADD CONSTRAINT notelink_pkey PRIMARY KEY (notelink_id);


--
-- Name: party_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY party
    ADD CONSTRAINT party_pkey PRIMARY KEY (party_id);


--
-- Name: partymember_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY partymember
    ADD CONSTRAINT partymember_pkey PRIMARY KEY (partymember_id);


--
-- Name: plant_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plant
    ADD CONSTRAINT plant_pkey PRIMARY KEY (plant_id);


--
-- Name: plantconcept_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantconcept
    ADD CONSTRAINT plantconcept_pkey PRIMARY KEY (plantconcept_id);


--
-- Name: plantconcept_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantconcept
    ADD CONSTRAINT plantconcept_unique UNIQUE (plantname_id);


--
-- Name: plantcorrelation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantcorrelation
    ADD CONSTRAINT plantcorrelation_pkey PRIMARY KEY (plantcorrelation_id);


--
-- Name: plantlineage_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantlineage
    ADD CONSTRAINT plantlineage_pkey PRIMARY KEY (plantlineage_id);


--
-- Name: plantname_ancestor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantname_ancestor
    ADD CONSTRAINT plantname_ancestor_pkey PRIMARY KEY (plantname_id, ancestor_id);


--
-- Name: plantname_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantname
    ADD CONSTRAINT plantname_pkey PRIMARY KEY (plantname_id);


--
-- Name: plantnamescope_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantnamescope
    ADD CONSTRAINT plantnamescope_pkey PRIMARY KEY (plantnamescope_id);


--
-- Name: plantobservation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantobservation
    ADD CONSTRAINT plantobservation_pkey PRIMARY KEY (plantobservation_id);


--
-- Name: plantstatus_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantstatus
    ADD CONSTRAINT plantstatus_pkey PRIMARY KEY (plantstatus_id);


--
-- Name: plantstatus_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantstatus
    ADD CONSTRAINT plantstatus_unique UNIQUE (plantconcept_id, party_id);


--
-- Name: plantusage_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY plantusage
    ADD CONSTRAINT plantusage_pkey PRIMARY KEY (plantusage_id);


--
-- Name: project_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY project
    ADD CONSTRAINT project_pkey PRIMARY KEY (project_id);


--
-- Name: project_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY project
    ADD CONSTRAINT project_unique UNIQUE (datasource_id, projectname);


--
-- Name: projectcontributor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY projectcontributor
    ADD CONSTRAINT projectcontributor_pkey PRIMARY KEY (projectcontributor_id);


--
-- Name: reference_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY reference
    ADD CONSTRAINT reference_pkey PRIMARY KEY (reference_id);


--
-- Name: referencealtident_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY referencealtident
    ADD CONSTRAINT referencealtident_pkey PRIMARY KEY (referencealtident_id);


--
-- Name: referencecontributor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY referencecontributor
    ADD CONSTRAINT referencecontributor_pkey PRIMARY KEY (referencecontributor_id);


--
-- Name: referencejournal_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY referencejournal
    ADD CONSTRAINT referencejournal_pkey PRIMARY KEY (referencejournal_id);


--
-- Name: referenceparty_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY referenceparty
    ADD CONSTRAINT referenceparty_pkey PRIMARY KEY (referenceparty_id);


--
-- Name: revision_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY revision
    ADD CONSTRAINT revision_pkey PRIMARY KEY (revision_id);


--
-- Name: soilobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY soilobs
    ADD CONSTRAINT soilobs_pkey PRIMARY KEY (soilobs_id);


--
-- Name: soilobs_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY soilobs
    ADD CONSTRAINT soilobs_unique UNIQUE (locationevent_id);


--
-- Name: soiltaxon_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY soiltaxon
    ADD CONSTRAINT soiltaxon_pkey PRIMARY KEY (soiltaxon_id);


--
-- Name: specimen_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY specimen
    ADD CONSTRAINT specimen_pkey PRIMARY KEY (specimen_id);


--
-- Name: specimenreplicate_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY specimenreplicate
    ADD CONSTRAINT specimenreplicate_pkey PRIMARY KEY (taxonoccurrence_id);


--
-- Name: specimenreplicate_unique_accessioncode; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY specimenreplicate
    ADD CONSTRAINT specimenreplicate_unique_accessioncode UNIQUE (datasource_id, sourceaccessioncode);


--
-- Name: stemobservation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY stemobservation
    ADD CONSTRAINT stemobservation_pkey PRIMARY KEY (stemobservation_id);


--
-- Name: stemobservation_unique_accessioncode; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY stemobservation
    ADD CONSTRAINT stemobservation_unique_accessioncode UNIQUE (plantobservation_id, sourceaccessioncode);


--
-- Name: stemobservation_unique_code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY stemobservation
    ADD CONSTRAINT stemobservation_unique_code UNIQUE (plantobservation_id, authorstemcode);


--
-- Name: stemtag_current_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY stemtag
    ADD CONSTRAINT stemtag_current_unique UNIQUE (stemobservation_id, iscurrent);


--
-- Name: stemtag_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY stemtag
    ADD CONSTRAINT stemtag_pkey PRIMARY KEY (stemtag_id);


--
-- Name: stemtag_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY stemtag
    ADD CONSTRAINT stemtag_unique UNIQUE (stemobservation_id, tag);


--
-- Name: stratum_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY stratum
    ADD CONSTRAINT stratum_pkey PRIMARY KEY (stratum_id);


--
-- Name: taxonalt_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY taxonalt
    ADD CONSTRAINT taxonalt_pkey PRIMARY KEY (taxonalt_id);


--
-- Name: taxondetermination_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY taxondetermination
    ADD CONSTRAINT taxondetermination_pkey PRIMARY KEY (taxondetermination_id);


--
-- Name: taxonoccurrence_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY taxonoccurrence
    ADD CONSTRAINT taxonoccurrence_pkey PRIMARY KEY (taxonoccurrence_id);


--
-- Name: telephone_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY telephone
    ADD CONSTRAINT telephone_pkey PRIMARY KEY (telephone_id);


--
-- Name: trait_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY trait
    ADD CONSTRAINT trait_pkey PRIMARY KEY (trait_id);


--
-- Name: userdefined_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY userdefined
    ADD CONSTRAINT userdefined_pkey PRIMARY KEY (userdefined_id);


--
-- Name: userdefined_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY userdefined
    ADD CONSTRAINT userdefined_unique UNIQUE (tablename, userdefinedname);


--
-- Name: voucher_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY voucher
    ADD CONSTRAINT voucher_pkey PRIMARY KEY (voucher_id);


--
-- Name: voucher_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY voucher
    ADD CONSTRAINT voucher_unique UNIQUE (taxonoccurrence_id, specimenreplicate_id);


--
-- Name: address_organization_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX address_organization_id_x ON address USING btree (organization_id);


--
-- Name: address_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX address_party_id_x ON address USING btree (party_id);


--
-- Name: aggregateoccurrence_taxonoccurrence_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX aggregateoccurrence_taxonoccurrence_id_x ON aggregateoccurrence USING btree (taxonoccurrence_id);


--
-- Name: classcontributor_commclass_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX classcontributor_commclass_id_x ON classcontributor USING btree (commclass_id);


--
-- Name: classcontributor_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX classcontributor_party_id_x ON classcontributor USING btree (party_id);


--
-- Name: classcontributor_role_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX classcontributor_role_id_x ON classcontributor USING btree (role);


--
-- Name: commclass_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX commclass_accessioncode_index ON commclass USING btree (accessioncode);


--
-- Name: commclass_classpublication_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commclass_classpublication_id_x ON commclass USING btree (classpublication_id);


--
-- Name: commclass_locationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commclass_locationevent_id_x ON commclass USING btree (locationevent_id);


--
-- Name: commconcept_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX commconcept_accessioncode_index ON commconcept USING btree (accessioncode);


--
-- Name: commconcept_commname_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commconcept_commname_id_x ON commconcept USING btree (commname_id);


--
-- Name: commconcept_dobscount_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commconcept_dobscount_x ON commconcept USING btree (d_obscount);


--
-- Name: commconcept_reference_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commconcept_reference_id_x ON commconcept USING btree (reference_id);


--
-- Name: commcorrelation_commconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commcorrelation_commconcept_id_x ON commcorrelation USING btree (commconcept_id);


--
-- Name: commcorrelation_commstatus_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commcorrelation_commstatus_id_x ON commcorrelation USING btree (commstatus_id);


--
-- Name: commdetermination_commauthority_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commdetermination_commauthority_id_x ON commdetermination USING btree (commauthority_id);


--
-- Name: commdetermination_commclass_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commdetermination_commclass_id_x ON commdetermination USING btree (commclass_id);


--
-- Name: commdetermination_commconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commdetermination_commconcept_id_x ON commdetermination USING btree (commconcept_id);


--
-- Name: commlineage_childcommstatus_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commlineage_childcommstatus_id_x ON commlineage USING btree (childcommstatus_id);


--
-- Name: commlineage_parentcommstatus_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commlineage_parentcommstatus_id_x ON commlineage USING btree (parentcommstatus_id);


--
-- Name: commname_reference_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commname_reference_id_x ON commname USING btree (reference_id);


--
-- Name: commstatus_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX commstatus_accessioncode_index ON commstatus USING btree (accessioncode);


--
-- Name: commstatus_commconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commstatus_commconcept_id_x ON commstatus USING btree (commconcept_id);


--
-- Name: commstatus_commlevel_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commstatus_commlevel_x ON commstatus USING btree (commlevel);


--
-- Name: commstatus_commparent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commstatus_commparent_id_x ON commstatus USING btree (commparent_id);


--
-- Name: commstatus_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commstatus_party_id_x ON commstatus USING btree (party_id);


--
-- Name: commstatus_reference_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commstatus_reference_id_x ON commstatus USING btree (reference_id);


--
-- Name: commusage_classsystem_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commusage_classsystem_x ON commusage USING btree (classsystem);


--
-- Name: commusage_commconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commusage_commconcept_id_x ON commusage USING btree (commconcept_id);


--
-- Name: commusage_commname_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commusage_commname_id_x ON commusage USING btree (commname_id);


--
-- Name: commusage_commname_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commusage_commname_x ON commusage USING btree (commname);


--
-- Name: commusage_commstatus_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commusage_commstatus_id_x ON commusage USING btree (commstatus_id);


--
-- Name: commusage_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX commusage_party_id_x ON commusage USING btree (party_id);


--
-- Name: coverindex_covermethod_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX coverindex_covermethod_id_x ON coverindex USING btree (covermethod_id);


--
-- Name: covermethod_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX covermethod_accessioncode_index ON covermethod USING btree (accessioncode);


--
-- Name: covermethod_reference_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX covermethod_reference_id_x ON covermethod USING btree (reference_id);


--
-- Name: definedvalue_userdefined_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX definedvalue_userdefined_id_x ON definedvalue USING btree (userdefined_id);


--
-- Name: disturbanceobs_locationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX disturbanceobs_locationevent_id_x ON disturbanceobs USING btree (locationevent_id);


--
-- Name: fki_aggregateoccurrence_coverindex_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_aggregateoccurrence_coverindex_id ON aggregateoccurrence USING btree (coverindex_id);


--
-- Name: fki_aggregateoccurrence_plantobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_aggregateoccurrence_plantobservation_id ON aggregateoccurrence USING btree (plantobservation_id);


--
-- Name: fki_aggregateoccurrence_stratum_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_aggregateoccurrence_stratum_id ON aggregateoccurrence USING btree (stratum_id);


--
-- Name: fki_locationdetermination_identifier_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_locationdetermination_identifier_id ON locationdetermination USING btree (identifier_id);


--
-- Name: fki_locationevent_datasource_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_locationevent_datasource_id ON locationevent USING btree (datasource_id);


--
-- Name: fki_locationevent_method_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_locationevent_method_id ON locationevent USING btree (method_id);


--
-- Name: fki_locationevent_parent_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_locationevent_parent_id ON locationevent USING btree (parent_id);


--
-- Name: fki_method_reference_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_method_reference_id ON method USING btree (reference_id);


--
-- Name: fki_method_subplotmethod_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_method_subplotmethod_id ON method USING btree (subplotmethod_id);


--
-- Name: fki_methodtaxonclass_method_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_methodtaxonclass_method_id ON methodtaxonclass USING btree (method_id);


--
-- Name: fki_methodtaxonclass_plantconcept_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_methodtaxonclass_plantconcept_id ON methodtaxonclass USING btree (plantconcept_id);


--
-- Name: fki_namedplace_ancestor_ancestor_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_namedplace_ancestor_ancestor_id ON namedplace_ancestor USING btree (ancestor_id);


--
-- Name: fki_namedplace_ancestor_namedplace_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_namedplace_ancestor_namedplace_id ON namedplace_ancestor USING btree (namedplace_id);


--
-- Name: fki_namedplace_parent_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_namedplace_parent_id ON namedplace USING btree (parent_id);


--
-- Name: fki_plantname_ancestor_ancestor_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_plantname_ancestor_ancestor_id ON plantname_ancestor USING btree (ancestor_id);


--
-- Name: fki_plantname_ancestor_plantname_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_plantname_ancestor_plantname_id ON plantname_ancestor USING btree (plantname_id);


--
-- Name: fki_plantname_parent_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_plantname_parent_id ON plantname USING btree (parent_id);


--
-- Name: fki_plantname_scope_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_plantname_scope_id ON plantname USING btree (scope_id);


--
-- Name: fki_plantnamescope_locationevent_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_plantnamescope_locationevent_id ON plantnamescope USING btree (locationevent_id);


--
-- Name: fki_plantnamescope_namedplace_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_plantnamescope_namedplace_id ON plantnamescope USING btree (namedplace_id);


--
-- Name: fki_plantnamescope_project_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_plantnamescope_project_id ON plantnamescope USING btree (project_id);


--
-- Name: fki_plantobservation_plant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_plantobservation_plant_id ON plantobservation USING btree (plant_id);


--
-- Name: fki_project_datasource_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_project_datasource_id ON project USING btree (datasource_id);


--
-- Name: fki_specimenreplicate_datasource_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_specimenreplicate_datasource_id ON specimenreplicate USING btree (datasource_id);


--
-- Name: fki_specimenreplicate_institution_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_specimenreplicate_institution_id ON specimenreplicate USING btree (institution_id);


--
-- Name: fki_specimenreplicate_reference_id_fkey; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_specimenreplicate_reference_id_fkey ON specimenreplicate USING btree (datasource_id);


--
-- Name: fki_specimenreplicate_specimen_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_specimenreplicate_specimen_id ON specimenreplicate USING btree (specimen_id);


--
-- Name: fki_stemtag_plant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_stemtag_plant_id ON stemtag USING btree (stemobservation_id);


--
-- Name: fki_stemtag_plantobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_stemtag_plantobservation_id ON stemtag USING btree (stemobservation_id);


--
-- Name: fki_stemtag_stemobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX fki_stemtag_stemobservation_id ON stemtag USING btree (stemobservation_id);


--
-- Name: graphic_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX graphic_accessioncode_index ON graphic USING btree (accessioncode);


--
-- Name: graphic_locationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX graphic_locationevent_id_x ON graphic USING btree (locationevent_id);


--
-- Name: location_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX location_accessioncode_index ON location USING btree (accessioncode);


--
-- Name: location_centerlatitude; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX location_centerlatitude ON location USING btree ((COALESCE(centerlatitude, 'NaN'::double precision)));


--
-- Name: location_centerlongitude; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX location_centerlongitude ON location USING btree ((COALESCE(centerlongitude, 'NaN'::double precision)));


--
-- Name: location_parent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX location_parent_id_x ON location USING btree (parent_id);


--
-- Name: locationdetermination_location_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationdetermination_location_id_x ON locationdetermination USING btree (location_id);


--
-- Name: locationdetermination_namedplace_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationdetermination_namedplace_id ON locationdetermination USING btree ((COALESCE(namedplace_id, 2147483647)));


--
-- Name: locationevent_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX locationevent_accessioncode_index ON locationevent USING btree (accessioncode);


--
-- Name: locationevent_authorlocationcode; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationevent_authorlocationcode ON locationevent USING btree ((COALESCE(authorlocationcode, '\\N'::text)));


--
-- Name: locationevent_datasource_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationevent_datasource_id ON locationevent USING btree ((COALESCE(datasource_id, 2147483647)));


--
-- Name: locationevent_location_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationevent_location_id_x ON locationevent USING btree (location_id);


--
-- Name: locationevent_parent_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationevent_parent_id ON locationevent USING btree ((COALESCE(parent_id, 2147483647)));


--
-- Name: locationevent_previousobs_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationevent_previousobs_id_x ON locationevent USING btree (previous_id);


--
-- Name: locationevent_project_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationevent_project_id_x ON locationevent USING btree (project_id);


--
-- Name: locationevent_soiltaxon_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationevent_soiltaxon_id_x ON locationevent USING btree (soiltaxon_id);


--
-- Name: locationevent_sourceaccessioncode; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationevent_sourceaccessioncode ON locationevent USING btree ((COALESCE(sourceaccessioncode, '\\N'::text)));


--
-- Name: locationevent_unique_location; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX locationevent_unique_location ON locationevent USING btree (location_id) WHERE (parent_id IS NULL);


--
-- Name: locationevent_unique_location_date; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX locationevent_unique_location_date ON locationevent USING btree (location_id, obsstartdate) WHERE (parent_id IS NULL);


--
-- Name: locationevent_unique_project_authorcode; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX locationevent_unique_project_authorcode ON locationevent USING btree (project_id, authorlocationcode, obsstartdate) WHERE (parent_id IS NULL);


--
-- Name: locationeventcontributor_locationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationeventcontributor_locationevent_id_x ON locationeventcontributor USING btree (locationevent_id);


--
-- Name: locationeventcontributor_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationeventcontributor_party_id_x ON locationeventcontributor USING btree (party_id);


--
-- Name: locationeventcontributor_role_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationeventcontributor_role_id_x ON locationeventcontributor USING btree (role);


--
-- Name: locationeventsynonym_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX locationeventsynonym_accessioncode_index ON locationeventsynonym USING btree (accessioncode);


--
-- Name: locationeventsynonym_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationeventsynonym_party_id_x ON locationeventsynonym USING btree (party_id);


--
-- Name: locationeventsynonym_primarylocationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationeventsynonym_primarylocationevent_id_x ON locationeventsynonym USING btree (primarylocationevent_id);


--
-- Name: locationeventsynonym_role_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationeventsynonym_role_id_x ON locationeventsynonym USING btree (role);


--
-- Name: locationeventsynonym_synonymlocationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX locationeventsynonym_synonymlocationevent_id_x ON locationeventsynonym USING btree (synonymlocationevent_id);


--
-- Name: method_accessioncode; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX method_accessioncode ON method USING btree (accessioncode);


--
-- Name: method_description; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX method_description ON method USING btree ((COALESCE(description, '\\N'::text)));


--
-- Name: method_name; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX method_name ON method USING btree (name);


--
-- Name: method_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX method_unique ON method USING btree (name, (COALESCE(description, '\\N'::text)));


--
-- Name: namedplace_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX namedplace_accessioncode_index ON namedplace USING btree (accessioncode);


--
-- Name: namedplace_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX namedplace_unique ON namedplace USING btree ((COALESCE(parent_id, 2147483647)), rank, placename);


--
-- Name: note_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX note_accessioncode_index ON note USING btree (accessioncode);


--
-- Name: note_notelink_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX note_notelink_id_x ON note USING btree (notelink_id);


--
-- Name: note_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX note_party_id_x ON note USING btree (party_id);


--
-- Name: note_role_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX note_role_id_x ON note USING btree (role);


--
-- Name: party_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX party_accessioncode_index ON party USING btree (accessioncode);


--
-- Name: party_currentname_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX party_currentname_id_x ON party USING btree (currentname_id);


--
-- Name: party_givenname; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX party_givenname ON party USING btree ((COALESCE(givenname, '\\N'::text)));


--
-- Name: party_middlename; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX party_middlename ON party USING btree ((COALESCE(middlename, '\\N'::text)));


--
-- Name: party_organizationname; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX party_organizationname ON party USING btree ((COALESCE(organizationname, '\\N'::text)));


--
-- Name: party_surname; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX party_surname ON party USING btree ((COALESCE(surname, '\\N'::text)));


--
-- Name: party_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX party_unique ON party USING btree ((COALESCE(organizationname, '\\N'::text)), (COALESCE(givenname, '\\N'::text)), (COALESCE(middlename, '\\N'::text)), (COALESCE(surname, '\\N'::text)));


--
-- Name: partymember_childparty_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX partymember_childparty_id_x ON partymember USING btree (childparty_id);


--
-- Name: partymember_parentparty_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX partymember_parentparty_id_x ON partymember USING btree (parentparty_id);


--
-- Name: partymember_role_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX partymember_role_id_x ON partymember USING btree (role);


--
-- Name: plantconcept_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX plantconcept_accessioncode_index ON plantconcept USING btree (accessioncode);


--
-- Name: plantconcept_plantname_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantconcept_plantname_id_x ON plantconcept USING btree (plantname_id);


--
-- Name: plantcorrelation_plantconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantcorrelation_plantconcept_id_x ON plantcorrelation USING btree (plantconcept_id);


--
-- Name: plantcorrelation_plantstatus_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantcorrelation_plantstatus_id_x ON plantcorrelation USING btree (plantstatus_id);


--
-- Name: plantlineage_childplantstatus_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantlineage_childplantstatus_id_x ON plantlineage USING btree (childplantstatus_id);


--
-- Name: plantlineage_parentplantstatus_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantlineage_parentplantstatus_id_x ON plantlineage USING btree (parentplantstatus_id);


--
-- Name: plantname_plantname_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantname_plantname_x ON plantname USING btree (plantname);


--
-- Name: plantname_rank; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantname_rank ON plantname USING btree (rank);


--
-- Name: plantname_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX plantname_unique ON plantname USING btree ((COALESCE(parent_id, 2147483647)), (COALESCE(scope_id, 2147483647)), rank, plantname);


--
-- Name: plantnamescope_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX plantnamescope_unique ON plantnamescope USING btree ((COALESCE(locationevent_id, 2147483647)), (COALESCE(project_id, 2147483647)), (COALESCE(namedplace_id, 2147483647)));


--
-- Name: plantstatus_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX plantstatus_accessioncode_index ON plantstatus USING btree (accessioncode);


--
-- Name: plantstatus_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantstatus_party_id_x ON plantstatus USING btree (party_id);


--
-- Name: plantstatus_plantconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantstatus_plantconcept_id_x ON plantstatus USING btree (plantconcept_id);


--
-- Name: plantstatus_reference_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantstatus_reference_id_x ON plantstatus USING btree (reference_id);


--
-- Name: plantusage_classsystem_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantusage_classsystem_x ON plantusage USING btree (classsystem);


--
-- Name: plantusage_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantusage_party_id_x ON plantusage USING btree (party_id);


--
-- Name: plantusage_plantconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantusage_plantconcept_id_x ON plantusage USING btree (plantconcept_id);


--
-- Name: plantusage_plantname_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantusage_plantname_id_x ON plantusage USING btree (plantname_id);


--
-- Name: plantusage_plantname_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantusage_plantname_x ON plantusage USING btree (plantname);


--
-- Name: plantusage_plantstatus_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX plantusage_plantstatus_id_x ON plantusage USING btree (plantstatus_id);


--
-- Name: project_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX project_accessioncode_index ON project USING btree (accessioncode);


--
-- Name: projectcontributor_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX projectcontributor_party_id_x ON projectcontributor USING btree (party_id);


--
-- Name: projectcontributor_project_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX projectcontributor_project_id_x ON projectcontributor USING btree (project_id);


--
-- Name: projectcontributor_role_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX projectcontributor_role_id_x ON projectcontributor USING btree (role);


--
-- Name: reference_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX reference_accessioncode_index ON reference USING btree (accessioncode);


--
-- Name: reference_referencejournal_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX reference_referencejournal_id_x ON reference USING btree (referencejournal_id);


--
-- Name: referencealtident_reference_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX referencealtident_reference_id_x ON referencealtident USING btree (reference_id);


--
-- Name: referencecontributor_reference_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX referencecontributor_reference_id_x ON referencecontributor USING btree (reference_id);


--
-- Name: referencecontributor_referenceparty_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX referencecontributor_referenceparty_id_x ON referencecontributor USING btree (referenceparty_id);


--
-- Name: referencejournal_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX referencejournal_accessioncode_index ON referencejournal USING btree (accessioncode);


--
-- Name: referenceparty_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX referenceparty_accessioncode_index ON referenceparty USING btree (accessioncode);


--
-- Name: referenceparty_currentparty_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX referenceparty_currentparty_id_x ON referenceparty USING btree (currentparty_id);


--
-- Name: revision_previousrevision_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX revision_previousrevision_id_x ON revision USING btree (previousrevision_id);


--
-- Name: soilobs_locationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX soilobs_locationevent_id_x ON soilobs USING btree (locationevent_id);


--
-- Name: soiltaxon_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX soiltaxon_accessioncode_index ON soiltaxon USING btree (accessioncode);


--
-- Name: soiltaxon_soilparent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX soiltaxon_soilparent_id_x ON soiltaxon USING btree (soilparent_id);


--
-- Name: specimenreplicate_catalognumber_dwc; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX specimenreplicate_catalognumber_dwc ON specimenreplicate USING btree ((COALESCE(catalognumber_dwc, '\\N'::text)));


--
-- Name: specimenreplicate_sourceaccessioncode; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX specimenreplicate_sourceaccessioncode ON specimenreplicate USING btree ((COALESCE(sourceaccessioncode, '\\N'::text)));


--
-- Name: specimenreplicate_unique_catalognumber; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX specimenreplicate_unique_catalognumber ON specimenreplicate USING btree (datasource_id, (COALESCE(institution_id, 2147483647)), (COALESCE(collectioncode_dwc, '\\N'::text)), catalognumber_dwc) WHERE (sourceaccessioncode IS NULL);


--
-- Name: stemobservation_plantobservation_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX stemobservation_plantobservation_id_x ON stemobservation USING btree (plantobservation_id);


--
-- Name: stratum_locationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX stratum_locationevent_id_x ON stratum USING btree (locationevent_id);


--
-- Name: taxonalt_plantconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX taxonalt_plantconcept_id_x ON taxonalt USING btree (plantconcept_id);


--
-- Name: taxonalt_taxondetermination_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX taxonalt_taxondetermination_id_x ON taxonalt USING btree (taxondetermination_id);


--
-- Name: taxondetermination_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX taxondetermination_accessioncode_index ON taxondetermination USING btree (accessioncode);


--
-- Name: taxondetermination_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX taxondetermination_party_id_x ON taxondetermination USING btree (party_id);


--
-- Name: taxondetermination_plantconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX taxondetermination_plantconcept_id_x ON taxondetermination USING btree (plantconcept_id);


--
-- Name: taxondetermination_reference_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX taxondetermination_reference_id_x ON taxondetermination USING btree (reference_id);


--
-- Name: taxondetermination_role_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX taxondetermination_role_id_x ON taxondetermination USING btree (role);


--
-- Name: taxondetermination_taxonoccurrence_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX taxondetermination_taxonoccurrence_id_x ON taxondetermination USING btree (taxonoccurrence_id);


--
-- Name: taxondetermination_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX taxondetermination_unique ON taxondetermination USING btree (taxonoccurrence_id, role, (COALESCE(party_id, 2147483647)), plantconcept_id);


--
-- Name: taxonoccurrence_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX taxonoccurrence_accessioncode_index ON taxonoccurrence USING btree (accessioncode);


--
-- Name: taxonoccurrence_locationevent_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX taxonoccurrence_locationevent_id_x ON taxonoccurrence USING btree (locationevent_id);


--
-- Name: telephone_party_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX telephone_party_id_x ON telephone USING btree (party_id);


--
-- Name: userdefined_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX userdefined_accessioncode_index ON userdefined USING btree (accessioncode);


--
-- Name: aggregateoccurrence_plantobs_count_1; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER aggregateoccurrence_plantobs_count_1 BEFORE INSERT OR UPDATE ON aggregateoccurrence FOR EACH ROW EXECUTE PROCEDURE aggregateoccurrence_plantobs_count_1();


--
-- Name: namedplace_update_ancestors; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER namedplace_update_ancestors AFTER INSERT OR UPDATE ON namedplace FOR EACH ROW EXECUTE PROCEDURE namedplace_update_ancestors();


--
-- Name: plantname_update_ancestors; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER plantname_update_ancestors AFTER INSERT OR UPDATE ON plantname FOR EACH ROW EXECUTE PROCEDURE plantname_update_ancestors();


--
-- Name: taxondetermination_taxonoccurrence_id_fkey; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER taxondetermination_taxonoccurrence_id_fkey BEFORE INSERT OR UPDATE ON taxondetermination FOR EACH ROW EXECUTE PROCEDURE taxondetermination_taxonoccurrence_id_fkey();


--
-- Name: address_organization_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY address
    ADD CONSTRAINT address_organization_id FOREIGN KEY (organization_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: address_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY address
    ADD CONSTRAINT address_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: aggregateoccurrence_coverindex_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY aggregateoccurrence
    ADD CONSTRAINT aggregateoccurrence_coverindex_id FOREIGN KEY (coverindex_id) REFERENCES coverindex(coverindex_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: aggregateoccurrence_method_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY aggregateoccurrence
    ADD CONSTRAINT aggregateoccurrence_method_id FOREIGN KEY (method_id) REFERENCES method(method_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: aggregateoccurrence_plantobservation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY aggregateoccurrence
    ADD CONSTRAINT aggregateoccurrence_plantobservation_id FOREIGN KEY (plantobservation_id) REFERENCES plantobservation(plantobservation_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: aggregateoccurrence_stratum_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY aggregateoccurrence
    ADD CONSTRAINT aggregateoccurrence_stratum_id FOREIGN KEY (stratum_id) REFERENCES stratum(stratum_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: aggregateoccurrence_taxonoccurrence_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY aggregateoccurrence
    ADD CONSTRAINT aggregateoccurrence_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) REFERENCES taxonoccurrence(taxonoccurrence_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: classcontributor_commclass_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY classcontributor
    ADD CONSTRAINT classcontributor_commclass_id FOREIGN KEY (commclass_id) REFERENCES commclass(commclass_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: classcontributor_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY classcontributor
    ADD CONSTRAINT classcontributor_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commclass_classpublication_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commclass
    ADD CONSTRAINT commclass_classpublication_id FOREIGN KEY (classpublication_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commclass_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commclass
    ADD CONSTRAINT commclass_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commconcept_commname_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commconcept
    ADD CONSTRAINT commconcept_commname_id FOREIGN KEY (commname_id) REFERENCES commname(commname_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commconcept_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commconcept
    ADD CONSTRAINT commconcept_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commcorrelation_commconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commcorrelation
    ADD CONSTRAINT commcorrelation_commconcept_id FOREIGN KEY (commconcept_id) REFERENCES commconcept(commconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commcorrelation_commstatus_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commcorrelation
    ADD CONSTRAINT commcorrelation_commstatus_id FOREIGN KEY (commstatus_id) REFERENCES commstatus(commstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commdetermination_commauthority_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commdetermination
    ADD CONSTRAINT commdetermination_commauthority_id FOREIGN KEY (commauthority_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commdetermination_commclass_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commdetermination
    ADD CONSTRAINT commdetermination_commclass_id FOREIGN KEY (commclass_id) REFERENCES commclass(commclass_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commdetermination_commconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commdetermination
    ADD CONSTRAINT commdetermination_commconcept_id FOREIGN KEY (commconcept_id) REFERENCES commconcept(commconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commlineage_childcommstatus_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commlineage
    ADD CONSTRAINT commlineage_childcommstatus_id FOREIGN KEY (childcommstatus_id) REFERENCES commstatus(commstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commlineage_parentcommstatus_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commlineage
    ADD CONSTRAINT commlineage_parentcommstatus_id FOREIGN KEY (parentcommstatus_id) REFERENCES commstatus(commstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commname_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commname
    ADD CONSTRAINT commname_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commstatus_commconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commstatus
    ADD CONSTRAINT commstatus_commconcept_id FOREIGN KEY (commconcept_id) REFERENCES commconcept(commconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commstatus_commparent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commstatus
    ADD CONSTRAINT commstatus_commparent_id FOREIGN KEY (commparent_id) REFERENCES commconcept(commconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commstatus_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commstatus
    ADD CONSTRAINT commstatus_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commstatus_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commstatus
    ADD CONSTRAINT commstatus_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commusage_commconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commusage
    ADD CONSTRAINT commusage_commconcept_id FOREIGN KEY (commconcept_id) REFERENCES commconcept(commconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commusage_commname_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commusage
    ADD CONSTRAINT commusage_commname_id FOREIGN KEY (commname_id) REFERENCES commname(commname_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commusage_commstatus_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commusage
    ADD CONSTRAINT commusage_commstatus_id FOREIGN KEY (commstatus_id) REFERENCES commstatus(commstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: commusage_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY commusage
    ADD CONSTRAINT commusage_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: coverindex_covermethod_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY coverindex
    ADD CONSTRAINT coverindex_covermethod_id FOREIGN KEY (covermethod_id) REFERENCES covermethod(covermethod_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: covermethod_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY covermethod
    ADD CONSTRAINT covermethod_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: definedvalue_userdefined_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY definedvalue
    ADD CONSTRAINT definedvalue_userdefined_id FOREIGN KEY (userdefined_id) REFERENCES userdefined(userdefined_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: disturbanceobs_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY disturbanceobs
    ADD CONSTRAINT disturbanceobs_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: graphic_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY graphic
    ADD CONSTRAINT graphic_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: location_datasource_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY location
    ADD CONSTRAINT location_datasource_id FOREIGN KEY (datasource_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: location_parent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY location
    ADD CONSTRAINT location_parent_id FOREIGN KEY (parent_id) REFERENCES location(location_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationdetermination_identifier_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationdetermination
    ADD CONSTRAINT locationdetermination_identifier_id FOREIGN KEY (identifier_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationdetermination_location_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationdetermination
    ADD CONSTRAINT locationdetermination_location_id FOREIGN KEY (location_id) REFERENCES location(location_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationdetermination_namedplace_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationdetermination
    ADD CONSTRAINT locationdetermination_namedplace_id FOREIGN KEY (namedplace_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationevent_datasource_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_datasource_id FOREIGN KEY (datasource_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationevent_location_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_location_id FOREIGN KEY (location_id) REFERENCES location(location_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationevent_method_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_method_id FOREIGN KEY (method_id) REFERENCES method(method_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationevent_parent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_parent_id FOREIGN KEY (parent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationevent_previousobs_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_previousobs_id FOREIGN KEY (previous_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationevent_project_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_project_id FOREIGN KEY (project_id) REFERENCES project(project_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationevent_soiltaxon_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationevent
    ADD CONSTRAINT locationevent_soiltaxon_id FOREIGN KEY (soiltaxon_id) REFERENCES soiltaxon(soiltaxon_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationeventcontributor_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationeventcontributor
    ADD CONSTRAINT locationeventcontributor_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationeventcontributor_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationeventcontributor
    ADD CONSTRAINT locationeventcontributor_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationeventsynonym_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationeventsynonym
    ADD CONSTRAINT locationeventsynonym_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationeventsynonym_primarylocationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationeventsynonym
    ADD CONSTRAINT locationeventsynonym_primarylocationevent_id FOREIGN KEY (primarylocationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: locationeventsynonym_synonymlocationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY locationeventsynonym
    ADD CONSTRAINT locationeventsynonym_synonymlocationevent_id FOREIGN KEY (synonymlocationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: method_covermethod_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY method
    ADD CONSTRAINT method_covermethod_id FOREIGN KEY (covermethod_id) REFERENCES covermethod(covermethod_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: method_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY method
    ADD CONSTRAINT method_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: method_subplotmethod_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY method
    ADD CONSTRAINT method_subplotmethod_id FOREIGN KEY (subplotmethod_id) REFERENCES method(method_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: methodtaxonclass_method_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY methodtaxonclass
    ADD CONSTRAINT methodtaxonclass_method_id FOREIGN KEY (method_id) REFERENCES method(method_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: methodtaxonclass_plantconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY methodtaxonclass
    ADD CONSTRAINT methodtaxonclass_plantconcept_id FOREIGN KEY (plantconcept_id) REFERENCES plantconcept(plantconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: methodtaxonclass_submethod_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY methodtaxonclass
    ADD CONSTRAINT methodtaxonclass_submethod_id FOREIGN KEY (submethod_id) REFERENCES method(method_id) ON UPDATE CASCADE ON DELETE SET NULL;


--
-- Name: namedplace_ancestor_ancestor_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY namedplace_ancestor
    ADD CONSTRAINT namedplace_ancestor_ancestor_id FOREIGN KEY (ancestor_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: namedplace_ancestor_namedplace_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY namedplace_ancestor
    ADD CONSTRAINT namedplace_ancestor_namedplace_id FOREIGN KEY (namedplace_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: namedplace_parent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY namedplace
    ADD CONSTRAINT namedplace_parent_id FOREIGN KEY (parent_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: namedplacecorrelation_childplace_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY namedplacecorrelation
    ADD CONSTRAINT namedplacecorrelation_childplace_id FOREIGN KEY (childplace_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: namedplacecorrelation_parentplace_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY namedplacecorrelation
    ADD CONSTRAINT namedplacecorrelation_parentplace_id FOREIGN KEY (parentplace_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: note_notelink_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY note
    ADD CONSTRAINT note_notelink_id FOREIGN KEY (notelink_id) REFERENCES notelink(notelink_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: note_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY note
    ADD CONSTRAINT note_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: party_currentname_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY party
    ADD CONSTRAINT party_currentname_id FOREIGN KEY (currentname_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: partymember_childparty_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY partymember
    ADD CONSTRAINT partymember_childparty_id FOREIGN KEY (childparty_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: partymember_parentparty_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY partymember
    ADD CONSTRAINT partymember_parentparty_id FOREIGN KEY (parentparty_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantconcept_plantname_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantconcept
    ADD CONSTRAINT plantconcept_plantname_id FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantcorrelation_plantconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantcorrelation
    ADD CONSTRAINT plantcorrelation_plantconcept_id FOREIGN KEY (plantconcept_id) REFERENCES plantconcept(plantconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantcorrelation_plantstatus_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantcorrelation
    ADD CONSTRAINT plantcorrelation_plantstatus_id FOREIGN KEY (plantstatus_id) REFERENCES plantstatus(plantstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantlineage_childplantstatus_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantlineage
    ADD CONSTRAINT plantlineage_childplantstatus_id FOREIGN KEY (childplantstatus_id) REFERENCES plantstatus(plantstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantlineage_parentplantstatus_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantlineage
    ADD CONSTRAINT plantlineage_parentplantstatus_id FOREIGN KEY (parentplantstatus_id) REFERENCES plantstatus(plantstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantname_ancestor_ancestor_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantname_ancestor
    ADD CONSTRAINT plantname_ancestor_ancestor_id FOREIGN KEY (ancestor_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantname_ancestor_plantname_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantname_ancestor
    ADD CONSTRAINT plantname_ancestor_plantname_id FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantname_parent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantname
    ADD CONSTRAINT plantname_parent_id FOREIGN KEY (parent_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantname_scope_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantname
    ADD CONSTRAINT plantname_scope_id FOREIGN KEY (scope_id) REFERENCES plantnamescope(plantnamescope_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantnamescope_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantnamescope
    ADD CONSTRAINT plantnamescope_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantnamescope_namedplace_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantnamescope
    ADD CONSTRAINT plantnamescope_namedplace_id FOREIGN KEY (namedplace_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantnamescope_project_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantnamescope
    ADD CONSTRAINT plantnamescope_project_id FOREIGN KEY (project_id) REFERENCES project(project_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantobservation_plant_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantobservation
    ADD CONSTRAINT plantobservation_plant_id FOREIGN KEY (plant_id) REFERENCES plant(plant_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantstatus_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantstatus
    ADD CONSTRAINT plantstatus_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantstatus_plantconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantstatus
    ADD CONSTRAINT plantstatus_plantconcept_id FOREIGN KEY (plantconcept_id) REFERENCES plantconcept(plantconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantstatus_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantstatus
    ADD CONSTRAINT plantstatus_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantusage_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantusage
    ADD CONSTRAINT plantusage_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantusage_plantconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantusage
    ADD CONSTRAINT plantusage_plantconcept_id FOREIGN KEY (plantconcept_id) REFERENCES plantconcept(plantconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantusage_plantname_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantusage
    ADD CONSTRAINT plantusage_plantname_id FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: plantusage_plantstatus_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY plantusage
    ADD CONSTRAINT plantusage_plantstatus_id FOREIGN KEY (plantstatus_id) REFERENCES plantstatus(plantstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: project_datasource_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY project
    ADD CONSTRAINT project_datasource_id FOREIGN KEY (datasource_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: projectcontributor_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY projectcontributor
    ADD CONSTRAINT projectcontributor_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: projectcontributor_project_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY projectcontributor
    ADD CONSTRAINT projectcontributor_project_id FOREIGN KEY (project_id) REFERENCES project(project_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: reference_referencejournal_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY reference
    ADD CONSTRAINT reference_referencejournal_id FOREIGN KEY (referencejournal_id) REFERENCES referencejournal(referencejournal_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: referencealtident_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY referencealtident
    ADD CONSTRAINT referencealtident_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: referencecontributor_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY referencecontributor
    ADD CONSTRAINT referencecontributor_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: referencecontributor_referenceparty_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY referencecontributor
    ADD CONSTRAINT referencecontributor_referenceparty_id FOREIGN KEY (referenceparty_id) REFERENCES referenceparty(referenceparty_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: referenceparty_currentparty_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY referenceparty
    ADD CONSTRAINT referenceparty_currentparty_id FOREIGN KEY (currentparty_id) REFERENCES referenceparty(referenceparty_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: revision_previousrevision_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY revision
    ADD CONSTRAINT revision_previousrevision_id FOREIGN KEY (previousrevision_id) REFERENCES revision(revision_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: soilobs_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY soilobs
    ADD CONSTRAINT soilobs_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: soiltaxon_soilparent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY soiltaxon
    ADD CONSTRAINT soiltaxon_soilparent_id FOREIGN KEY (soilparent_id) REFERENCES soiltaxon(soiltaxon_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: specimenreplicate_datasource_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY specimenreplicate
    ADD CONSTRAINT specimenreplicate_datasource_id FOREIGN KEY (datasource_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: specimenreplicate_institution_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY specimenreplicate
    ADD CONSTRAINT specimenreplicate_institution_id FOREIGN KEY (institution_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: specimenreplicate_specimen_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY specimenreplicate
    ADD CONSTRAINT specimenreplicate_specimen_id FOREIGN KEY (specimen_id) REFERENCES specimen(specimen_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: stemobservation_plantobservation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY stemobservation
    ADD CONSTRAINT stemobservation_plantobservation_id FOREIGN KEY (plantobservation_id) REFERENCES plantobservation(plantobservation_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: stemtag_stemobservation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY stemtag
    ADD CONSTRAINT stemtag_stemobservation_id FOREIGN KEY (stemobservation_id) REFERENCES stemobservation(stemobservation_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: stratum_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY stratum
    ADD CONSTRAINT stratum_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: stratum_method_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY stratum
    ADD CONSTRAINT stratum_method_id FOREIGN KEY (method_id) REFERENCES method(method_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: taxonalt_plantconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY taxonalt
    ADD CONSTRAINT taxonalt_plantconcept_id FOREIGN KEY (plantconcept_id) REFERENCES plantconcept(plantconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: taxonalt_taxondetermination_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY taxonalt
    ADD CONSTRAINT taxonalt_taxondetermination_id FOREIGN KEY (taxondetermination_id) REFERENCES taxondetermination(taxondetermination_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: taxondetermination_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY taxondetermination
    ADD CONSTRAINT taxondetermination_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: taxondetermination_plantconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY taxondetermination
    ADD CONSTRAINT taxondetermination_plantconcept_id FOREIGN KEY (plantconcept_id) REFERENCES plantconcept(plantconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: taxondetermination_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY taxondetermination
    ADD CONSTRAINT taxondetermination_reference_id FOREIGN KEY (reference_id) REFERENCES reference(reference_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: taxonoccurrence_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY taxonoccurrence
    ADD CONSTRAINT taxonoccurrence_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: telephone_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY telephone
    ADD CONSTRAINT telephone_party_id FOREIGN KEY (party_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: trait_stemobservation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY trait
    ADD CONSTRAINT trait_stemobservation_id_fkey FOREIGN KEY (stemobservation_id) REFERENCES stemobservation(stemobservation_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: voucher_specimenreplicate_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY voucher
    ADD CONSTRAINT voucher_specimenreplicate_id FOREIGN KEY (specimenreplicate_id) REFERENCES specimenreplicate(taxonoccurrence_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: voucher_taxonoccurrence_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY voucher
    ADD CONSTRAINT voucher_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) REFERENCES taxonoccurrence(taxonoccurrence_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- PostgreSQL database dump complete
--

