Project

General

Profile

« Previous | Next » 

Revision 14611

schemas/public_.sql: views that use view_full_occurrence_individual_view: use the view_full_occurrence_individual table instead, now that this is materialized.

View differences:

vegbien.sql
8144 8144

  
8145 8145

  
8146 8146
--
8147
-- Name: coordinates; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8148
--
8149

  
8150
CREATE TABLE coordinates (
8151
    coordinates_id integer NOT NULL,
8152
    source_id integer NOT NULL,
8153
    latitude_deg double precision NOT NULL,
8154
    longitude_deg double precision NOT NULL,
8155
    verbatimlatitude text,
8156
    verbatimlongitude text,
8157
    verbatimcoordinates text,
8158
    footprintgeometry_dwc text,
8159
    coordsaccuracy_m double precision
8160
);
8161

  
8162

  
8163
--
8164
-- Name: COLUMN coordinates.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
8165
--
8166

  
8167
COMMENT ON COLUMN coordinates.footprintgeometry_dwc IS '
8168
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).
8169
';
8170

  
8171

  
8172
--
8173
-- Name: COLUMN coordinates.coordsaccuracy_m; Type: COMMENT; Schema: public; Owner: -
8174
--
8175

  
8176
COMMENT ON COLUMN coordinates.coordsaccuracy_m IS '
8177
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.
8178
';
8179

  
8180

  
8181
--
8182
-- Name: cultivated_family_locations; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8183
--
8184

  
8185
CREATE TABLE cultivated_family_locations (
8186
    family text NOT NULL,
8187
    country text NOT NULL
8188
);
8189

  
8190

  
8191
--
8192
-- Name: TABLE cultivated_family_locations; Type: COMMENT; Schema: public; Owner: -
8193
--
8194

  
8195
COMMENT ON TABLE cultivated_family_locations IS '
8196
from sftp://nimoy.nceas.ucsb.edu/home/bien/bien2_scripts/geoscrub/cultivated/cult_by_taxon/flag_by_taxa.inc
8197
';
8198

  
8199

  
8200
--
8201
-- Name: family_higher_plant_group; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8202
--
8203

  
8204
CREATE TABLE family_higher_plant_group (
8205
    family text NOT NULL,
8206
    higher_plant_group higher_plant_group
8207
);
8208

  
8209

  
8210
--
8211
-- Name: location; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8212
--
8213

  
8214
CREATE TABLE location (
8215
    location_id integer NOT NULL,
8216
    source_id integer NOT NULL,
8217
    sourceaccessioncode text,
8218
    plot_location_id integer NOT NULL,
8219
    parent_id integer,
8220
    authorlocationcode text,
8221
    place_id integer,
8222
    accesslevel accesslevel,
8223
    accessconditions text,
8224
    sublocationxposition_m double precision,
8225
    sublocationyposition_m double precision,
8226
    iscultivated boolean,
8227
    authorzone text,
8228
    authordatum text,
8229
    authorlocation text,
8230
    locationnarrative text,
8231
    azimuth double precision,
8232
    shape text,
8233
    area_m2 double precision,
8234
    standsize text,
8235
    placementmethod text,
8236
    permanence boolean,
8237
    layoutnarrative text,
8238
    elevation_m double precision,
8239
    elevationaccuracy_m double precision,
8240
    elevationrange_m double precision,
8241
    verbatimelevation text,
8242
    slopeaspect_deg double precision,
8243
    minslopeaspect_deg double precision,
8244
    maxslopeaspect_deg double precision,
8245
    slopegradient_fraction double precision,
8246
    minslopegradient_fraction double precision,
8247
    maxslopegradient_fraction double precision,
8248
    topoposition text,
8249
    landform text,
8250
    surficialdeposits text,
8251
    rocktype text,
8252
    submitter_surname text,
8253
    submitter_givenname text,
8254
    submitter_email text,
8255
    notespublic boolean,
8256
    notesmgt boolean,
8257
    revisions boolean,
8258
    dateentered date DEFAULT now(),
8259
    locationrationalenarrative text,
8260
    CONSTRAINT location_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (authorlocationcode IS NOT NULL)))
8261
);
8262

  
8263

  
8264
--
8265
-- Name: TABLE location; Type: COMMENT; Schema: public; Owner: -
8266
--
8267

  
8268
COMMENT ON TABLE location IS '
8269
Equivalent to VegBank''s plot table.
8270

  
8271
`CREATE INDEX plot_source_id` runtime: 5 min ("295235 ms") @vegbiendev
8272
';
8273

  
8274

  
8275
--
8276
-- Name: COLUMN location.plot_location_id; Type: COMMENT; Schema: public; Owner: -
8277
--
8278

  
8279
COMMENT ON COLUMN location.plot_location_id IS '
8280
autopopulated
8281
';
8282

  
8283

  
8284
--
8285
-- Name: locationevent; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8286
--
8287

  
8288
CREATE TABLE locationevent (
8289
    locationevent_id integer NOT NULL,
8290
    source_id integer NOT NULL,
8291
    sourceaccessioncode text,
8292
    accesslevel accesslevel,
8293
    place_visit_id integer NOT NULL,
8294
    parent_id integer,
8295
    plot_id integer,
8296
    location_id integer,
8297
    project_id integer,
8298
    stratum_id integer,
8299
    authoreventcode text,
8300
    previous_id integer,
8301
    obsstartdate date,
8302
    obsenddate date,
8303
    dateaccuracy text,
8304
    method_id integer,
8305
    temperature_c double precision,
8306
    precipitation_m double precision,
8307
    autotaxoncover boolean,
8308
    originaldata text,
8309
    effortlevel text,
8310
    floristicquality text,
8311
    bryophytequality text,
8312
    lichenquality text,
8313
    locationeventnarrative text,
8314
    landscapenarrative text,
8315
    homogeneity text,
8316
    phenologicaspect text,
8317
    representativeness text,
8318
    standmaturity text,
8319
    successionalstatus text,
8320
    basalarea double precision,
8321
    hydrologicregime text,
8322
    soilmoistureregime text,
8323
    soildrainage text,
8324
    watersalinity text,
8325
    waterdepth_m double precision,
8326
    shoredistance double precision,
8327
    soildepth double precision,
8328
    organicdepth double precision,
8329
    soiltaxon_id integer,
8330
    soiltaxonsrc text,
8331
    percentbedrock double precision,
8332
    percentrockgravel double precision,
8333
    percentwood double precision,
8334
    percentlitter double precision,
8335
    percentbaresoil double precision,
8336
    percentwater double precision,
8337
    percentother double precision,
8338
    nameother text,
8339
    treeht double precision,
8340
    shrubht double precision,
8341
    fieldht double precision,
8342
    nonvascularht double precision,
8343
    submergedht double precision,
8344
    treecover double precision,
8345
    shrubcover double precision,
8346
    fieldcover double precision,
8347
    nonvascularcover double precision,
8348
    floatingcover double precision,
8349
    submergedcover double precision,
8350
    dominantstratum text,
8351
    growthform1type text,
8352
    growthform2type text,
8353
    growthform3type text,
8354
    growthform1cover double precision,
8355
    growthform2cover double precision,
8356
    growthform3cover double precision,
8357
    totalcover double precision,
8358
    notespublic boolean,
8359
    notesmgt boolean,
8360
    revisions boolean,
8361
    dateentered date DEFAULT now(),
8362
    toptaxon1name text,
8363
    toptaxon2name text,
8364
    toptaxon3name text,
8365
    toptaxon4name text,
8366
    toptaxon5name text,
8367
    numberoftaxa integer,
8368
    CONSTRAINT locationevent_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (location_id IS NOT NULL)))
8369
);
8370

  
8371

  
8372
--
8373
-- Name: TABLE locationevent; Type: COMMENT; Schema: public; Owner: -
8374
--
8375

  
8376
COMMENT ON TABLE locationevent IS '
8377
Equivalent to VegBank''s observation table.
8378

  
8379
`VACUUM ANALYZE VERBOSE locationevent` runtime: 20 min ("1188590 ms") @vegbiendev
8380
`CREATE INDEX locationevent_place_visit_id` runtime: 3 min ("179139 ms") @vegbiendev
8381
`UPDATE locationevent SET place_visit_id = place_visit_id` runtime: >~1 h @vegbiendev
8382
';
8383

  
8384

  
8385
--
8386
-- Name: COLUMN locationevent.place_visit_id; Type: COMMENT; Schema: public; Owner: -
8387
--
8388

  
8389
COMMENT ON COLUMN locationevent.place_visit_id IS '
8390
autopopulated
8391
';
8392

  
8393

  
8394
--
8395
-- Name: COLUMN locationevent.plot_id; Type: COMMENT; Schema: public; Owner: -
8396
--
8397

  
8398
COMMENT ON COLUMN locationevent.plot_id IS '
8399
autopopulated
8400
';
8401

  
8402

  
8403
--
8404
-- Name: method; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8405
--
8406

  
8407
CREATE TABLE method (
8408
    method_id integer NOT NULL,
8409
    source_id integer NOT NULL,
8410
    name text,
8411
    description text,
8412
    diameterheight_m double precision,
8413
    mindiameter_m double precision,
8414
    maxdiameter_m double precision,
8415
    minheight_m double precision,
8416
    maxheight_m double precision,
8417
    observationtype text,
8418
    observationmeasure text,
8419
    covermethod_id integer,
8420
    samplingfactor double precision DEFAULT 1 NOT NULL,
8421
    coverbasis text,
8422
    stemsamplemethod text,
8423
    shape text,
8424
    length_m double precision,
8425
    width_m double precision,
8426
    radius_m double precision,
8427
    area_m2 double precision,
8428
    samplearea_m2 double precision,
8429
    subplotspacing_m double precision,
8430
    subplotmethod_id integer,
8431
    pointsperline integer,
8432
    CONSTRAINT method_required_key CHECK ((((name IS NOT NULL) OR (description IS NOT NULL)) OR (observationmeasure IS NOT NULL)))
8433
);
8434

  
8435

  
8436
--
8437
-- Name: TABLE method; Type: COMMENT; Schema: public; Owner: -
8438
--
8439

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

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

  
8446

  
8447
--
8448
-- Name: COLUMN method.source_id; Type: COMMENT; Schema: public; Owner: -
8449
--
8450

  
8451
COMMENT ON COLUMN method.source_id IS '
8452
Use the source table (e.g. source.url) to store a link to the original plain text description.
8453
';
8454

  
8455

  
8456
--
8457
-- Name: COLUMN method.name; Type: COMMENT; Schema: public; Owner: -
8458
--
8459

  
8460
COMMENT ON COLUMN method.name IS '
8461
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.
8462
';
8463

  
8464

  
8465
--
8466
-- Name: COLUMN method.description; Type: COMMENT; Schema: public; Owner: -
8467
--
8468

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

  
8473

  
8474
--
8475
-- Name: COLUMN method.diameterheight_m; Type: COMMENT; Schema: public; Owner: -
8476
--
8477

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

  
8482

  
8483
--
8484
-- Name: COLUMN method.mindiameter_m; Type: COMMENT; Schema: public; Owner: -
8485
--
8486

  
8487
COMMENT ON COLUMN method.mindiameter_m IS '
8488
Lower diameter limit in m for inclusion of a tree.
8489
';
8490

  
8491

  
8492
--
8493
-- Name: COLUMN method.maxdiameter_m; Type: COMMENT; Schema: public; Owner: -
8494
--
8495

  
8496
COMMENT ON COLUMN method.maxdiameter_m IS '
8497
Upper diameter limit in m for inclusion of a tree.
8498
';
8499

  
8500

  
8501
--
8502
-- Name: COLUMN method.minheight_m; Type: COMMENT; Schema: public; Owner: -
8503
--
8504

  
8505
COMMENT ON COLUMN method.minheight_m IS '
8506
Lower height limit in m for inclusion of a tree.
8507
';
8508

  
8509

  
8510
--
8511
-- Name: COLUMN method.maxheight_m; Type: COMMENT; Schema: public; Owner: -
8512
--
8513

  
8514
COMMENT ON COLUMN method.maxheight_m IS '
8515
Upper height limit in m for inclusion of a tree.
8516
';
8517

  
8518

  
8519
--
8520
-- Name: COLUMN method.observationtype; Type: COMMENT; Schema: public; Owner: -
8521
--
8522

  
8523
COMMENT ON COLUMN method.observationtype IS '
8524
values: aggregate, individual, both
8525
';
8526

  
8527

  
8528
--
8529
-- Name: COLUMN method.observationmeasure; Type: COMMENT; Schema: public; Owner: -
8530
--
8531

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

  
8536

  
8537
--
8538
-- Name: COLUMN method.samplingfactor; Type: COMMENT; Schema: public; Owner: -
8539
--
8540

  
8541
COMMENT ON COLUMN method.samplingfactor IS '
8542
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.
8543
';
8544

  
8545

  
8546
--
8547
-- Name: COLUMN method.coverbasis; Type: COMMENT; Schema: public; Owner: -
8548
--
8549

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

  
8553
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.
8554

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

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

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

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

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

  
8566

  
8567
--
8568
-- Name: COLUMN method.stemsamplemethod; Type: COMMENT; Schema: public; Owner: -
8569
--
8570

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

  
8574
e.g.:
8575
Full census
8576
Point quarter
8577
Random pairs
8578
Bitterlich
8579
Other
8580
Subsample census
8581
';
8582

  
8583

  
8584
--
8585
-- Name: COLUMN method.shape; Type: COMMENT; Schema: public; Owner: -
8586
--
8587

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

  
8592

  
8593
--
8594
-- Name: COLUMN method.samplearea_m2; Type: COMMENT; Schema: public; Owner: -
8595
--
8596

  
8597
COMMENT ON COLUMN method.samplearea_m2 IS '
8598
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.
8599
';
8600

  
8601

  
8602
--
8603
-- Name: COLUMN method.subplotspacing_m; Type: COMMENT; Schema: public; Owner: -
8604
--
8605

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

  
8610

  
8611
--
8612
-- Name: COLUMN method.subplotmethod_id; Type: COMMENT; Schema: public; Owner: -
8613
--
8614

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

  
8619

  
8620
--
8621
-- Name: COLUMN method.pointsperline; Type: COMMENT; Schema: public; Owner: -
8622
--
8623

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

  
8628

  
8629
--
8630
-- Name: party; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8631
--
8632

  
8633
CREATE TABLE party (
8634
    party_id integer NOT NULL,
8635
    source_id integer NOT NULL,
8636
    sourceaccessioncode text,
8637
    fullname text,
8638
    salutation text,
8639
    givenname text,
8640
    middlename text,
8641
    surname text,
8642
    suffix text,
8643
    department text,
8644
    organizationname text,
8645
    currentname_id integer,
8646
    contactinstructions text,
8647
    email text,
8648
    partytype text,
8649
    partypublic boolean DEFAULT true,
8650
    CONSTRAINT party_required_key CHECK (((organizationname IS NOT NULL) OR ((source_id <> party_id) AND ((fullname IS NOT NULL) OR (surname IS NOT NULL)))))
8651
);
8652

  
8653

  
8654
--
8655
-- Name: plantobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8656
--
8657

  
8658
CREATE TABLE plantobservation (
8659
    plantobservation_id integer NOT NULL,
8660
    source_id integer NOT NULL,
8661
    sourceaccessioncode text,
8662
    aggregateoccurrence_id integer,
8663
    overallheight_m double precision,
8664
    overallheightaccuracy_m double precision,
8665
    authorplantcode text,
8666
    stemcount integer,
8667
    reproductivecondition text,
8668
    plant_id integer,
8669
    CONSTRAINT plantobservation_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (aggregateoccurrence_id IS NOT NULL)))
8670
);
8671

  
8672

  
8673
--
8674
-- Name: TABLE plantobservation; Type: COMMENT; Schema: public; Owner: -
8675
--
8676

  
8677
COMMENT ON TABLE plantobservation IS '
8678
Equivalent to VegBank''s stemcount table.
8679
';
8680

  
8681

  
8682
--
8683
-- Name: COLUMN plantobservation.authorplantcode; Type: COMMENT; Schema: public; Owner: -
8684
--
8685

  
8686
COMMENT ON COLUMN plantobservation.authorplantcode IS '
8687
The number of the organism within the data collection or event.
8688
';
8689

  
8690

  
8691
--
8692
-- Name: project; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8693
--
8694

  
8695
CREATE TABLE project (
8696
    project_id integer NOT NULL,
8697
    source_id integer NOT NULL,
8698
    sourceaccessioncode text,
8699
    projectname text,
8700
    projectdescription text,
8701
    startdate date,
8702
    stopdate date,
8703
    CONSTRAINT project_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (projectname IS NOT NULL)))
8704
);
8705

  
8706

  
8707
--
8708
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace: 
8709
--
8710

  
8711
CREATE TABLE stratum (
8712
    stratum_id integer NOT NULL,
8713
    source_id integer NOT NULL,
8714
    stratumname text NOT NULL,
8715
    stratumheight double precision,
8716
    stratumbase double precision,
8717
    stratumcover double precision,
8718
    area double precision,
8719
    method_id integer
8720
);
8721

  
8722

  
8723
--
8724
-- Name: plot.**; Type: VIEW; Schema: public; Owner: -
8725
--
8726

  
8727
CREATE VIEW "plot.**" AS
8728
 SELECT source.shortname AS datasource,
8729
    COALESCE(geoscrub_output."acceptedCountry", place.country) AS country,
8730
    COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince) AS state_province,
8731
    COALESCE(geoscrub_output."acceptedCounty", place.county) AS county,
8732
    location.locationnarrative AS locality,
8733
        CASE
8734
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.latitude_deg
8735
            ELSE county_centroids."decimalLatitude"
8736
        END AS latitude,
8737
        CASE
8738
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.longitude_deg
8739
            ELSE county_centroids."decimalLongitude"
8740
        END AS longitude,
8741
        CASE
8742
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.coordsaccuracy_m
8743
            ELSE _km_to_m(county_centroids."*error_km")
8744
        END AS coord_uncertainty_m,
8745
        CASE
8746
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN 'source data'::coordinatesource
8747
            WHEN (county_centroids."*row_num" IS NOT NULL) THEN 'georeferencing'::coordinatesource
8748
            ELSE NULL::coordinatesource
8749
        END AS georef_sources,
8750
        CASE
8751
            WHEN (coordinates.latitude_deg IS NOT NULL) THEN NULL::text
8752
            WHEN (county_centroids."*row_num" IS NOT NULL) THEN 'county centroid'::text
8753
            ELSE NULL::text
8754
        END AS georef_protocol,
8755
    (geoscrub_output.geovalid)::integer AS is_geovalid,
8756
    ("newWorldCountries"."isNewWorld")::integer AS is_new_world,
8757
    COALESCE(project.sourceaccessioncode, project.projectname) AS project_id,
8758
    ARRAY( SELECT project_contributors(project.project_id) AS project_contributors) AS project_contributors,
8759
    COALESCE(location.sourceaccessioncode, NULLIF(concat_ws('; '::text, COALESCE(parent_location.sourceaccessioncode, parent_location.authorlocationcode), location.authorlocationcode), ''::text)) AS location_id,
8760
    COALESCE(parent_location.authorlocationcode, location.authorlocationcode) AS plot_name,
8761
        CASE
8762
            WHEN (parent_location.location_id IS NOT NULL) THEN location.authorlocationcode
8763
            ELSE NULL::text
8764
        END AS subplot,
8765
    location.iscultivated AS is_location_cultivated,
8766
    locationevent.locationevent_id,
8767
    COALESCE(locationevent.obsstartdate, parent_event.obsstartdate) AS event_date,
8768
    COALESCE(location.elevation_m, parent_location.elevation_m) AS elevation_m,
8769
    COALESCE(location.slopeaspect_deg, parent_location.slopeaspect_deg) AS slope_aspect_deg,
8770
    COALESCE(location.slopegradient_fraction, parent_location.slopegradient_fraction) AS slope_gradient_deg,
8771
    _m2_to_ha(COALESCE(location.area_m2, parent_location.area_m2)) AS plot_area_ha,
8772
    method.name AS sampling_protocol,
8773
    COALESCE(locationevent.temperature_c, parent_event.temperature_c) AS temperature_c,
8774
    COALESCE(locationevent.precipitation_m, parent_event.precipitation_m) AS precip_mm,
8775
    stratum.stratumname AS stratum_name,
8776
    COALESCE(locationevent__communities__array(locationevent.locationevent_id), locationevent__communities__array(parent_event.locationevent_id)) AS community_concept_name,
8777
    COALESCE(locationevent__contributors__array(locationevent.locationevent_id), locationevent__contributors__array(parent_event.locationevent_id)) AS observation_contributors
8778
   FROM (((((((((((((source
8779
   JOIN location USING (source_id))
8780
   LEFT JOIN locationevent USING (location_id))
8781
   LEFT JOIN place USING (place_id))
8782
   LEFT JOIN location parent_location ON ((parent_location.location_id = location.parent_id)))
8783
   LEFT JOIN coordinates USING (coordinates_id))
8784
   LEFT JOIN geoscrub.geoscrub_output ON ((((((ARRAY[geoscrub_output."decimalLatitude"] = ARRAY[coordinates.latitude_deg]) AND (ARRAY[geoscrub_output."decimalLongitude"] = ARRAY[coordinates.longitude_deg])) AND (ARRAY[geoscrub_output.country] = ARRAY[place.country])) AND (ARRAY[geoscrub_output."stateProvince"] = ARRAY[place.stateprovince])) AND (ARRAY[geoscrub_output.county] = ARRAY[place.county]))))
8785
   LEFT JOIN "newWorld".iso_code_gadm ON ((iso_code_gadm."*GADM country" = COALESCE(geoscrub_output."acceptedCountry", place.country))))
8786
   LEFT JOIN "newWorld"."newWorldCountries" ON (("newWorldCountries"."*isoCode" = iso_code_gadm."*2-digit iso code")))
8787
   LEFT JOIN geoscrub.county_centroids ON ((((place.country = 'United States'::text) AND (county_centroids."stateProvince" = COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince))) AND (county_centroids.county = COALESCE(geoscrub_output."acceptedCounty", place.county)))))
8788
   LEFT JOIN locationevent parent_event ON ((parent_event.locationevent_id = locationevent.parent_id)))
8789
   LEFT JOIN project ON ((project.project_id = COALESCE(locationevent.project_id, parent_event.project_id))))
8790
   LEFT JOIN stratum ON ((stratum.stratum_id = COALESCE(locationevent.stratum_id, parent_event.stratum_id))))
8791
   LEFT JOIN method ON ((method.method_id = COALESCE(locationevent.method_id, parent_event.method_id))));
8792

  
8793

  
8794
--
8795
-- Name: COLUMN "plot.**".datasource; Type: COMMENT; Schema: public; Owner: -
8796
--
8797

  
8798
COMMENT ON COLUMN "plot.**".datasource IS '"the person [or] institution that provided the data [to this database] (the *proximate* data provider)"';
8799

  
8800

  
8801
--
8802
-- Name: COLUMN "plot.**".country; Type: COMMENT; Schema: public; Owner: -
8803
--
8804

  
8805
COMMENT ON COLUMN "plot.**".country IS 'http://geoscrub.geoscrub_output.acceptedCountry__@VegBIEN__@vegpath.org;
8806
"The name of the country or major administrative unit in which the Location occurs"';
8807

  
8808

  
8809
--
8810
-- Name: COLUMN "plot.**".state_province; Type: COMMENT; Schema: public; Owner: -
8811
--
8812

  
8813
COMMENT ON COLUMN "plot.**".state_province IS '"The name of the next smaller administrative region than country (state, province, canton, department, region, etc.) in which the Location occurs"';
8814

  
8815

  
8816
--
8817
-- Name: COLUMN "plot.**".county; Type: COMMENT; Schema: public; Owner: -
8818
--
8819

  
8820
COMMENT ON COLUMN "plot.**".county IS '"The full, unabbreviated name of the next smaller administrative region than stateProvince (county, shire, department, etc.) in which the Location occurs"';
8821

  
8822

  
8823
--
8824
-- Name: COLUMN "plot.**".locality; Type: COMMENT; Schema: public; Owner: -
8825
--
8826

  
8827
COMMENT ON COLUMN "plot.**".locality IS '"The specific description of the place"';
8828

  
8829

  
8830
--
8831
-- Name: COLUMN "plot.**".latitude; Type: COMMENT; Schema: public; Owner: -
8832
--
8833

  
8834
COMMENT ON COLUMN "plot.**".latitude IS '"The geographic latitude (in decimal degrees, using the spatial reference system given in geodeticDatum) of the geographic center of a Location"';
8835

  
8836

  
8837
--
8838
-- Name: COLUMN "plot.**".longitude; Type: COMMENT; Schema: public; Owner: -
8839
--
8840

  
8841
COMMENT ON COLUMN "plot.**".longitude IS '"The geographic longitude (in decimal degrees, using the spatial reference system given in geodeticDatum) of the geographic center of a Location"';
8842

  
8843

  
8844
--
8845
-- Name: COLUMN "plot.**".coord_uncertainty_m; Type: COMMENT; Schema: public; Owner: -
8846
--
8847

  
8848
COMMENT ON COLUMN "plot.**".coord_uncertainty_m IS 'for a point observation, this is the fuzziness of the coordinates. for a plot (or other shape), this is the radius of the circle that circumscribes the entire plot, or the fuzziness, whichever is greater. note that the DwC definition is confusingly worded: it uses the ambiguous term Location, which sometimes refers to the asserted named place, but which they intended to refer to the plot or point.';
8849

  
8850

  
8851
--
8852
-- Name: COLUMN "plot.**".georef_sources; Type: COMMENT; Schema: public; Owner: -
8853
--
8854

  
8855
COMMENT ON COLUMN "plot.**".georef_sources IS '"A list (concatenated and separated) of maps, gazetteers, or other resources used to georeference the Location, described specifically enough to allow anyone in the future to use the same resources"';
8856

  
8857

  
8858
--
8859
-- Name: COLUMN "plot.**".georef_protocol; Type: COMMENT; Schema: public; Owner: -
8860
--
8861

  
8862
COMMENT ON COLUMN "plot.**".georef_protocol IS '"A description or reference to the methods used to determine the spatial footprint, coordinates, and uncertainties"';
8863

  
8864

  
8865
--
8866
-- Name: COLUMN "plot.**".is_geovalid; Type: COMMENT; Schema: public; Owner: -
8867
--
8868

  
8869
COMMENT ON COLUMN "plot.**".is_geovalid IS 'whether the coordinates are within the boundary of the asserted named places';
8870

  
8871

  
8872
--
8873
-- Name: COLUMN "plot.**".is_new_world; Type: COMMENT; Schema: public; Owner: -
8874
--
8875

  
8876
COMMENT ON COLUMN "plot.**".is_new_world IS 'whether the country is in the Americas';
8877

  
8878

  
8879
--
8880
-- Name: COLUMN "plot.**".project_id; Type: COMMENT; Schema: public; Owner: -
8881
--
8882

  
8883
COMMENT ON COLUMN "plot.**".project_id IS 'http://project.sourceaccessioncode__@VegBIEN__.public@vegpath.org;
8884
"A reference to a specific ''project''"';
8885

  
8886

  
8887
--
8888
-- Name: COLUMN "plot.**".project_contributors; Type: COMMENT; Schema: public; Owner: -
8889
--
8890

  
8891
COMMENT ON COLUMN "plot.**".project_contributors IS '"intersection entit[ies] used to ''link'' a party with a specific project wherein vegetation plots are described"';
8892

  
8893

  
8894
--
8895
-- Name: COLUMN "plot.**".location_id; Type: COMMENT; Schema: public; Owner: -
8896
--
8897

  
8898
COMMENT ON COLUMN "plot.**".location_id IS '"An identifier for the set of location information (data associated with dcterms:Location)"';
8899

  
8900

  
8901
--
8902
-- Name: COLUMN "plot.**".plot_name; Type: COMMENT; Schema: public; Owner: -
8903
--
8904

  
8905
COMMENT ON COLUMN "plot.**".plot_name IS '"Name or label for a plot"';
8906

  
8907

  
8908
--
8909
-- Name: COLUMN "plot.**".subplot; Type: COMMENT; Schema: public; Owner: -
8910
--
8911

  
8912
COMMENT ON COLUMN "plot.**".subplot IS 'http://location.authorlocationcode__@VegBIEN__.public@vegpath.org;
8913
"Code for subplot, line, or any other subsample or subdivision of plot"';
8914

  
8915

  
8916
--
8917
-- Name: COLUMN "plot.**".is_location_cultivated; Type: COMMENT; Schema: public; Owner: -
8918
--
8919

  
8920
COMMENT ON COLUMN "plot.**".is_location_cultivated IS 'whether the occurrence''s *location* was flagged as cultivated. note that this refers just to the cultivated status of the *location*; the occurrence may be cultivated even if the location isn''t.';
8921

  
8922

  
8923
--
8924
-- Name: COLUMN "plot.**".locationevent_id; Type: COMMENT; Schema: public; Owner: -
8925
--
8926

  
8927
COMMENT ON COLUMN "plot.**".locationevent_id IS 'http://locationevent.locationevent_id__@VegBIEN__.public@vegpath.org;
8928
autogenerated ID for locationevent';
8929

  
8930

  
8931
--
8932
-- Name: COLUMN "plot.**".event_date; Type: COMMENT; Schema: public; Owner: -
8933
--
8934

  
8935
COMMENT ON COLUMN "plot.**".event_date IS '"The date-time or interval during which an Event occurred. For occurrences, this is the date-time when the event was recorded."';
8936

  
8937

  
8938
--
8939
-- Name: COLUMN "plot.**".elevation_m; Type: COMMENT; Schema: public; Owner: -
8940
--
8941

  
8942
COMMENT ON COLUMN "plot.**".elevation_m IS 'the "elevation (altitude, usually above sea level), in meters"';
8943

  
8944

  
8945
--
8946
-- Name: COLUMN "plot.**".slope_aspect_deg; Type: COMMENT; Schema: public; Owner: -
8947
--
8948

  
8949
COMMENT ON COLUMN "plot.**".slope_aspect_deg IS '"Representative azimuth of slope gradient (0-360 degrees) or as a cardinal direction (e.g. N, S, NE)"';
8950

  
8951

  
8952
--
8953
-- Name: COLUMN "plot.**".slope_gradient_deg; Type: COMMENT; Schema: public; Owner: -
8954
--
8955

  
8956
COMMENT ON COLUMN "plot.**".slope_gradient_deg IS '"Representative inclination of slope in degrees"';
8957

  
8958

  
8959
--
8960
-- Name: COLUMN "plot.**".plot_area_ha; Type: COMMENT; Schema: public; Owner: -
8961
--
8962

  
8963
COMMENT ON COLUMN "plot.**".plot_area_ha IS '"Total area of the plot"';
8964

  
8965

  
8966
--
8967
-- Name: COLUMN "plot.**".sampling_protocol; Type: COMMENT; Schema: public; Owner: -
8968
--
8969

  
8970
COMMENT ON COLUMN "plot.**".sampling_protocol IS '"The name of, reference to, or description of the method or protocol used during an Event"';
8971

  
8972

  
8973
--
8974
-- Name: COLUMN "plot.**".temperature_c; Type: COMMENT; Schema: public; Owner: -
8975
--
8976

  
8977
COMMENT ON COLUMN "plot.**".temperature_c IS '"Temperature during observation [...] [in] Celsius"';
8978

  
8979

  
8980
--
8981
-- Name: COLUMN "plot.**".precip_mm; Type: COMMENT; Schema: public; Owner: -
8982
--
8983

  
8984
COMMENT ON COLUMN "plot.**".precip_mm IS '"Total annual precipitation, in mm"';
8985

  
8986

  
8987
--
8988
-- Name: COLUMN "plot.**".stratum_name; Type: COMMENT; Schema: public; Owner: -
8989
--
8990

  
8991
COMMENT ON COLUMN "plot.**".stratum_name IS '"Name associated with this stratum"';
8992

  
8993

  
8994
--
8995
-- Name: COLUMN "plot.**".community_concept_name; Type: COMMENT; Schema: public; Owner: -
8996
--
8997

  
8998
COMMENT ON COLUMN "plot.**".community_concept_name IS '"A textual label for a community type. A community type is an abstract grouping of organisms that tend to co-occur on the landscape due to shared ecological requirements or preferences."';
8999

  
9000

  
9001
--
9002
-- Name: COLUMN "plot.**".observation_contributors; Type: COMMENT; Schema: public; Owner: -
9003
--
9004

  
9005
COMMENT ON COLUMN "plot.**".observation_contributors IS '"intersection[s] that link[] a party with a specific plot observation event"';
9006

  
9007

  
9008
--
9009
-- Name: sourcelist; Type: TABLE; Schema: public; Owner: -; Tablespace: 
9010
--
9011

  
9012
CREATE TABLE sourcelist (
9013
    sourcelist_id integer NOT NULL,
9014
    source_id integer NOT NULL,
9015
    name text NOT NULL
9016
);
9017

  
9018

  
9019
--
9020
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
9021
--
9022

  
9023
CREATE TABLE specimenreplicate (
9024
    specimenreplicate_id integer NOT NULL,
9025
    source_id integer NOT NULL,
9026
    sourceaccessioncode text,
9027
    plantobservation_id integer,
9028
    duplicate_institutions_sourcelist_id integer,
9029
    collectioncode_dwc text,
9030
    catalognumber_dwc text,
9031
    collectionnumber text,
9032
    description text,
9033
    specimen_id integer,
9034
    CONSTRAINT specimenreplicate_required_key CHECK ((((plantobservation_id IS NOT NULL) OR (sourceaccessioncode IS NOT NULL)) OR (catalognumber_dwc IS NOT NULL)))
9035
);
9036

  
9037

  
9038
--
9039
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
9040
--
9041

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

  
9046

  
9047
--
9048
-- Name: COLUMN specimenreplicate.duplicate_institutions_sourcelist_id; Type: COMMENT; Schema: public; Owner: -
9049
--
9050

  
9051
COMMENT ON COLUMN specimenreplicate.duplicate_institutions_sourcelist_id IS '
9052
The institution(s) (such as museums) that the specimenreplicate is from.
9053
';
9054

  
9055

  
9056
--
9057
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
9058
--
9059

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

  
9064

  
9065
--
9066
-- Name: taxondetermination; Type: TABLE; Schema: public; Owner: -; Tablespace: 
9067
--
9068

  
9069
CREATE TABLE taxondetermination (
9070
    taxondetermination_id integer NOT NULL,
9071
    taxonoccurrence_id integer NOT NULL,
9072
    source_id integer NOT NULL,
9073
    taxonverbatim_id integer NOT NULL,
9074
    party_id integer,
9075
    role role DEFAULT 'unknown'::role NOT NULL,
9076
    determinationtype text,
9077
    reference_id integer,
9078
    isoriginal boolean,
9079
    iscurrent__verbatim boolean,
9080
    iscurrent boolean DEFAULT false NOT NULL,
9081
    taxonfit text,
9082
    taxonconfidence text,
9083
    grouptype text,
9084
    notes text,
9085
    revisions boolean,
9086
    determinationdate date
9087
);
9088

  
9089

  
9090
--
9091
-- Name: TABLE taxondetermination; Type: COMMENT; Schema: public; Owner: -
9092
--
9093

  
9094
COMMENT ON TABLE taxondetermination IS '
9095
Equivalent to VegBank''s taxoninterpretation table.
9096
';
9097

  
9098

  
9099
--
9100
-- Name: taxonoccurrence; Type: TABLE; Schema: public; Owner: -; Tablespace: 
9101
--
9102

  
9103
CREATE TABLE taxonoccurrence (
9104
    taxonoccurrence_id integer NOT NULL,
9105
    source_id integer NOT NULL,
9106
    sourceaccessioncode text,
9107
    locationevent_id integer,
9108
    authortaxoncode text,
9109
    collector_id integer,
9110
    growthform growthform,
9111
    iscultivated boolean,
9112
    cultivatedbasis text,
9113
    isnative boolean,
9114
    CONSTRAINT taxonoccurrence_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (locationevent_id IS NOT NULL)))
9115
);
9116

  
9117

  
9118
--
9119
-- Name: TABLE taxonoccurrence; Type: COMMENT; Schema: public; Owner: -
9120
--
9121

  
9122
COMMENT ON TABLE taxonoccurrence IS '
9123
Equivalent to VegBank''s taxonobservation table.
9124
';
9125

  
9126

  
9127
--
9128
-- Name: COLUMN taxonoccurrence.iscultivated; Type: COMMENT; Schema: public; Owner: -
9129
--
9130

  
9131
COMMENT ON COLUMN taxonoccurrence.iscultivated IS '
9132
cultivated or wild
9133
';
9134

  
9135

  
9136
--
9137
-- Name: COLUMN taxonoccurrence.cultivatedbasis; Type: COMMENT; Schema: public; Owner: -
9138
--
9139

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

  
9144

  
9145
--
9146
-- Name: COLUMN taxonoccurrence.isnative; Type: COMMENT; Schema: public; Owner: -
9147
--
9148

  
9149
COMMENT ON COLUMN taxonoccurrence.isnative IS '
9150
native or exotic
9151
';
9152

  
9153

  
9154
--
9155
-- Name: taxonverbatim; Type: TABLE; Schema: public; Owner: -; Tablespace: 
9156
--
9157

  
9158
CREATE TABLE taxonverbatim (
9159
    taxonverbatim_id integer NOT NULL,
9160
    source_id integer NOT NULL,
9161
    taxonlabel_id integer,
9162
    verbatimrank text,
9163
    taxonomicname text,
9164
    taxonname text,
9165
    author text,
9166
    family text,
9167
    genus text,
9168
    specific_epithet text,
9169
    subspecies text,
9170
    morphospecies text,
9171
    morphoname text,
9172
    growthform growthform,
9173
    description text,
9174
    CONSTRAINT taxonverbatim_required_key CHECK (((taxonlabel_id IS NOT NULL) OR (morphoname IS NOT NULL)))
9175
);
9176

  
9177

  
9178
--
9179
-- Name: TABLE taxonverbatim; Type: COMMENT; Schema: public; Owner: -
9180
--
9181

  
9182
COMMENT ON TABLE taxonverbatim IS '
9183
Component parts of the taxonlabel. Contains the datasource''s original taxonomic name components, as well as any parsed components produced by name resolution.
9184
';
9185

  
9186

  
9187
--
9188
-- Name: COLUMN taxonverbatim.verbatimrank; Type: COMMENT; Schema: public; Owner: -
9189
--
9190

  
9191
COMMENT ON COLUMN taxonverbatim.verbatimrank IS '
9192
The taxon''s verbatim level in the taxonomic hierarchy. Does not need to be in the taxonrank closed list.
9193
';
9194

  
9195

  
9196
--
9197
-- Name: COLUMN taxonverbatim.taxonomicname; Type: COMMENT; Schema: public; Owner: -
9198
--
9199

  
9200
COMMENT ON COLUMN taxonverbatim.taxonomicname IS '
9201
The full taxonomic name which uniquely identifies this taxon, including the author of that name. The family should be omitted if possible.
9202

  
9203
Equivalent to Darwin Core''s scientificName.
9204
';
9205

  
9206

  
9207
--
9208
-- Name: COLUMN taxonverbatim.taxonname; Type: COMMENT; Schema: public; Owner: -
9209
--
9210

  
9211
COMMENT ON COLUMN taxonverbatim.taxonname IS '
9212
The taxonomic name without the author. The family should be omitted if possible.
9213
';
9214

  
9215

  
9216
--
9217
-- Name: COLUMN taxonverbatim.author; Type: COMMENT; Schema: public; Owner: -
9218
--
9219

  
9220
COMMENT ON COLUMN taxonverbatim.author IS '
9221
The author of the taxonomic name.
9222

  
9223
Equivalent to Darwin Core''s scientificNameAuthorship.
9224
';
9225

  
9226

  
9227
--
9228
-- Name: COLUMN taxonverbatim.family; Type: COMMENT; Schema: public; Owner: -
9229
--
9230

  
9231
COMMENT ON COLUMN taxonverbatim.family IS '
9232
The family of the taxonomic name. This is a cached field for easy querying; this should also be stored in taxonlabel at the appropriate rank.
9233
';
9234

  
9235

  
9236
--
9237
-- Name: COLUMN taxonverbatim.genus; Type: COMMENT; Schema: public; Owner: -
9238
--
9239

  
9240
COMMENT ON COLUMN taxonverbatim.genus IS '
9241
The genus portion of the taxonomic name. This is a cached field for easy querying; this should also be stored in taxonlabel at the appropriate rank.
9242
';
9243

  
9244

  
9245
--
9246
-- Name: COLUMN taxonverbatim.specific_epithet; Type: COMMENT; Schema: public; Owner: -
9247
--
9248

  
9249
COMMENT ON COLUMN taxonverbatim.specific_epithet IS '
9250
The specific epithet portion of the taxonomic name. This is a cached field for easy querying; this should also be stored in taxonlabel at the appropriate rank.
9251
';
9252

  
9253

  
9254
--
9255
-- Name: COLUMN taxonverbatim.morphospecies; Type: COMMENT; Schema: public; Owner: -
9256
--
9257

  
9258
COMMENT ON COLUMN taxonverbatim.morphospecies IS '
9259
The morphospecies suffix.
9260
';
9261

  
9262

  
9263
--
9264
-- Name: view_full_occurrence_individual_view; Type: VIEW; Schema: public; Owner: -
9265
--
9266

  
9267
CREATE VIEW view_full_occurrence_individual_view AS
9268
 SELECT "plot.**".datasource,
9269
    "plot.**".country,
9270
    "plot.**".state_province,
9271
    "plot.**".county,
9272
    "plot.**".locality,
9273
    "plot.**".latitude,
9274
    "plot.**".longitude,
9275
    "plot.**".coord_uncertainty_m,
9276
    "plot.**".georef_sources,
9277
    "plot.**".georef_protocol,
9278
    "plot.**".is_geovalid,
9279
    "plot.**".is_new_world,
9280
    "plot.**".project_id,
9281
    "plot.**".project_contributors,
9282
    "plot.**".location_id,
9283
    "plot.**".plot_name,
9284
    "plot.**".subplot,
9285
    "plot.**".is_location_cultivated,
9286
    "plot.**".locationevent_id,
9287
    "plot.**".event_date,
9288
    "plot.**".elevation_m,
9289
    "plot.**".slope_aspect_deg,
9290
    "plot.**".slope_gradient_deg,
9291
    "plot.**".plot_area_ha,
9292
    "plot.**".sampling_protocol,
9293
    "plot.**".temperature_c,
9294
    "plot.**".precip_mm,
9295
    "plot.**".stratum_name,
9296
    "plot.**".community_concept_name,
9297
    "plot.**".observation_contributors,
9298
    sourcelist.name AS custodial_institution_codes,
9299
    specimenreplicate.collectioncode_dwc AS collection_code,
9300
    specimenreplicate.catalognumber_dwc AS catalog_number,
9301
    specimenreplicate.sourceaccessioncode AS occurrence_id,
9302
    collector.fullname AS recorded_by,
9303
    plantobservation.authorplantcode AS record_number,
9304
    COALESCE(aggregateoccurrence.collectiondate, "plot.**".event_date) AS date_collected,
9305
    taxonverbatim.family AS verbatim_family,
9306
    COALESCE(taxonverbatim.taxonomicname, (taxonverbatim.taxonname || COALESCE((' '::text || taxonverbatim.author), ''::text)), taxonlabel.taxonomicname) AS verbatim_scientific_name,
9307
    identifiedby.fullname AS identified_by,
9308
    taxondetermination.determinationdate AS date_identified,
9309
    taxondetermination.notes AS identification_remarks,
9310
    taxon_scrub."*Name_matched_accepted_family" AS family_matched,
9311
    taxon_scrub."*Name_matched" AS name_matched,
9312
    taxon_scrub."*Name_matched_author" AS name_matched_author,
9313
    family_higher_plant_group.higher_plant_group,
9314
    taxon_scrub."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" AS taxonomic_status,
9315
    taxon_scrub."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" AS scrubbed_family,
9316
    taxon_scrub."[scrubbed_]genus__@DwC__@vegpath.org" AS scrubbed_genus,
9317
    taxon_scrub."[scrubbed_]specificEpithet__@DwC__@vegpath.org" AS scrubbed_specific_epithet,
9318
    ((taxon_scrub."[scrubbed_]genus__@DwC__@vegpath.org" || ' '::text) || taxon_scrub."[scrubbed_]specificEpithet__@DwC__@vegpath.org") AS scrubbed_species_binomial,
9319
    taxon_scrub."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" AS scrubbed_taxon_name_no_author,
9320
    taxon_scrub."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" AS scrubbed_author,
9321
    taxon_scrub."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" AS scrubbed_taxon_name_with_author,
9322
    taxon_scrub."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" AS scrubbed_species_binomial_with_morphospecies,
9323
    taxonoccurrence.growthform AS growth_form,
9324
    plantobservation.reproductivecondition AS reproductive_condition,
9325
    (((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, "plot.**".is_location_cultivated)))::integer AS is_cultivated,
9326
        CASE
9327
            WHEN (taxonoccurrence.iscultivated IS NOT NULL) THEN taxonoccurrence.cultivatedbasis
9328
            WHEN ("plot.**".is_location_cultivated IS NOT NULL) THEN NULL::text
9329
            ELSE NULL::text
9330
        END AS is_cultivated_basis,
9331
    aggregateoccurrence.notes AS occurrence_remarks,
9332
    _fraction_to_percent(aggregateoccurrence.cover_fraction) AS cover_percent,
9333
    taxonoccurrence.sourceaccessioncode AS taxon_observation_id,
9334
    taxonoccurrence.authortaxoncode AS taxon_name_usage_concept_author_code,
9335
    aggregateoccurrence.sourceaccessioncode AS aggregate_organism_observation_id,
9336
    plantobservation.sourceaccessioncode AS individual_organism_observation_id,
9337
    plantobservation.authorplantcode AS individual_id,
9338
    aggregateoccurrence.count AS individual_count,
9339
    plantobservation.plantobservation_id
9340
   FROM ((((((((((((("plot.**"
9341
   LEFT JOIN taxonoccurrence ON ((taxonoccurrence.locationevent_id = "plot.**".locationevent_id)))
9342
   LEFT JOIN party collector ON ((collector.party_id = taxonoccurrence.collector_id)))
9343
   LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id))
9344
   LEFT JOIN plantobservation USING (aggregateoccurrence_id))
9345
   LEFT JOIN specimenreplicate USING (plantobservation_id))
9346
   LEFT JOIN sourcelist ON ((sourcelist.sourcelist_id = specimenreplicate.duplicate_institutions_sourcelist_id)))
9347
   LEFT JOIN taxondetermination ON (((taxondetermination.taxonoccurrence_id = taxonoccurrence.taxonoccurrence_id) AND taxondetermination.iscurrent)))
9348
   LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id)))
9349
   LEFT JOIN taxonverbatim USING (taxonverbatim_id))
9350
   LEFT JOIN taxonlabel USING (taxonlabel_id))
9351
   LEFT JOIN "TNRS".taxon_scrub ON ((taxon_scrub."*Name_submitted" = taxonlabel.taxonomicname)))
9352
   LEFT JOIN family_higher_plant_group ON ((family_higher_plant_group.family = taxon_scrub."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org")))
9353
   LEFT JOIN cultivated_family_locations ON (((cultivated_family_locations.family = taxon_scrub."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org") AND (cultivated_family_locations.country = "plot.**".country))));
9354

  
9355

  
9356
--
9357
-- Name: VIEW view_full_occurrence_individual_view; Type: COMMENT; Schema: public; Owner: -
9358
--
9359

  
9360
COMMENT ON VIEW view_full_occurrence_individual_view IS '
9361
after updating this:
9362
SELECT view_full_occurrence_individual_view_modify()
9363
add applicable columns to analytical_specimen, analytical_plot
9364

  
9365
materialize time: 22 h ("79217026.810 ms") @r14089 @vegbiendev
9366

  
9367
CREATE INDEX runtime:
9368
1-column: 10 min - 1.5 h depending on the datatype and % populated
9369
	(plot_area_ha: "10:45.92"; taxonomic_status: "1:28:16") @r14089 @vegbiendev
9370
2-column: ~2 h ((datasource, scrubbed_species_binomial_with_morphospecies):
9371
	"2:11:31") @r14089 @vegbiendev
9372
';
9373

  
9374

  
9375
--
9376
-- Name: COLUMN view_full_occurrence_individual_view.datasource; Type: COMMENT; Schema: public; Owner: -
9377
--
9378

  
9379
COMMENT ON COLUMN view_full_occurrence_individual_view.datasource IS '"the person [or] institution that provided the data [to this database] (the *proximate* data provider)"';
9380

  
9381

  
9382
--
9383
-- Name: COLUMN view_full_occurrence_individual_view.country; Type: COMMENT; Schema: public; Owner: -
9384
--
9385

  
9386
COMMENT ON COLUMN view_full_occurrence_individual_view.country IS 'http://geoscrub.geoscrub_output.acceptedCountry__@VegBIEN__@vegpath.org;
9387
"The name of the country or major administrative unit in which the Location occurs"';
9388

  
9389

  
9390
--
9391
-- Name: COLUMN view_full_occurrence_individual_view.state_province; Type: COMMENT; Schema: public; Owner: -
9392
--
9393

  
9394
COMMENT ON COLUMN view_full_occurrence_individual_view.state_province IS '"The name of the next smaller administrative region than country (state, province, canton, department, region, etc.) in which the Location occurs"';
9395

  
9396

  
9397
--
9398
-- Name: COLUMN view_full_occurrence_individual_view.county; Type: COMMENT; Schema: public; Owner: -
9399
--
9400

  
9401
COMMENT ON COLUMN view_full_occurrence_individual_view.county IS '"The full, unabbreviated name of the next smaller administrative region than stateProvince (county, shire, department, etc.) in which the Location occurs"';
9402

  
9403

  
9404
--
9405
-- Name: COLUMN view_full_occurrence_individual_view.locality; Type: COMMENT; Schema: public; Owner: -
9406
--
9407

  
9408
COMMENT ON COLUMN view_full_occurrence_individual_view.locality IS '"The specific description of the place"';
9409

  
9410

  
9411
--
9412
-- Name: COLUMN view_full_occurrence_individual_view.latitude; Type: COMMENT; Schema: public; Owner: -
9413
--
9414

  
9415
COMMENT ON COLUMN view_full_occurrence_individual_view.latitude IS '"The geographic latitude (in decimal degrees, using the spatial reference system given in geodeticDatum) of the geographic center of a Location"';
9416

  
9417

  
9418
--
9419
-- Name: COLUMN view_full_occurrence_individual_view.longitude; Type: COMMENT; Schema: public; Owner: -
9420
--
9421

  
9422
COMMENT ON COLUMN view_full_occurrence_individual_view.longitude IS '"The geographic longitude (in decimal degrees, using the spatial reference system given in geodeticDatum) of the geographic center of a Location"';
9423

  
9424

  
9425
--
9426
-- Name: COLUMN view_full_occurrence_individual_view.coord_uncertainty_m; Type: COMMENT; Schema: public; Owner: -
9427
--
9428

  
9429
COMMENT ON COLUMN view_full_occurrence_individual_view.coord_uncertainty_m IS 'for a point observation, this is the fuzziness of the coordinates. for a plot (or other shape), this is the radius of the circle that circumscribes the entire plot, or the fuzziness, whichever is greater. note that the DwC definition is confusingly worded: it uses the ambiguous term Location, which sometimes refers to the asserted named place, but which they intended to refer to the plot or point.';
9430

  
9431

  
9432
--
9433
-- Name: COLUMN view_full_occurrence_individual_view.georef_sources; Type: COMMENT; Schema: public; Owner: -
9434
--
9435

  
9436
COMMENT ON COLUMN view_full_occurrence_individual_view.georef_sources IS '"A list (concatenated and separated) of maps, gazetteers, or other resources used to georeference the Location, described specifically enough to allow anyone in the future to use the same resources"';
9437

  
9438

  
9439
--
9440
-- Name: COLUMN view_full_occurrence_individual_view.georef_protocol; Type: COMMENT; Schema: public; Owner: -
9441
--
9442

  
9443
COMMENT ON COLUMN view_full_occurrence_individual_view.georef_protocol IS '"A description or reference to the methods used to determine the spatial footprint, coordinates, and uncertainties"';
9444

  
9445

  
9446
--
9447
-- Name: COLUMN view_full_occurrence_individual_view.is_geovalid; Type: COMMENT; Schema: public; Owner: -
9448
--
9449

  
9450
COMMENT ON COLUMN view_full_occurrence_individual_view.is_geovalid IS 'whether the coordinates are within the boundary of the asserted named places';
9451

  
9452

  
9453
--
9454
-- Name: COLUMN view_full_occurrence_individual_view.is_new_world; Type: COMMENT; Schema: public; Owner: -
9455
--
9456

  
9457
COMMENT ON COLUMN view_full_occurrence_individual_view.is_new_world IS 'whether the country is in the Americas';
9458

  
9459

  
9460
--
9461
-- Name: COLUMN view_full_occurrence_individual_view.project_id; Type: COMMENT; Schema: public; Owner: -
9462
--
9463

  
9464
COMMENT ON COLUMN view_full_occurrence_individual_view.project_id IS 'http://project.sourceaccessioncode__@VegBIEN__.public@vegpath.org;
9465
"A reference to a specific ''project''"';
9466

  
9467

  
9468
--
9469
-- Name: COLUMN view_full_occurrence_individual_view.project_contributors; Type: COMMENT; Schema: public; Owner: -
9470
--
9471

  
9472
COMMENT ON COLUMN view_full_occurrence_individual_view.project_contributors IS '"intersection entit[ies] used to ''link'' a party with a specific project wherein vegetation plots are described"';
9473

  
9474

  
9475
--
9476
-- Name: COLUMN view_full_occurrence_individual_view.location_id; Type: COMMENT; Schema: public; Owner: -
9477
--
9478

  
9479
COMMENT ON COLUMN view_full_occurrence_individual_view.location_id IS '"An identifier for the set of location information (data associated with dcterms:Location)"';
9480

  
9481

  
9482
--
9483
-- Name: COLUMN view_full_occurrence_individual_view.plot_name; Type: COMMENT; Schema: public; Owner: -
9484
--
9485

  
9486
COMMENT ON COLUMN view_full_occurrence_individual_view.plot_name IS '"Name or label for a plot"';
9487

  
9488

  
9489
--
9490
-- Name: COLUMN view_full_occurrence_individual_view.subplot; Type: COMMENT; Schema: public; Owner: -
9491
--
9492

  
9493
COMMENT ON COLUMN view_full_occurrence_individual_view.subplot IS 'http://location.authorlocationcode__@VegBIEN__.public@vegpath.org;
9494
"Code for subplot, line, or any other subsample or subdivision of plot"';
9495

  
9496

  
9497
--
9498
-- Name: COLUMN view_full_occurrence_individual_view.is_location_cultivated; Type: COMMENT; Schema: public; Owner: -
9499
--
9500

  
9501
COMMENT ON COLUMN view_full_occurrence_individual_view.is_location_cultivated IS 'whether the occurrence''s *location* was flagged as cultivated. note that this refers just to the cultivated status of the *location*; the occurrence may be cultivated even if the location isn''t.';
9502

  
9503

  
9504
--
9505
-- Name: COLUMN view_full_occurrence_individual_view.locationevent_id; Type: COMMENT; Schema: public; Owner: -
9506
--
9507

  
9508
COMMENT ON COLUMN view_full_occurrence_individual_view.locationevent_id IS 'http://locationevent.locationevent_id__@VegBIEN__.public@vegpath.org;
9509
autogenerated ID for locationevent';
9510

  
9511

  
9512
--
9513
-- Name: COLUMN view_full_occurrence_individual_view.event_date; Type: COMMENT; Schema: public; Owner: -
9514
--
9515

  
9516
COMMENT ON COLUMN view_full_occurrence_individual_view.event_date IS '"The date-time or interval during which an Event occurred. For occurrences, this is the date-time when the event was recorded."';
9517

  
9518

  
9519
--
9520
-- Name: COLUMN view_full_occurrence_individual_view.elevation_m; Type: COMMENT; Schema: public; Owner: -
9521
--
9522

  
9523
COMMENT ON COLUMN view_full_occurrence_individual_view.elevation_m IS 'the "elevation (altitude, usually above sea level), in meters"';
9524

  
9525

  
9526
--
9527
-- Name: COLUMN view_full_occurrence_individual_view.slope_aspect_deg; Type: COMMENT; Schema: public; Owner: -
9528
--
9529

  
9530
COMMENT ON COLUMN view_full_occurrence_individual_view.slope_aspect_deg IS '"Representative azimuth of slope gradient (0-360 degrees) or as a cardinal direction (e.g. N, S, NE)"';
9531

  
9532

  
9533
--
9534
-- Name: COLUMN view_full_occurrence_individual_view.slope_gradient_deg; Type: COMMENT; Schema: public; Owner: -
9535
--
9536

  
9537
COMMENT ON COLUMN view_full_occurrence_individual_view.slope_gradient_deg IS '"Representative inclination of slope in degrees"';
9538

  
9539

  
9540
--
9541
-- Name: COLUMN view_full_occurrence_individual_view.plot_area_ha; Type: COMMENT; Schema: public; Owner: -
9542
--
9543

  
9544
COMMENT ON COLUMN view_full_occurrence_individual_view.plot_area_ha IS '"Total area of the plot"';
9545

  
9546

  
9547
--
9548
-- Name: COLUMN view_full_occurrence_individual_view.sampling_protocol; Type: COMMENT; Schema: public; Owner: -
9549
--
9550

  
9551
COMMENT ON COLUMN view_full_occurrence_individual_view.sampling_protocol IS '"The name of, reference to, or description of the method or protocol used during an Event"';
9552

  
9553

  
9554
--
9555
-- Name: COLUMN view_full_occurrence_individual_view.temperature_c; Type: COMMENT; Schema: public; Owner: -
9556
--
9557

  
9558
COMMENT ON COLUMN view_full_occurrence_individual_view.temperature_c IS '"Temperature during observation [...] [in] Celsius"';
9559

  
9560

  
9561
--
9562
-- Name: COLUMN view_full_occurrence_individual_view.precip_mm; Type: COMMENT; Schema: public; Owner: -
9563
--
9564

  
9565
COMMENT ON COLUMN view_full_occurrence_individual_view.precip_mm IS '"Total annual precipitation, in mm"';
9566

  
9567

  
9568
--
9569
-- Name: COLUMN view_full_occurrence_individual_view.stratum_name; Type: COMMENT; Schema: public; Owner: -
9570
--
9571

  
9572
COMMENT ON COLUMN view_full_occurrence_individual_view.stratum_name IS '"Name associated with this stratum"';
9573

  
9574

  
9575
--
9576
-- Name: COLUMN view_full_occurrence_individual_view.community_concept_name; Type: COMMENT; Schema: public; Owner: -
9577
--
9578

  
9579
COMMENT ON COLUMN view_full_occurrence_individual_view.community_concept_name IS '"A textual label for a community type. A community type is an abstract grouping of organisms that tend to co-occur on the landscape due to shared ecological requirements or preferences."';
9580

  
9581

  
9582
--
9583
-- Name: COLUMN view_full_occurrence_individual_view.observation_contributors; Type: COMMENT; Schema: public; Owner: -
9584
--
9585

  
9586
COMMENT ON COLUMN view_full_occurrence_individual_view.observation_contributors IS '"intersection[s] that link[] a party with a specific plot observation event"';
9587

  
9588

  
9589
--
9590
-- Name: COLUMN view_full_occurrence_individual_view.custodial_institution_codes; Type: COMMENT; Schema: public; Owner: -
9591
--
9592

  
9593
COMMENT ON COLUMN view_full_occurrence_individual_view.custodial_institution_codes IS '"The name[s] (or acronym[s]) in use by the institution[s] having custody of the object(s) or information referred to in the record"';
9594

  
9595

  
9596
--
9597
-- Name: COLUMN view_full_occurrence_individual_view.collection_code; Type: COMMENT; Schema: public; Owner: -
9598
--
9599

  
9600
COMMENT ON COLUMN view_full_occurrence_individual_view.collection_code IS '"The name, acronym, coden, or initialism identifying the collection or data set from which the record was derived"';
9601

  
9602

  
9603
--
9604
-- Name: COLUMN view_full_occurrence_individual_view.catalog_number; Type: COMMENT; Schema: public; Owner: -
9605
--
9606

  
9607
COMMENT ON COLUMN view_full_occurrence_individual_view.catalog_number IS '"An identifier (preferably unique) for the record within the data set or collection"';
9608

  
9609

  
9610
--
9611
-- Name: COLUMN view_full_occurrence_individual_view.occurrence_id; Type: COMMENT; Schema: public; Owner: -
9612
--
9613

  
9614
COMMENT ON COLUMN view_full_occurrence_individual_view.occurrence_id IS '"An identifier for the Occurrence (as opposed to a particular digital record of the occurrence). In the absence of a persistent global unique identifier, construct one from a combination of identifiers in the record that will most closely make the occurrenceID globally unique."';
9615

  
9616

  
9617
--
9618
-- Name: COLUMN view_full_occurrence_individual_view.recorded_by; Type: COMMENT; Schema: public; Owner: -
9619
--
9620

  
9621
COMMENT ON COLUMN view_full_occurrence_individual_view.recorded_by IS '"A list (concatenated and separated) of names of people, groups, or organizations responsible for recording the original Occurrence. The primary collector or observer, especially one who applies a personal identifier (recordNumber), should be listed first."';
9622

  
9623

  
9624
--
9625
-- Name: COLUMN view_full_occurrence_individual_view.record_number; Type: COMMENT; Schema: public; Owner: -
9626
--
9627

  
9628
COMMENT ON COLUMN view_full_occurrence_individual_view.record_number IS '"An identifier given to the Occurrence at the time it was recorded. Often serves as a link between field notes and an Occurrence record, such as a specimen collector''s number."';
9629

  
9630

  
9631
--
9632
-- Name: COLUMN view_full_occurrence_individual_view.date_collected; Type: COMMENT; Schema: public; Owner: -
9633
--
9634

  
9635
COMMENT ON COLUMN view_full_occurrence_individual_view.date_collected IS 'the "date-time (Common Era calendar) in a date-time period during which an organism or group of organisms was collected or observed"';
9636

  
9637

  
9638
--
9639
-- Name: COLUMN view_full_occurrence_individual_view.verbatim_family; Type: COMMENT; Schema: public; Owner: -
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff