Project

General

Profile

« Previous | Next » 

Revision 391

Made more of Bob Peet's changes to the vegbien db and updated VegX-VegBIEN mapping

View differences:

vegbien.sql
140 140

  
141 141
CREATE TABLE collection (
142 142
    collection_id integer NOT NULL,
143
    individualplant_id integer NOT NULL
143
    stemobservation_id integer NOT NULL
144 144
);
145 145

  
146 146

  
......
180 180
    stratumbase double precision,
181 181
    stratumheight double precision,
182 182
    emb_taxonimportance integer,
183
    covercode character varying(10)
183
    covercode character varying(10),
184
    count integer NOT NULL
184 185
);
185 186

  
186 187

  
......
1059 1060

  
1060 1061
CREATE TABLE individualplant (
1061 1062
    individualplant_id integer NOT NULL,
1062
    stemcount_id integer NOT NULL,
1063
    stemcode character varying(20),
1064
    stemxposition double precision,
1065
    stemyposition double precision,
1066
    stemhealth character varying(50),
1067
    emb_stemlocation integer
1063
    collectiveobservation_id integer NOT NULL,
1064
    stemdiameter double precision,
1065
    stemdiameteraccuracy double precision,
1066
    stemheight double precision,
1067
    stemheightaccuracy double precision,
1068
    stemtaxonarea double precision,
1069
    emb_individualplant integer
1068 1070
);
1069 1071

  
1070 1072

  
1071 1073
--
1074
-- Name: individualplant_individualplant_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1075
--
1076

  
1077
CREATE SEQUENCE individualplant_individualplant_id_seq
1078
    START WITH 1
1079
    INCREMENT BY 1
1080
    NO MINVALUE
1081
    NO MAXVALUE
1082
    CACHE 1;
1083

  
1084

  
1085
--
1086
-- Name: individualplant_individualplant_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1087
--
1088

  
1089
ALTER SEQUENCE individualplant_individualplant_id_seq OWNED BY individualplant.individualplant_id;
1090

  
1091

  
1092
--
1072 1093
-- Name: keywords; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1073 1094
--
1074 1095

  
......
2173 2194

  
2174 2195

  
2175 2196
--
2176
-- Name: stemcount; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2197
-- Name: stemobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2177 2198
--
2178 2199

  
2179
CREATE TABLE stemcount (
2180
    stemcount_id integer NOT NULL,
2181
    collectiveobservation_id integer NOT NULL,
2182
    stemdiameter double precision,
2183
    stemdiameteraccuracy double precision,
2184
    stemheight double precision,
2185
    stemheightaccuracy double precision,
2186
    stemcount integer NOT NULL,
2187
    stemtaxonarea double precision,
2188
    emb_stemcount integer
2200
CREATE TABLE stemobservation (
2201
    stemobservation_id integer NOT NULL,
2202
    individualplant_id integer NOT NULL,
2203
    stemcode character varying(20),
2204
    stemxposition double precision,
2205
    stemyposition double precision,
2206
    stemhealth character varying(50),
2207
    emb_stemlocation integer
2189 2208
);
2190 2209

  
2191 2210

  
2192 2211
--
2193
-- Name: stemcount_stemcount_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2194
--
2195

  
2196
CREATE SEQUENCE stemcount_stemcount_id_seq
2197
    START WITH 1
2198
    INCREMENT BY 1
2199
    NO MINVALUE
2200
    NO MAXVALUE
2201
    CACHE 1;
2202

  
2203

  
2204
--
2205
-- Name: stemcount_stemcount_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2206
--
2207

  
2208
ALTER SEQUENCE stemcount_stemcount_id_seq OWNED BY stemcount.stemcount_id;
2209

  
2210

  
2211
--
2212 2212
-- Name: stemlocation_stemlocation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2213 2213
--
2214 2214

  
......
2224 2224
-- Name: stemlocation_stemlocation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2225 2225
--
2226 2226

  
2227
ALTER SEQUENCE stemlocation_stemlocation_id_seq OWNED BY individualplant.individualplant_id;
2227
ALTER SEQUENCE stemlocation_stemlocation_id_seq OWNED BY stemobservation.stemobservation_id;
2228 2228

  
2229 2229

  
2230 2230
--
......
2382 2382
CREATE TABLE taxondetermination (
2383 2383
    taxondetermination_id integer NOT NULL,
2384 2384
    taxonoccurrence_id integer NOT NULL,
2385
    individualplant_id integer,
2385
    stemobservation_id integer,
2386 2386
    plantconcept_id integer NOT NULL,
2387 2387
    plantname_id integer,
2388 2388
    party_id integer NOT NULL,
......
3008 3008

  
3009 3009

  
3010 3010
--
3011
-- Name: view_all_commnames_code; Type: VIEW; Schema: public; Owner: -
3012
--
3013

  
3014
CREATE VIEW view_all_commnames_code AS
3015
    SELECT commusage.commconcept_id, commusage.commname FROM commusage WHERE ((commusage.classsystem)::text = 'Code'::text);
3016

  
3017

  
3018
--
3019
-- Name: view_all_commnames_common; Type: VIEW; Schema: public; Owner: -
3020
--
3021

  
3022
CREATE VIEW view_all_commnames_common AS
3023
    SELECT commusage.commconcept_id, commusage.commname FROM commusage WHERE ((commusage.classsystem)::text = 'Common'::text);
3024

  
3025

  
3026
--
3027
-- Name: view_all_commnames_sciname; Type: VIEW; Schema: public; Owner: -
3028
--
3029

  
3030
CREATE VIEW view_all_commnames_sciname AS
3031
    SELECT commusage.commconcept_id, commusage.commname FROM commusage WHERE ((commusage.classsystem)::text = 'Scientific'::text);
3032

  
3033

  
3034
--
3035
-- Name: view_all_commnames_translated; Type: VIEW; Schema: public; Owner: -
3036
--
3037

  
3038
CREATE VIEW view_all_commnames_translated AS
3039
    SELECT commusage.commconcept_id, commusage.commname FROM commusage WHERE ((commusage.classsystem)::text = 'Translated'::text);
3040

  
3041

  
3042
--
3043
-- Name: view_all_plantnames_code; Type: VIEW; Schema: public; Owner: -
3044
--
3045

  
3046
CREATE VIEW view_all_plantnames_code AS
3047
    SELECT plantusage.plantconcept_id, plantusage.plantname FROM plantusage WHERE ((plantusage.classsystem)::text = 'Code'::text);
3048

  
3049

  
3050
--
3051
-- Name: view_all_plantnames_common; Type: VIEW; Schema: public; Owner: -
3052
--
3053

  
3054
CREATE VIEW view_all_plantnames_common AS
3055
    SELECT plantusage.plantconcept_id, plantusage.plantname FROM plantusage WHERE ((plantusage.classsystem)::text = 'English Common'::text);
3056

  
3057

  
3058
--
3059
-- Name: view_all_plantnames_sciname; Type: VIEW; Schema: public; Owner: -
3060
--
3061

  
3062
CREATE VIEW view_all_plantnames_sciname AS
3063
    SELECT plantusage.plantconcept_id, plantusage.plantname FROM plantusage WHERE ((plantusage.classsystem)::text = 'Scientific'::text);
3064

  
3065

  
3066
--
3067
-- Name: view_all_plantnames_scinamenoauth; Type: VIEW; Schema: public; Owner: -
3068
--
3069

  
3070
CREATE VIEW view_all_plantnames_scinamenoauth AS
3071
    SELECT plantusage.plantconcept_id, plantusage.plantname FROM plantusage WHERE ((plantusage.classsystem)::text = 'Scientific without authors'::text);
3072

  
3073

  
3074
--
3075
-- Name: view_notemb_observation; Type: VIEW; Schema: public; Owner: -
3076
--
3077

  
3078
CREATE VIEW view_notemb_observation AS
3079
    SELECT plotevent.plotevent_id, plotevent.previousobs_id, plotevent.plot_id, plotevent.project_id, plotevent.authorobscode, plotevent.dateaccuracy, plotevent.covermethod_id, plotevent.coverdispersion, plotevent.autotaxoncover, plotevent.stratummethod_id, plotevent.methodnarrative, plotevent.taxonobservationarea, plotevent.stemsizelimit, plotevent.stemobservationarea, plotevent.stemsamplemethod, plotevent.originaldata, plotevent.effortlevel, plotevent.plotvalidationlevel, plotevent.floristicquality, plotevent.bryophytequality, plotevent.lichenquality, plotevent.observationnarrative, plotevent.landscapenarrative, plotevent.homogeneity, plotevent.phenologicaspect, plotevent.representativeness, plotevent.standmaturity, plotevent.successionalstatus, plotevent.basalarea, plotevent.hydrologicregime, plotevent.soilmoistureregime, plotevent.soildrainage, plotevent.watersalinity, plotevent.waterdepth, plotevent.shoredistance, plotevent.soildepth, plotevent.organicdepth, plotevent.soiltaxon_id, plotevent.soiltaxonsrc, plotevent.percentbedrock, plotevent.percentrockgravel, plotevent.percentwood, plotevent.percentlitter, plotevent.percentbaresoil, plotevent.percentwater, plotevent.percentother, plotevent.nameother, plotevent.treeht, plotevent.shrubht, plotevent.fieldht, plotevent.nonvascularht, plotevent.submergedht, plotevent.treecover, plotevent.shrubcover, plotevent.fieldcover, plotevent.nonvascularcover, plotevent.floatingcover, plotevent.submergedcover, plotevent.dominantstratum, plotevent.growthform1type, plotevent.growthform2type, plotevent.growthform3type, plotevent.growthform1cover, plotevent.growthform2cover, plotevent.growthform3cover, plotevent.totalcover, plotevent.notespublic, plotevent.notesmgt, plotevent.revisions, plotevent.obsstartdate, plotevent.obsenddate, plotevent.dateentered, plotevent.emb_observation, plotevent.interp_orig_ci_id, plotevent.interp_orig_cc_id, plotevent.interp_orig_sciname, plotevent.interp_orig_code, plotevent.interp_orig_party_id, plotevent.interp_orig_partyname, plotevent.interp_current_ci_id, plotevent.interp_current_cc_id, plotevent.interp_current_sciname, plotevent.interp_current_code, plotevent.interp_current_party_id, plotevent.interp_current_partyname, plotevent.interp_bestfit_ci_id, plotevent.interp_bestfit_cc_id, plotevent.interp_bestfit_sciname, plotevent.interp_bestfit_code, plotevent.interp_bestfit_party_id, plotevent.interp_bestfit_partyname, plotevent.toptaxon1name, plotevent.toptaxon2name, plotevent.toptaxon3name, plotevent.toptaxon4name, plotevent.toptaxon5name, plotevent.numberoftaxa, plotevent.accessioncode FROM plotevent WHERE (plotevent.emb_observation < 6);
3080

  
3081

  
3082
--
3083
-- Name: view_browseparty_classcontrib; Type: VIEW; Schema: public; Owner: -
3084
--
3085

  
3086
CREATE VIEW view_browseparty_classcontrib AS
3087
    SELECT observation_2.plotevent_id, classcontributor.party_id FROM (view_notemb_observation observation_2 JOIN (commclass JOIN classcontributor ON ((commclass.commclass_id = classcontributor.commclass_id))) ON ((observation_2.plotevent_id = commclass.plotevent_id))) GROUP BY observation_2.plotevent_id, classcontributor.party_id;
3088

  
3089

  
3090
--
3091
-- Name: view_browseparty_obscontrib; Type: VIEW; Schema: public; Owner: -
3092
--
3093

  
3094
CREATE VIEW view_browseparty_obscontrib AS
3095
    SELECT observationcontributor.party_id, observationcontributor.plotevent_id FROM (view_notemb_observation plotevent JOIN observationcontributor ON ((plotevent.plotevent_id = observationcontributor.plotevent_id))) GROUP BY observationcontributor.party_id, observationcontributor.plotevent_id;
3096

  
3097

  
3098
--
3099
-- Name: view_browseparty_projectcontrib; Type: VIEW; Schema: public; Owner: -
3100
--
3101

  
3102
CREATE VIEW view_browseparty_projectcontrib AS
3103
    SELECT observation_1.plotevent_id, projectcontributor.party_id FROM ((project JOIN view_notemb_observation observation_1 ON ((project.project_id = observation_1.project_id))) JOIN projectcontributor ON ((project.project_id = projectcontributor.project_id))) GROUP BY observation_1.plotevent_id, projectcontributor.party_id;
3104

  
3105

  
3106
--
3107
-- Name: view_browseparty_all; Type: VIEW; Schema: public; Owner: -
3108
--
3109

  
3110
CREATE VIEW view_browseparty_all AS
3111
    (SELECT view_browseparty_classcontrib.plotevent_id, view_browseparty_classcontrib.party_id FROM view_browseparty_classcontrib UNION SELECT view_browseparty_projectcontrib.plotevent_id, view_browseparty_projectcontrib.party_id FROM view_browseparty_projectcontrib) UNION SELECT view_browseparty_obscontrib.plotevent_id, view_browseparty_obscontrib.party_id FROM view_browseparty_obscontrib;
3112

  
3113

  
3114
--
3115
-- Name: view_browseparty_all_count; Type: VIEW; Schema: public; Owner: -
3116
--
3117

  
3118
CREATE VIEW view_browseparty_all_count AS
3119
    SELECT count(1) AS countallcontrib, view_browseparty_all.party_id FROM view_browseparty_all GROUP BY view_browseparty_all.party_id;
3120

  
3121

  
3122
--
3123
-- Name: view_browseparty_classcontrib_count; Type: VIEW; Schema: public; Owner: -
3124
--
3125

  
3126
CREATE VIEW view_browseparty_classcontrib_count AS
3127
    SELECT count(1) AS countclasscontrib, view_browseparty_classcontrib.party_id FROM view_browseparty_classcontrib GROUP BY view_browseparty_classcontrib.party_id;
3128

  
3129

  
3130
--
3131
-- Name: view_browseparty_obscontrib_count; Type: VIEW; Schema: public; Owner: -
3132
--
3133

  
3134
CREATE VIEW view_browseparty_obscontrib_count AS
3135
    SELECT count(1) AS countobscontrib, view_browseparty_obscontrib.party_id FROM view_browseparty_obscontrib GROUP BY view_browseparty_obscontrib.party_id;
3136

  
3137

  
3138
--
3139
-- Name: view_browseparty_projectcontrib_count; Type: VIEW; Schema: public; Owner: -
3140
--
3141

  
3142
CREATE VIEW view_browseparty_projectcontrib_count AS
3143
    SELECT count(1) AS countprojectcontrib, view_browseparty_projectcontrib.party_id FROM view_browseparty_projectcontrib GROUP BY view_browseparty_projectcontrib.party_id;
3144

  
3145

  
3146
--
3147
-- Name: view_browseparty_all_count_combined; Type: VIEW; Schema: public; Owner: -
3148
--
3149

  
3150
CREATE VIEW view_browseparty_all_count_combined AS
3151
    SELECT view_browseparty_all_count.party_id, view_browseparty_all_count.countallcontrib, view_browseparty_classcontrib_count.countclasscontrib, view_browseparty_obscontrib_count.countobscontrib, view_browseparty_projectcontrib_count.countprojectcontrib FROM (((view_browseparty_all_count LEFT JOIN view_browseparty_classcontrib_count ON ((view_browseparty_all_count.party_id = view_browseparty_classcontrib_count.party_id))) LEFT JOIN view_browseparty_obscontrib_count ON ((view_browseparty_all_count.party_id = view_browseparty_obscontrib_count.party_id))) LEFT JOIN view_browseparty_projectcontrib_count ON ((view_browseparty_all_count.party_id = view_browseparty_projectcontrib_count.party_id))) ORDER BY view_browseparty_all_count.countallcontrib DESC;
3152

  
3153

  
3154
--
3155
-- Name: view_busrule_duplcovercode; Type: VIEW; Schema: public; Owner: -
3156
--
3157

  
3158
CREATE VIEW view_busrule_duplcovercode AS
3159
    SELECT count(1) AS count, coverindex.covermethod_id, coverindex.covercode FROM coverindex GROUP BY coverindex.covermethod_id, coverindex.covercode HAVING (count(1) > 1);
3160

  
3161

  
3162
--
3163
-- Name: view_busrule_duplstratumtype; Type: VIEW; Schema: public; Owner: -
3164
--
3165

  
3166
CREATE VIEW view_busrule_duplstratumtype AS
3167
    SELECT count(1) AS count, stratumtype.stratummethod_id, stratumtype.stratumindex FROM stratumtype GROUP BY stratumtype.stratummethod_id, stratumtype.stratumindex HAVING (count(1) > 1);
3168

  
3169

  
3170
--
3171
-- Name: view_busrule_plotsizeshape; Type: VIEW; Schema: public; Owner: -
3172
--
3173

  
3174
CREATE VIEW view_busrule_plotsizeshape AS
3175
    SELECT plotevent.project_id, (SELECT project.projectname FROM project WHERE (project.project_id = plotevent.project_id)) AS projectname, count(1) AS plotcount FROM (plot JOIN plotevent ON ((plot.plot_id = plotevent.plot_id))) WHERE ((plot.area IS NULL) AND ((plot.shape IS NULL) OR (((plot.shape)::text <> 'Plotless'::text) AND (upper((plot.shape)::text) !~~ 'RELEV%'::text)))) GROUP BY plotevent.project_id;
3176

  
3177

  
3178
--
3179
-- Name: view_reference_transl; Type: VIEW; Schema: public; Owner: -
3180
--
3181

  
3182
CREATE VIEW view_reference_transl AS
3183
    SELECT CASE WHEN (reference.shortname IS NULL) THEN CASE WHEN (reference.title IS NULL) THEN (CASE WHEN (reference.fulltext IS NULL) THEN '[poorly documented reference]'::text ELSE CASE WHEN (length(reference.fulltext) > 35) THEN (substr(reference.fulltext, 1, 32) || '...'::text) ELSE reference.fulltext END END)::character varying ELSE reference.title END ELSE reference.shortname END AS reference_id_transl, reference.reference_id FROM reference;
3184

  
3185

  
3186
--
3187
-- Name: view_commconcept_transl; Type: VIEW; Schema: public; Owner: -
3188
--
3189

  
3190
CREATE VIEW view_commconcept_transl AS
3191
    SELECT commconcept.commconcept_id, commconcept.commname_id, commconcept.commname, commconcept.reference_id, (((commconcept.commname || ' ['::text) || ((SELECT view_reference_transl.reference_id_transl FROM view_reference_transl WHERE (view_reference_transl.reference_id = commconcept.reference_id)))::text) || ']'::text) AS commconcept_id_transl FROM commconcept;
3192

  
3193

  
3194
--
3195
-- Name: view_notemb_commclass; Type: VIEW; Schema: public; Owner: -
3196
--
3197

  
3198
CREATE VIEW view_notemb_commclass AS
3199
    SELECT commclass.commclass_id, commclass.plotevent_id, commclass.inspection, commclass.tableanalysis, commclass.multivariateanalysis, commclass.classpublication_id, commclass.classnotes, commclass.commname, commclass.commcode, commclass.commframework, commclass.commlevel, commclass.classstartdate, commclass.classstopdate, commclass.emb_commclass, commclass.expertsystem, commclass.accessioncode FROM commclass WHERE (commclass.emb_commclass < 6);
3200

  
3201

  
3202
--
3203
-- Name: view_comminterp_more; Type: VIEW; Schema: public; Owner: -
3204
--
3205

  
3206
CREATE VIEW view_comminterp_more AS
3207
    SELECT commclass.plotevent_id, commclass.inspection, commclass.tableanalysis, commclass.multivariateanalysis, commclass.expertsystem, commclass.classpublication_id, commclass.classnotes, commclass.accessioncode, commclass.classstartdate, commclass.classstopdate, comminterpretation.comminterpretation_id, comminterpretation.commclass_id, comminterpretation.commconcept_id, comminterpretation.commcode, comminterpretation.commname, comminterpretation.classfit, comminterpretation.classconfidence, comminterpretation.commauthority_id, comminterpretation.notes, comminterpretation.type, comminterpretation.nomenclaturaltype, comminterpretation.emb_comminterpretation, CASE WHEN ((comminterpretation.classfit)::text = 'Absolutely wrong'::text) THEN 6 WHEN ((comminterpretation.classfit)::text = 'Understandable but wrong'::text) THEN 4 WHEN ((comminterpretation.classfit)::text = 'Reasonable or acceptable answer'::text) THEN 3 WHEN ((comminterpretation.classfit)::text = 'Good answer'::text) THEN 2 WHEN ((comminterpretation.classfit)::text = 'Absolutely correct'::text) THEN 1 ELSE 5 END AS classfitnum, CASE WHEN ((comminterpretation.classconfidence)::text = 'High'::text) THEN 1 WHEN ((comminterpretation.classconfidence)::text = 'Medium'::text) THEN 2 WHEN ((comminterpretation.classconfidence)::text = 'Low'::text) THEN 3 ELSE 4 END AS classconfidencenum FROM view_notemb_commclass commclass, comminterpretation WHERE (commclass.commclass_id = comminterpretation.commclass_id);
3208

  
3209

  
3210
--
3211
-- Name: view_csv_taxonimportance_pre; Type: VIEW; Schema: public; Owner: -
3212
--
3213

  
3214
CREATE VIEW view_csv_taxonimportance_pre AS
3215
    SELECT taxonoccurrence.plotevent_id, taxonoccurrence.authorplantname AS plant, CASE WHEN (collectiveobservation.stratum_id IS NULL) THEN '-all-'::character varying ELSE (SELECT stratumtype.stratumname FROM stratumtype, stratum WHERE ((stratum.stratumtype_id = stratumtype.stratumtype_id) AND (stratum.stratum_id = collectiveobservation.stratum_id))) END AS stratum, collectiveobservation.cover, (SELECT min((coverindex.covercode)::text) AS min FROM coverindex WHERE (((coverindex.coverpercent = collectiveobservation.cover) AND (coverindex.covermethod_id = plotevent.covermethod_id)) AND (plotevent.plotevent_id = taxonoccurrence.plotevent_id))) AS covercode_exact, (SELECT min((coverindex.covercode)::text) AS min FROM coverindex WHERE ((((coverindex.upperlimit >= collectiveobservation.cover) AND (coverindex.lowerlimit <= collectiveobservation.cover)) AND (coverindex.covermethod_id = plotevent.covermethod_id)) AND (plotevent.plotevent_id = taxonoccurrence.plotevent_id))) AS covercode_byrange, collectiveobservation.basalarea, taxonoccurrence.accessioncode FROM taxonoccurrence, collectiveobservation, view_notemb_observation plotevent WHERE ((taxonoccurrence.taxonoccurrence_id = collectiveobservation.taxonoccurrence_id) AND (taxonoccurrence.plotevent_id = plotevent.plotevent_id));
3216

  
3217

  
3218
--
3219
-- Name: view_csv_taxonimportance; Type: VIEW; Schema: public; Owner: -
3220
--
3221

  
3222
CREATE VIEW view_csv_taxonimportance AS
3223
    SELECT view_csv_taxonimportance_pre.plotevent_id, view_csv_taxonimportance_pre.plant, view_csv_taxonimportance_pre.stratum, view_csv_taxonimportance_pre.cover, CASE WHEN (view_csv_taxonimportance_pre.covercode_exact IS NULL) THEN view_csv_taxonimportance_pre.covercode_byrange ELSE view_csv_taxonimportance_pre.covercode_exact END AS covercode, view_csv_taxonimportance_pre.basalarea, view_csv_taxonimportance_pre.accessioncode FROM view_csv_taxonimportance_pre;
3224

  
3225

  
3226
--
3227
-- Name: view_dbafielddesc_notimpl; Type: VIEW; Schema: public; Owner: -
3228
--
3229

  
3230
CREATE VIEW view_dbafielddesc_notimpl AS
3231
    SELECT dba_fielddescription.dba_fielddescription_id, dba_fielddescription.tablename, (SELECT dba_tabledescription.tablelabel FROM dba_tabledescription WHERE ((dba_fielddescription.tablename)::text = (dba_tabledescription.tablename)::text) LIMIT 1) AS tablename_transl, dba_fielddescription.fieldname, dba_fielddescription.fieldlabel, dba_fielddescription.fieldmodel, dba_fielddescription.fieldnulls, CASE WHEN ((dba_fielddescription.fieldnulls)::text = 'no'::text) THEN 'required'::text ELSE 'no'::text END AS fieldnulls_transl, dba_fielddescription.fieldtype, dba_fielddescription.fieldkey, CASE WHEN ((dba_fielddescription.fieldkey)::text = 'PK'::text) THEN dba_fielddescription.fieldkey WHEN ((dba_fielddescription.fieldkey)::text = 'FK'::text) THEN dba_fielddescription.fieldkey WHEN ((dba_fielddescription.fieldmodel)::text = 'denorm'::text) THEN dba_fielddescription.fieldmodel WHEN ((dba_fielddescription.fieldmodel)::text = 'implementation'::text) THEN dba_fielddescription.fieldmodel ELSE 'n/a'::character varying END AS fieldkey_transl, dba_fielddescription.fieldreferences, dba_fielddescription.fieldlist, dba_fielddescription.fieldnotes, dba_fielddescription.fielddefinition, dba_fielddescription.fieldkeywords FROM dba_fielddescription WHERE ((lower((dba_fielddescription.fieldmodel)::text) <> 'implementation'::text) AND (lower((dba_fielddescription.fieldmodel)::text) <> 'denorm'::text)) ORDER BY dba_fielddescription.dba_fielddescription_id;
3232

  
3233

  
3234
--
3235
-- Name: view_emb_embargo_currentfullonly; Type: VIEW; Schema: public; Owner: -
3236
--
3237

  
3238
CREATE VIEW view_emb_embargo_currentfullonly AS
3239
    SELECT embargo.embargo_id, embargo.plot_id, embargo.embargoreason, embargo.defaultstatus, embargo.embargostart, embargo.embargostop FROM embargo WHERE (((embargo.defaultstatus = 6) AND (embargo.embargostart < now())) AND (embargo.embargostop > now()));
3240

  
3241

  
3242
--
3243
-- Name: view_emb_embargo_complete; Type: VIEW; Schema: public; Owner: -
3244
--
3245

  
3246
CREATE VIEW view_emb_embargo_complete AS
3247
    SELECT COALESCE(emb.defaultstatus, 0) AS currentemb, plot.plot_id FROM (plot LEFT JOIN view_emb_embargo_currentfullonly emb ON ((plot.plot_id = emb.plot_id)));
3248

  
3249

  
3250
--
3251
-- Name: view_keywprojplaces; Type: VIEW; Schema: public; Owner: -
3252
--
3253

  
3254
CREATE VIEW view_keywprojplaces AS
3255
    SELECT project.project_id, plot.stateprovince FROM plot, project, plotevent WHERE ((plot.plot_id = plotevent.plot_id) AND (project.project_id = plotevent.project_id)) GROUP BY project.project_id, plot.stateprovince;
3256

  
3257

  
3258
--
3259
-- Name: view_kwhelper_projcontrib; Type: VIEW; Schema: public; Owner: -
3260
--
3261

  
3262
CREATE VIEW view_kwhelper_projcontrib AS
3263
    SELECT project.project_id, concat((((' '::text || (COALESCE(party.givenname, ''::character varying))::text) || ' '::text) || (COALESCE(party.surname, ''::character varying))::text)) AS kw FROM party, project, projectcontributor WHERE ((party.party_id = projectcontributor.party_id) AND (project.project_id = projectcontributor.project_id)) GROUP BY project.project_id;
3264

  
3265

  
3266
--
3267
-- Name: view_kwhelper_refjournal; Type: VIEW; Schema: public; Owner: -
3268
--
3269

  
3270
CREATE VIEW view_kwhelper_refjournal AS
3271
    SELECT reference.reference_id, (((((COALESCE(referencejournal.journal, ''::character varying))::text || ' '::text) || (COALESCE(referencejournal.issn, ''::character varying))::text) || ' '::text) || (COALESCE(referencejournal.abbreviation, ''::character varying))::text) AS kw FROM reference, referencejournal WHERE (reference.referencejournal_id = referencejournal.referencejournal_id) GROUP BY reference.reference_id, referencejournal.journal, referencejournal.issn, referencejournal.abbreviation;
3272

  
3273

  
3274
--
3275
-- Name: view_kwhelper_refparty; Type: VIEW; Schema: public; Owner: -
3276
--
3277

  
3278
CREATE VIEW view_kwhelper_refparty AS
3279
    SELECT reference.reference_id, concat((((((((' '::text || (COALESCE(referenceparty.givenname, ''::character varying))::text) || ' '::text) || (COALESCE(referenceparty.surname, ''::character varying))::text) || ' '::text) || (COALESCE(referenceparty.suffix, ''::character varying))::text) || ' '::text) || (COALESCE(referenceparty.organizationname, ''::character varying))::text)) AS kw FROM referenceparty, reference, referencecontributor WHERE ((referencecontributor.referenceparty_id = referenceparty.referenceparty_id) AND (reference.reference_id = referencecontributor.reference_id)) GROUP BY reference.reference_id;
3280

  
3281

  
3282
--
3283
-- Name: view_notemb_classcontributor; Type: VIEW; Schema: public; Owner: -
3284
--
3285

  
3286
CREATE VIEW view_notemb_classcontributor AS
3287
    SELECT classcontributor.classcontributor_id, classcontributor.commclass_id, classcontributor.party_id, classcontributor.role_id, classcontributor.emb_classcontributor FROM classcontributor WHERE (classcontributor.emb_classcontributor < 6);
3288

  
3289

  
3290
--
3291
-- Name: view_notemb_comminterpretation; Type: VIEW; Schema: public; Owner: -
3292
--
3293

  
3294
CREATE VIEW view_notemb_comminterpretation AS
3295
    SELECT comminterpretation.comminterpretation_id, comminterpretation.commclass_id, comminterpretation.commconcept_id, comminterpretation.commcode, comminterpretation.commname, comminterpretation.classfit, comminterpretation.classconfidence, comminterpretation.commauthority_id, comminterpretation.notes, comminterpretation.type, comminterpretation.nomenclaturaltype, comminterpretation.emb_comminterpretation FROM comminterpretation WHERE (comminterpretation.emb_comminterpretation < 6);
3296

  
3297

  
3298
--
3299
-- Name: view_notemb_disturbanceobs; Type: VIEW; Schema: public; Owner: -
3300
--
3301

  
3302
CREATE VIEW view_notemb_disturbanceobs AS
3303
    SELECT disturbanceobs.disturbanceobs_id, disturbanceobs.plotevent_id, disturbanceobs.disturbancetype, disturbanceobs.disturbanceintensity, disturbanceobs.disturbanceage, disturbanceobs.disturbanceextent, disturbanceobs.disturbancecomment, disturbanceobs.emb_disturbanceobs FROM disturbanceobs WHERE (disturbanceobs.emb_disturbanceobs < 6);
3304

  
3305

  
3306
--
3307
-- Name: view_notemb_plot; Type: VIEW; Schema: public; Owner: -
3308
--
3309

  
3310
CREATE VIEW view_notemb_plot AS
3311
    SELECT plot.plot_id, plot.authorplotcode, plot.reference_id, plot.parent_id, plot.reallatitude, plot.reallongitude, plot.locationaccuracy, plot.confidentialitystatus, plot.confidentialityreason, plot.latitude, plot.longitude, plot.authore, plot.authorn, plot.authorzone, plot.authordatum, plot.authorlocation, plot.locationnarrative, plot.azimuth, plot.dsgpoly, plot.shape, plot.area, plot.standsize, plot.placementmethod, plot.permanence, plot.layoutnarrative, plot.elevation, plot.elevationaccuracy, plot.elevationrange, plot.slopeaspect, plot.minslopeaspect, plot.maxslopeaspect, plot.slopegradient, plot.minslopegradient, plot.maxslopegradient, plot.topoposition, plot.landform, plot.surficialdeposits, plot.rocktype, plot.stateprovince, plot.country, plot.submitter_surname, plot.submitter_givenname, plot.submitter_email, plot.notespublic, plot.notesmgt, plot.revisions, plot.dateentered, plot.emb_plot, plot.plotrationalenarrative, plot.accessioncode FROM plot WHERE (plot.emb_plot < 6);
3312

  
3313

  
3314
--
3315
-- Name: view_notemb_soilobs; Type: VIEW; Schema: public; Owner: -
3316
--
3317

  
3318
CREATE VIEW view_notemb_soilobs AS
3319
    SELECT soilobs.soilobs_id, soilobs.plotevent_id, soilobs.soilhorizon, soilobs.soildepthtop, soilobs.soildepthbottom, soilobs.soilcolor, soilobs.soilorganic, soilobs.soiltexture, soilobs.soilsand, soilobs.soilsilt, soilobs.soilclay, soilobs.soilcoarse, soilobs.soilph, soilobs.exchangecapacity, soilobs.basesaturation, soilobs.soildescription, soilobs.emb_soilobs FROM soilobs WHERE (soilobs.emb_soilobs < 6);
3320

  
3321

  
3322
--
3323
-- Name: view_notemb_stemcount; Type: VIEW; Schema: public; Owner: -
3324
--
3325

  
3326
CREATE VIEW view_notemb_stemcount AS
3327
    SELECT stemcount.stemcount_id, stemcount.collectiveobservation_id, stemcount.stemdiameter, stemcount.stemdiameteraccuracy, stemcount.stemheight, stemcount.stemheightaccuracy, stemcount.stemcount, stemcount.stemtaxonarea, stemcount.emb_stemcount FROM stemcount WHERE (stemcount.emb_stemcount < 6);
3328

  
3329

  
3330
--
3331
-- Name: view_notemb_stemlocation; Type: VIEW; Schema: public; Owner: -
3332
--
3333

  
3334
CREATE VIEW view_notemb_stemlocation AS
3335
    SELECT individualplant.individualplant_id, individualplant.stemcount_id, individualplant.stemcode, individualplant.stemxposition, individualplant.stemyposition, individualplant.stemhealth, individualplant.emb_stemlocation FROM individualplant WHERE (individualplant.emb_stemlocation < 6);
3336

  
3337

  
3338
--
3339
-- Name: view_notemb_taxonalt; Type: VIEW; Schema: public; Owner: -
3340
--
3341

  
3342
CREATE VIEW view_notemb_taxonalt AS
3343
    SELECT taxonalt.taxonalt_id, taxonalt.taxondetermination_id, taxonalt.plantconcept_id, taxonalt.taxonaltfit, taxonalt.taxonaltconfidence, taxonalt.taxonaltnotes, taxonalt.emb_taxonalt FROM taxonalt WHERE (taxonalt.emb_taxonalt < 6);
3344

  
3345

  
3346
--
3347
-- Name: view_notemb_taxonimportance; Type: VIEW; Schema: public; Owner: -
3348
--
3349

  
3350
CREATE VIEW view_notemb_taxonimportance AS
3351
    SELECT collectiveobservation.collectiveobservation_id, collectiveobservation.taxonoccurrence_id, collectiveobservation.stratum_id, collectiveobservation.cover, collectiveobservation.basalarea, collectiveobservation.biomass, collectiveobservation.inferencearea, collectiveobservation.stratumbase, collectiveobservation.stratumheight, collectiveobservation.emb_taxonimportance, collectiveobservation.covercode FROM collectiveobservation WHERE (collectiveobservation.emb_taxonimportance < 6);
3352

  
3353

  
3354
--
3355
-- Name: view_notemb_taxoninterpretation; Type: VIEW; Schema: public; Owner: -
3356
--
3357

  
3358
CREATE VIEW view_notemb_taxoninterpretation AS
3359
    SELECT taxondetermination.taxondetermination_id, taxondetermination.taxonoccurrence_id, taxondetermination.individualplant_id, taxondetermination.plantconcept_id, taxondetermination.plantname_id, taxondetermination.party_id, taxondetermination.role_id, taxondetermination.interpretationtype, taxondetermination.reference_id, taxondetermination.originalinterpretation, taxondetermination.currentinterpretation, taxondetermination.taxonfit, taxondetermination.taxonconfidence, taxondetermination.collector_id, taxondetermination.collectionnumber, taxondetermination.museum_id, taxondetermination.museumaccessionnumber, taxondetermination.grouptype, taxondetermination.notes, taxondetermination.notespublic, taxondetermination.notesmgt, taxondetermination.revisions, taxondetermination.interpretationdate, taxondetermination.collectiondate, taxondetermination.emb_taxoninterpretation, taxondetermination.accessioncode FROM taxondetermination WHERE (taxondetermination.emb_taxoninterpretation < 6);
3360

  
3361

  
3362
--
3363
-- Name: view_notemb_taxonobservation; Type: VIEW; Schema: public; Owner: -
3364
--
3365

  
3366
CREATE VIEW view_notemb_taxonobservation AS
3367
    SELECT taxonoccurrence.taxonoccurrence_id, taxonoccurrence.plotevent_id, taxonoccurrence.authorplantname, taxonoccurrence.reference_id, taxonoccurrence.taxoninferencearea, taxonoccurrence.emb_taxonobservation, taxonoccurrence.int_origplantconcept_id, taxonoccurrence.int_origplantscifull, taxonoccurrence.int_origplantscinamenoauth, taxonoccurrence.int_origplantcommon, taxonoccurrence.int_origplantcode, taxonoccurrence.int_currplantconcept_id, taxonoccurrence.int_currplantscifull, taxonoccurrence.int_currplantscinamenoauth, taxonoccurrence.int_currplantcommon, taxonoccurrence.int_currplantcode, taxonoccurrence.accessioncode FROM taxonoccurrence WHERE (taxonoccurrence.emb_taxonobservation < 6);
3368

  
3369

  
3370
--
3371
-- Name: view_observation_transl; Type: VIEW; Schema: public; Owner: -
3372
--
3373

  
3374
CREATE VIEW view_observation_transl AS
3375
    SELECT plotevent.plotevent_id, COALESCE(plotevent.authorobscode, plot.authorplotcode) AS observation_id_transl FROM view_notemb_observation plotevent, plot WHERE (plotevent.plot_id = plot.plot_id);
3376

  
3377

  
3378
--
3379
-- Name: view_party_public; Type: VIEW; Schema: public; Owner: -
3380
--
3381

  
3382
CREATE VIEW view_party_public AS
3383
    SELECT party.party_id, party.accessioncode, party.salutation, party.surname, party.givenname, party.middlename, party.organizationname, party.contactinstructions, party.email FROM (party LEFT JOIN usr ON ((party.party_id = usr.party_id))) WHERE ((usr.usr_id IS NULL) OR (usr.permission_type > 1));
3384

  
3385

  
3386
--
3387
-- Name: view_party_transl; Type: VIEW; Schema: public; Owner: -
3388
--
3389

  
3390
CREATE VIEW view_party_transl AS
3391
    SELECT CASE WHEN (party.surname IS NULL) THEN CASE WHEN (party.organizationname IS NULL) THEN '[poorly documented party]'::text ELSE ((party.organizationname)::text || ' (organization)'::text) END ELSE ((party.surname)::text || CASE WHEN (party.givenname IS NULL) THEN ''::text ELSE (', '::text || (COALESCE(party.givenname, ''::character varying))::text) END) END AS party_id_transl, party.party_id FROM party;
3392

  
3393

  
3394
--
3395
-- Name: view_plantconcept_transl; Type: VIEW; Schema: public; Owner: -
3396
--
3397

  
3398
CREATE VIEW view_plantconcept_transl AS
3399
    SELECT plantconcept.plantconcept_id, plantconcept.plantname_id, plantconcept.plantname, plantconcept.reference_id, ((((plantconcept.plantname)::text || ' ['::text) || ((SELECT view_reference_transl.reference_id_transl FROM view_reference_transl WHERE (view_reference_transl.reference_id = plantconcept.reference_id)))::text) || ']'::text) AS plantconcept_id_transl FROM plantconcept;
3400

  
3401

  
3402
--
3403
-- Name: view_plotall_withembargo; Type: VIEW; Schema: public; Owner: -
3404
--
3405

  
3406
CREATE VIEW view_plotall_withembargo AS
3407
    SELECT plot.plot_id, plot.authorplotcode, plot.reference_id, plot.parent_id, plot.reallatitude, plot.reallongitude, plot.locationaccuracy, plot.confidentialitystatus, plot.confidentialityreason, plot.latitude, plot.longitude, plot.authore, plot.authorn, plot.authorzone, plot.authordatum, plot.authorlocation, plot.locationnarrative, plot.azimuth, plot.dsgpoly, plot.shape, plot.area, plot.standsize, plot.placementmethod, plot.permanence, plot.layoutnarrative, plot.elevation, plot.elevationaccuracy, plot.elevationrange, plot.slopeaspect, plot.minslopeaspect, plot.maxslopeaspect, plot.slopegradient, plot.minslopegradient, plot.maxslopegradient, plot.topoposition, plot.landform, plot.surficialdeposits, plot.rocktype, plot.stateprovince, plot.country, plot.submitter_surname, plot.submitter_givenname, plot.submitter_email, plot.notespublic, plot.notesmgt, plot.revisions, plot.dateentered, plot.emb_plot, plot.plotrationalenarrative, plot.accessioncode, embargo.embargo_id, embargo.embargoreason, embargo.defaultstatus, embargo.embargostart, embargo.embargostop, (embargo.defaultstatus + CASE WHEN (embargo.embargostop < now()) THEN 100 ELSE 0 END) AS embstatusinclexpired FROM (plot LEFT JOIN embargo ON ((plot.plot_id = embargo.plot_id)));
3408

  
3409

  
3410
--
3411
-- Name: view_std_commnames_code; Type: VIEW; Schema: public; Owner: -
3412
--
3413

  
3414
CREATE VIEW view_std_commnames_code AS
3415
    SELECT commusage.commconcept_id, commusage.commname FROM commusage WHERE ((((commusage.classsystem)::text = 'Code'::text) AND (commusage.party_id = (SELECT party.party_id FROM party WHERE ((party.accessioncode)::text = 'VB.Py.512.NATURESERVE'::text)))) AND (commusage.usagestop IS NULL));
3416

  
3417

  
3418
--
3419
-- Name: view_std_commnames_common; Type: VIEW; Schema: public; Owner: -
3420
--
3421

  
3422
CREATE VIEW view_std_commnames_common AS
3423
    SELECT commusage.commconcept_id, commusage.commname FROM commusage WHERE ((((commusage.classsystem)::text = 'Common'::text) AND (commusage.party_id = (SELECT party.party_id FROM party WHERE ((party.accessioncode)::text = 'VB.Py.512.NATURESERVE'::text)))) AND (commusage.usagestop IS NULL));
3424

  
3425

  
3426
--
3427
-- Name: view_std_commnames_sciname; Type: VIEW; Schema: public; Owner: -
3428
--
3429

  
3430
CREATE VIEW view_std_commnames_sciname AS
3431
    SELECT commusage.commconcept_id, commusage.commname FROM commusage WHERE ((((commusage.classsystem)::text = 'Scientific'::text) AND (commusage.party_id = (SELECT party.party_id FROM party WHERE ((party.accessioncode)::text = 'VB.Py.512.NATURESERVE'::text)))) AND (commusage.usagestop IS NULL));
3432

  
3433

  
3434
--
3435
-- Name: view_std_commnames_translated; Type: VIEW; Schema: public; Owner: -
3436
--
3437

  
3438
CREATE VIEW view_std_commnames_translated AS
3439
    SELECT commusage.commconcept_id, commusage.commname FROM commusage WHERE ((((commusage.classsystem)::text = 'Translated'::text) AND (commusage.party_id = (SELECT party.party_id FROM party WHERE ((party.accessioncode)::text = 'VB.Py.512.NATURESERVE'::text)))) AND (commusage.usagestop IS NULL));
3440

  
3441

  
3442
--
3443
-- Name: view_std_plantnames_code; Type: VIEW; Schema: public; Owner: -
3444
--
3445

  
3446
CREATE VIEW view_std_plantnames_code AS
3447
    SELECT plantusage.plantconcept_id, plantusage.plantname FROM plantusage WHERE ((((plantusage.classsystem)::text = 'Code'::text) AND (plantusage.party_id = (SELECT party.party_id FROM party WHERE ((party.accessioncode)::text = 'VB.Py.511.USDANRCSPLANTS2'::text)))) AND (plantusage.usagestop IS NULL));
3448

  
3449

  
3450
--
3451
-- Name: view_std_plantnames_common; Type: VIEW; Schema: public; Owner: -
3452
--
3453

  
3454
CREATE VIEW view_std_plantnames_common AS
3455
    SELECT plantusage.plantconcept_id, plantusage.plantname FROM plantusage WHERE ((((plantusage.classsystem)::text = 'English Common'::text) AND (plantusage.party_id = (SELECT party.party_id FROM party WHERE ((party.accessioncode)::text = 'VB.Py.511.USDANRCSPLANTS2'::text)))) AND (plantusage.usagestop IS NULL));
3456

  
3457

  
3458
--
3459
-- Name: view_std_plantnames_sciname; Type: VIEW; Schema: public; Owner: -
3460
--
3461

  
3462
CREATE VIEW view_std_plantnames_sciname AS
3463
    SELECT plantusage.plantconcept_id, plantusage.plantname FROM plantusage WHERE ((((plantusage.classsystem)::text = 'Scientific'::text) AND (plantusage.party_id = (SELECT party.party_id FROM party WHERE ((party.accessioncode)::text = 'VB.Py.511.USDANRCSPLANTS2'::text)))) AND (plantusage.usagestop IS NULL));
3464

  
3465

  
3466
--
3467
-- Name: view_std_plantnames_scinamenoauth; Type: VIEW; Schema: public; Owner: -
3468
--
3469

  
3470
CREATE VIEW view_std_plantnames_scinamenoauth AS
3471
    SELECT plantusage.plantconcept_id, plantusage.plantname FROM plantusage WHERE ((((plantusage.classsystem)::text = 'Scientific without authors'::text) AND (plantusage.party_id = (SELECT party.party_id FROM party WHERE ((party.accessioncode)::text = 'VB.Py.511.USDANRCSPLANTS2'::text)))) AND (plantusage.usagestop IS NULL));
3472

  
3473

  
3474
--
3475
-- Name: view_taxoninterp_more; Type: VIEW; Schema: public; Owner: -
3476
--
3477

  
3478
CREATE VIEW view_taxoninterp_more AS
3479
    SELECT taxondetermination.taxondetermination_id, taxondetermination.taxonoccurrence_id, taxondetermination.individualplant_id, taxondetermination.plantconcept_id, taxondetermination.plantname_id, taxondetermination.party_id, taxondetermination.role_id, taxondetermination.interpretationtype, taxondetermination.reference_id, taxondetermination.originalinterpretation, taxondetermination.currentinterpretation, taxondetermination.taxonfit, taxondetermination.taxonconfidence, taxondetermination.collector_id, taxondetermination.collectionnumber, taxondetermination.museum_id, taxondetermination.museumaccessionnumber, taxondetermination.grouptype, taxondetermination.notes, taxondetermination.notespublic, taxondetermination.notesmgt, taxondetermination.revisions, taxondetermination.interpretationdate, taxondetermination.collectiondate, taxondetermination.emb_taxoninterpretation, taxondetermination.accessioncode, plantconcept.accessioncode AS pc_accessioncode, plantconcept.plantname AS pc_plantname, taxonoccurrence.plotevent_id FROM view_notemb_taxoninterpretation taxondetermination, taxonoccurrence, plantconcept WHERE ((taxonoccurrence.taxonoccurrence_id = taxondetermination.taxonoccurrence_id) AND (plantconcept.plantconcept_id = taxondetermination.plantconcept_id));
3480

  
3481

  
3482
--
3483
-- Name: view_taxonobs_withmaxcover; Type: VIEW; Schema: public; Owner: -
3484
--
3485

  
3486
CREATE VIEW view_taxonobs_withmaxcover AS
3487
    SELECT taxonoccurrence.taxonoccurrence_id, taxonoccurrence.plotevent_id, taxonoccurrence.authorplantname, taxonoccurrence.reference_id, taxonoccurrence.taxoninferencearea, taxonoccurrence.emb_taxonobservation, taxonoccurrence.int_origplantconcept_id, taxonoccurrence.int_origplantscifull, taxonoccurrence.int_origplantscinamenoauth, taxonoccurrence.int_origplantcommon, taxonoccurrence.int_origplantcode, taxonoccurrence.int_currplantconcept_id, taxonoccurrence.int_currplantscifull, taxonoccurrence.int_currplantscinamenoauth, taxonoccurrence.int_currplantcommon, taxonoccurrence.int_currplantcode, taxonoccurrence.accessioncode, (SELECT max(collectiveobservation.cover) AS max FROM collectiveobservation WHERE (collectiveobservation.taxonoccurrence_id = taxonoccurrence.taxonoccurrence_id)) AS maxcover FROM view_notemb_taxonobservation taxonoccurrence;
3488

  
3489

  
3490
--
3491
-- Name: view_taxonobs_distinctid_curr; Type: VIEW; Schema: public; Owner: -
3492
--
3493

  
3494
CREATE VIEW view_taxonobs_distinctid_curr AS
3495
    SELECT userdatasetitem.userdataset_id, taxonoccurrence.plotevent_id, taxonoccurrence.int_currplantconcept_id AS plantconcept_id, max(taxonoccurrence.maxcover) AS maxplantcover FROM view_taxonobs_withmaxcover taxonoccurrence, userdatasetitem WHERE ((taxonoccurrence.plotevent_id = userdatasetitem.itemrecord) AND ((userdatasetitem.itemtable)::text = 'plotevent'::text)) GROUP BY taxonoccurrence.int_currplantconcept_id, userdatasetitem.userdataset_id, taxonoccurrence.plotevent_id;
3496

  
3497

  
3498
--
3499
-- Name: view_taxonobs_distinctid_curr_counts; Type: VIEW; Schema: public; Owner: -
3500
--
3501

  
3502
CREATE VIEW view_taxonobs_distinctid_curr_counts AS
3503
    SELECT view_taxonobs_distinctid_curr.userdataset_id, view_taxonobs_distinctid_curr.plantconcept_id, count(1) AS countobs, avg(view_taxonobs_distinctid_curr.maxplantcover) AS avgcovernoround, min(view_taxonobs_distinctid_curr.maxplantcover) AS mincovernoround, max(view_taxonobs_distinctid_curr.maxplantcover) AS maxcovernoround FROM view_taxonobs_distinctid_curr GROUP BY view_taxonobs_distinctid_curr.userdataset_id, view_taxonobs_distinctid_curr.plantconcept_id;
3504

  
3505

  
3506
--
3507
-- Name: view_taxonobs_distinctid_curr_counts_plants; Type: VIEW; Schema: public; Owner: -
3508
--
3509

  
3510
CREATE VIEW view_taxonobs_distinctid_curr_counts_plants AS
3511
    SELECT view_taxonobs_distinctid_curr_counts.userdataset_id, view_taxonobs_distinctid_curr_counts.plantconcept_id, view_taxonobs_distinctid_curr_counts.countobs, view_taxonobs_distinctid_curr_counts.avgcovernoround, view_taxonobs_distinctid_curr_counts.mincovernoround, view_taxonobs_distinctid_curr_counts.maxcovernoround, round((view_taxonobs_distinctid_curr_counts.avgcovernoround)::numeric, 3) AS avgcover, round((view_taxonobs_distinctid_curr_counts.mincovernoround)::numeric, 3) AS mincover, round((view_taxonobs_distinctid_curr_counts.maxcovernoround)::numeric, 3) AS maxcover, temptbl_std_plantnames.plantname, temptbl_std_plantnames.sciname, temptbl_std_plantnames.scinamenoauth, temptbl_std_plantnames.code, temptbl_std_plantnames.common FROM temptbl_std_plantnames, view_taxonobs_distinctid_curr_counts WHERE (view_taxonobs_distinctid_curr_counts.plantconcept_id = temptbl_std_plantnames.plantconcept_id);
3512

  
3513

  
3514
--
3515 3011
-- Name: address_id; Type: DEFAULT; Schema: public; Owner: -
3516 3012
--
3517 3013

  
......
3718 3214
-- Name: individualplant_id; Type: DEFAULT; Schema: public; Owner: -
3719 3215
--
3720 3216

  
3721
ALTER TABLE individualplant ALTER COLUMN individualplant_id SET DEFAULT nextval('stemlocation_stemlocation_id_seq'::regclass);
3217
ALTER TABLE individualplant ALTER COLUMN individualplant_id SET DEFAULT nextval('individualplant_individualplant_id_seq'::regclass);
3722 3218

  
3723 3219

  
3724 3220
--
......
3911 3407

  
3912 3408

  
3913 3409
--
3914
-- Name: stemcount_id; Type: DEFAULT; Schema: public; Owner: -
3410
-- Name: stemobservation_id; Type: DEFAULT; Schema: public; Owner: -
3915 3411
--
3916 3412

  
3917
ALTER TABLE stemcount ALTER COLUMN stemcount_id SET DEFAULT nextval('stemcount_stemcount_id_seq'::regclass);
3413
ALTER TABLE stemobservation ALTER COLUMN stemobservation_id SET DEFAULT nextval('stemlocation_stemlocation_id_seq'::regclass);
3918 3414

  
3919 3415

  
3920 3416
--
......
4290 3786

  
4291 3787

  
4292 3788
--
3789
-- Name: individualplant_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3790
--
3791

  
3792
ALTER TABLE ONLY individualplant
3793
    ADD CONSTRAINT individualplant_pkey PRIMARY KEY (individualplant_id);
3794

  
3795

  
3796
--
4293 3797
-- Name: namedplace_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4294 3798
--
4295 3799

  
......
4506 4010

  
4507 4011

  
4508 4012
--
4509
-- Name: stemcount_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4510
--
4511

  
4512
ALTER TABLE ONLY stemcount
4513
    ADD CONSTRAINT stemcount_pkey PRIMARY KEY (stemcount_id);
4514

  
4515

  
4516
--
4517 4013
-- Name: stemlocation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4518 4014
--
4519 4015

  
4520
ALTER TABLE ONLY individualplant
4521
    ADD CONSTRAINT stemlocation_pkey PRIMARY KEY (individualplant_id);
4016
ALTER TABLE ONLY stemobservation
4017
    ADD CONSTRAINT stemlocation_pkey PRIMARY KEY (stemobservation_id);
4522 4018

  
4523 4019

  
4524 4020
--
......
4999 4495

  
5000 4496

  
5001 4497
--
4498
-- Name: emb_individualplant_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4499
--
4500

  
4501
CREATE INDEX emb_individualplant_idx ON individualplant USING btree (emb_individualplant);
4502

  
4503

  
4504
--
5002 4505
-- Name: emb_observation_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5003 4506
--
5004 4507

  
......
5020 4523

  
5021 4524

  
5022 4525
--
5023
-- Name: emb_stemcount_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5024
--
5025

  
5026
CREATE INDEX emb_stemcount_idx ON stemcount USING btree (emb_stemcount);
5027

  
5028

  
5029
--
5030 4526
-- Name: emb_stemlocation_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5031 4527
--
5032 4528

  
5033
CREATE INDEX emb_stemlocation_idx ON individualplant USING btree (emb_stemlocation);
4529
CREATE INDEX emb_stemlocation_idx ON stemobservation USING btree (emb_stemlocation);
5034 4530

  
5035 4531

  
5036 4532
--
......
5083 4579

  
5084 4580

  
5085 4581
--
4582
-- Name: individualplant_taxonimportance_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4583
--
4584

  
4585
CREATE INDEX individualplant_taxonimportance_id_x ON individualplant USING btree (collectiveobservation_id);
4586

  
4587

  
4588
--
5086 4589
-- Name: keywords_table_id_entity_key; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5087 4590
--
5088 4591

  
......
5573 5076

  
5574 5077

  
5575 5078
--
5576
-- Name: stemcount_taxonimportance_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5079
-- Name: stemlocation_individualplant_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5577 5080
--
5578 5081

  
5579
CREATE INDEX stemcount_taxonimportance_id_x ON stemcount USING btree (collectiveobservation_id);
5082
CREATE INDEX stemlocation_individualplant_id_x ON stemobservation USING btree (individualplant_id);
5580 5083

  
5581 5084

  
5582 5085
--
5583
-- Name: stemlocation_stemcount_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5584
--
5585

  
5586
CREATE INDEX stemlocation_stemcount_id_x ON individualplant USING btree (stemcount_id);
5587

  
5588

  
5589
--
5590 5086
-- Name: stratum_observation_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5591 5087
--
5592 5088

  
......
5716 5212
-- Name: taxoninterpretation_stemlocation_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5717 5213
--
5718 5214

  
5719
CREATE INDEX taxoninterpretation_stemlocation_id_x ON taxondetermination USING btree (individualplant_id);
5215
CREATE INDEX taxoninterpretation_stemlocation_id_x ON taxondetermination USING btree (stemobservation_id);
5720 5216

  
5721 5217

  
5722 5218
--
......
5881 5377

  
5882 5378

  
5883 5379
--
5884
-- Name: collection_individualplant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5380
-- Name: collection_stemobservation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5885 5381
--
5886 5382

  
5887 5383
ALTER TABLE ONLY collection
5888
    ADD CONSTRAINT collection_individualplant_id_fkey FOREIGN KEY (individualplant_id) REFERENCES individualplant(individualplant_id);
5384
    ADD CONSTRAINT collection_stemobservation_id_fkey FOREIGN KEY (stemobservation_id) REFERENCES stemobservation(stemobservation_id);
5889 5385

  
5890 5386

  
5891 5387
--
......
6017 5513

  
6018 5514

  
6019 5515
--
5516
-- Name: r1individualplant_taxonimportance_id; Type: FK CONSTRAINT; Schema: public; Owner: -
5517
--
5518

  
5519
ALTER TABLE ONLY individualplant
5520
    ADD CONSTRAINT r1individualplant_taxonimportance_id FOREIGN KEY (collectiveobservation_id) REFERENCES collectiveobservation(collectiveobservation_id);
5521

  
5522

  
5523
--
6020 5524
-- Name: r1namedplace_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6021 5525
--
6022 5526

  
......
6209 5713

  
6210 5714

  
6211 5715
--
6212
-- Name: r1stemcount_taxonimportance_id; Type: FK CONSTRAINT; Schema: public; Owner: -
5716
-- Name: r1stemlocation_individualplant_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6213 5717
--
6214 5718

  
6215
ALTER TABLE ONLY stemcount
6216
    ADD CONSTRAINT r1stemcount_taxonimportance_id FOREIGN KEY (collectiveobservation_id) REFERENCES collectiveobservation(collectiveobservation_id);
5719
ALTER TABLE ONLY stemobservation
5720
    ADD CONSTRAINT r1stemlocation_individualplant_id FOREIGN KEY (individualplant_id) REFERENCES individualplant(individualplant_id);
6217 5721

  
6218 5722

  
6219 5723
--
6220
-- Name: r1stemlocation_stemcount_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6221
--
6222

  
6223
ALTER TABLE ONLY individualplant
6224
    ADD CONSTRAINT r1stemlocation_stemcount_id FOREIGN KEY (stemcount_id) REFERENCES stemcount(stemcount_id);
6225

  
6226

  
6227
--
6228 5724
-- Name: r1stratum_observation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6229 5725
--
6230 5726

  
......
6589 6085
--
6590 6086

  
6591 6087
ALTER TABLE ONLY taxondetermination
6592
    ADD CONSTRAINT r2taxoninterpretation_stemlocation_id FOREIGN KEY (individualplant_id) REFERENCES individualplant(individualplant_id);
6088
    ADD CONSTRAINT r2taxoninterpretation_stemlocation_id FOREIGN KEY (stemobservation_id) REFERENCES stemobservation(stemobservation_id);
6593 6089

  
6594 6090

  
6595 6091
--

Also available in: Unified diff