Project

General

Profile

« Previous | Next » 

Revision 7189

schemas/vegbien.sql: plantobservation: Renamed collectionnumber to authorplantcode since this number, which identifies the plant, is actually different from the collectionnumber that identifies the specimen collected from it. This distinction is meaningful for plots data, but generally not for specimens data.

View differences:

schemas/vegbien.my.sql
1241 1241
    aggregateoccurrence_id int(11),
1242 1242
    overallheight_m double precision,
1243 1243
    overallheightaccuracy_m double precision,
1244
    collectionnumber varchar(255),
1244
    authorplantcode varchar(255),
1245 1245
    stemcount int(11),
1246 1246
    plant_id int(11),
1247 1247
    accessioncode varchar(255)
......
1256 1256

  
1257 1257

  
1258 1258
--
1259
-- Name: COLUMN plantobservation.collectionnumber; Type: COMMENT; Schema: public; Owner: -
1259
-- Name: COLUMN plantobservation.authorplantcode; Type: COMMENT; Schema: public; Owner: -
1260 1260
--
1261 1261

  
1262 1262

  
schemas/vegbien.sql
2079 2079
    aggregateoccurrence_id integer,
2080 2080
    overallheight_m double precision,
2081 2081
    overallheightaccuracy_m double precision,
2082
    collectionnumber text,
2082
    authorplantcode text,
2083 2083
    stemcount integer,
2084 2084
    plant_id integer,
2085 2085
    accessioncode text,
......
2095 2095

  
2096 2096

  
2097 2097
--
2098
-- Name: COLUMN plantobservation.collectionnumber; Type: COMMENT; Schema: public; Owner: -
2098
-- Name: COLUMN plantobservation.authorplantcode; Type: COMMENT; Schema: public; Owner: -
2099 2099
--
2100 2100

  
2101
COMMENT ON COLUMN plantobservation.collectionnumber IS 'The number of the organism within the data collection or event.';
2101
COMMENT ON COLUMN plantobservation.authorplantcode IS 'The number of the organism within the data collection or event.';
2102 2102

  
2103 2103

  
2104 2104
--
......
2433 2433
--
2434 2434

  
2435 2435
CREATE VIEW analytical_stem_view AS
2436
    SELECT source.shortname AS datasource, sourcelist.name AS "institutionCode", specimenreplicate.collectioncode_dwc AS "collectionCode", specimenreplicate.catalognumber_dwc AS "catalogNumber", specimenreplicate.sourceaccessioncode AS "occurrenceID", canon_place.country, canon_place.stateprovince AS "stateProvince", datasource_place.county, coordinates.latitude_deg AS "decimalLatitude", coordinates.longitude_deg AS "decimalLongitude", coordinates.coordsaccuracy_m AS "coordinateUncertaintyInMeters", (canon_place.geovalid)::integer AS geovalid, ("newWorldCountries"."isNewWorld")::integer AS "isNewWorld", COALESCE(project.sourceaccessioncode, project.projectname) AS "projectID", COALESCE(location.sourceaccessioncode, NULLIF(array_to_string(ARRAY[COALESCE(parent_location.sourceaccessioncode, parent_location.authorlocationcode), location.authorlocationcode], '; '::text), ''::text)) AS "locationID", COALESCE(parent_location.authorlocationcode, location.authorlocationcode) AS "locationName", CASE WHEN (parent_location.location_id IS NOT NULL) THEN location.authorlocationcode ELSE NULL::text END AS subplot, plantobservation.collectionnumber AS "individualCode", COALESCE(location.elevation_m, parent_location.elevation_m) AS "elevationInMeters", _m2_to_ha(location.area_m2) AS "plotArea_ha", method.name AS "samplingProtocol", COALESCE(locationevent.obsstartdate, parent_event.obsstartdate, aggregateoccurrence.collectiondate) AS "dateCollected", family_higher_plant_group.higher_plant_group AS "higherPlantGroup", taxonverbatim.family, taxonverbatim.genus, ((taxonverbatim.genus || ' '::text) || taxonverbatim.specific_epithet) AS "speciesBinomial", taxonlabel.taxonomicname AS "scientificName", taxonverbatim.author AS "scientificNameAuthorship", NULLIF(array_to_string(ARRAY[COALESCE(taxonverbatim.genus, taxonverbatim.family), COALESCE(taxonverbatim.specific_epithet, taxonverbatim.morphospecies)], ' '::text), ''::text) AS "speciesBinomialWithMorphospecies", NULLIF(array_to_string(ARRAY[taxonlabel.taxonomicname, taxonverbatim.morphospecies], ' '::text), ''::text) AS "scientificNameWithMorphospecies", ((threatened_taxonlabel.taxonlabel_id IS NOT NULL))::integer AS threatened, identifiedby.fullname AS "identifiedBy", taxonoccurrence.growthform AS "growthForm", (((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, location.iscultivated)))::integer AS cultivated, CASE WHEN (taxonoccurrence.iscultivated IS NOT NULL) THEN taxonoccurrence.cultivatedbasis WHEN (location.iscultivated IS NOT NULL) THEN NULL::text ELSE NULL::text END AS "cultivatedBasis", collector.fullname AS "recordedBy", plantobservation.collectionnumber AS "recordNumber", _fraction_to_percent(aggregateoccurrence.cover_fraction) AS "coverPercent", _m_to_cm(stemobservation.diameterbreastheight_m) AS "diameterBreastHeight_cm", stemobservation.height_m, stemobservation.tag, stemobservation.xposition_m AS "organismX_m", stemobservation.yposition_m AS "organismY_m", taxonoccurrence.sourceaccessioncode AS "taxonOccurrenceID", taxonoccurrence.authortaxoncode AS "authorTaxonCode", plantobservation.sourceaccessioncode AS "individualObservationID", stemobservation.authorstemcode AS "authorStemCode" FROM ((((((((((((((((((((((((((source JOIN location USING (source_id)) LEFT JOIN locationevent USING (location_id)) LEFT JOIN location parent_location ON ((parent_location.location_id = location.parent_id))) LEFT JOIN locationplace ON ((locationplace.location_id = COALESCE(parent_location.location_id, location.location_id)))) LEFT JOIN place datasource_place USING (place_id)) LEFT JOIN place canon_place ON ((canon_place.place_id = datasource_place.canon_place_id))) LEFT JOIN coordinates ON ((coordinates.coordinates_id = canon_place.coordinates_id))) LEFT JOIN "newWorld".iso_code_gadm ON ((iso_code_gadm."GADM country" = canon_place.country))) LEFT JOIN "newWorld"."newWorldCountries" ON (("newWorldCountries"."isoCode" = iso_code_gadm."2-digit iso code"))) LEFT JOIN taxonoccurrence USING (locationevent_id)) LEFT JOIN locationevent parent_event ON ((parent_event.locationevent_id = locationevent.parent_id))) LEFT JOIN project ON ((project.project_id = COALESCE(locationevent.project_id, parent_event.project_id)))) LEFT JOIN method ON ((method.method_id = COALESCE(locationevent.method_id, parent_event.method_id)))) LEFT JOIN party collector ON ((collector.party_id = taxonoccurrence.collector_id))) LEFT JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) LEFT JOIN taxonverbatim USING (taxonverbatim_id)) LEFT JOIN taxonlabel USING (taxonlabel_id)) LEFT JOIN threatened_taxonlabel ON ((threatened_taxonlabel.taxonlabel_id = taxonlabel.taxonlabel_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN family_higher_plant_group ON ((family_higher_plant_group.family = taxonverbatim.family))) LEFT JOIN cultivated_family_locations ON (((cultivated_family_locations.family = taxonverbatim.family) AND (cultivated_family_locations.country = canon_place.country)))) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) LEFT JOIN specimenreplicate USING (plantobservation_id)) LEFT JOIN sourcelist ON ((sourcelist.sourcelist_id = specimenreplicate.institution_id))) WHERE COALESCE(taxondetermination.iscurrent, true);
2436
    SELECT source.shortname AS datasource, sourcelist.name AS "institutionCode", specimenreplicate.collectioncode_dwc AS "collectionCode", specimenreplicate.catalognumber_dwc AS "catalogNumber", specimenreplicate.sourceaccessioncode AS "occurrenceID", canon_place.country, canon_place.stateprovince AS "stateProvince", datasource_place.county, coordinates.latitude_deg AS "decimalLatitude", coordinates.longitude_deg AS "decimalLongitude", coordinates.coordsaccuracy_m AS "coordinateUncertaintyInMeters", (canon_place.geovalid)::integer AS geovalid, ("newWorldCountries"."isNewWorld")::integer AS "isNewWorld", COALESCE(project.sourceaccessioncode, project.projectname) AS "projectID", COALESCE(location.sourceaccessioncode, NULLIF(array_to_string(ARRAY[COALESCE(parent_location.sourceaccessioncode, parent_location.authorlocationcode), location.authorlocationcode], '; '::text), ''::text)) AS "locationID", COALESCE(parent_location.authorlocationcode, location.authorlocationcode) AS "locationName", CASE WHEN (parent_location.location_id IS NOT NULL) THEN location.authorlocationcode ELSE NULL::text END AS subplot, plantobservation.authorplantcode AS "individualCode", COALESCE(location.elevation_m, parent_location.elevation_m) AS "elevationInMeters", _m2_to_ha(location.area_m2) AS "plotArea_ha", method.name AS "samplingProtocol", COALESCE(locationevent.obsstartdate, parent_event.obsstartdate, aggregateoccurrence.collectiondate) AS "dateCollected", family_higher_plant_group.higher_plant_group AS "higherPlantGroup", taxonverbatim.family, taxonverbatim.genus, ((taxonverbatim.genus || ' '::text) || taxonverbatim.specific_epithet) AS "speciesBinomial", taxonlabel.taxonomicname AS "scientificName", taxonverbatim.author AS "scientificNameAuthorship", NULLIF(array_to_string(ARRAY[COALESCE(taxonverbatim.genus, taxonverbatim.family), COALESCE(taxonverbatim.specific_epithet, taxonverbatim.morphospecies)], ' '::text), ''::text) AS "speciesBinomialWithMorphospecies", NULLIF(array_to_string(ARRAY[taxonlabel.taxonomicname, taxonverbatim.morphospecies], ' '::text), ''::text) AS "scientificNameWithMorphospecies", ((threatened_taxonlabel.taxonlabel_id IS NOT NULL))::integer AS threatened, identifiedby.fullname AS "identifiedBy", taxonoccurrence.growthform AS "growthForm", (((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, location.iscultivated)))::integer AS cultivated, CASE WHEN (taxonoccurrence.iscultivated IS NOT NULL) THEN taxonoccurrence.cultivatedbasis WHEN (location.iscultivated IS NOT NULL) THEN NULL::text ELSE NULL::text END AS "cultivatedBasis", collector.fullname AS "recordedBy", plantobservation.authorplantcode AS "recordNumber", _fraction_to_percent(aggregateoccurrence.cover_fraction) AS "coverPercent", _m_to_cm(stemobservation.diameterbreastheight_m) AS "diameterBreastHeight_cm", stemobservation.height_m, stemobservation.tag, stemobservation.xposition_m AS "organismX_m", stemobservation.yposition_m AS "organismY_m", taxonoccurrence.sourceaccessioncode AS "taxonOccurrenceID", taxonoccurrence.authortaxoncode AS "authorTaxonCode", plantobservation.sourceaccessioncode AS "individualObservationID", stemobservation.authorstemcode AS "authorStemCode" FROM ((((((((((((((((((((((((((source JOIN location USING (source_id)) LEFT JOIN locationevent USING (location_id)) LEFT JOIN location parent_location ON ((parent_location.location_id = location.parent_id))) LEFT JOIN locationplace ON ((locationplace.location_id = COALESCE(parent_location.location_id, location.location_id)))) LEFT JOIN place datasource_place USING (place_id)) LEFT JOIN place canon_place ON ((canon_place.place_id = datasource_place.canon_place_id))) LEFT JOIN coordinates ON ((coordinates.coordinates_id = canon_place.coordinates_id))) LEFT JOIN "newWorld".iso_code_gadm ON ((iso_code_gadm."GADM country" = canon_place.country))) LEFT JOIN "newWorld"."newWorldCountries" ON (("newWorldCountries"."isoCode" = iso_code_gadm."2-digit iso code"))) LEFT JOIN taxonoccurrence USING (locationevent_id)) LEFT JOIN locationevent parent_event ON ((parent_event.locationevent_id = locationevent.parent_id))) LEFT JOIN project ON ((project.project_id = COALESCE(locationevent.project_id, parent_event.project_id)))) LEFT JOIN method ON ((method.method_id = COALESCE(locationevent.method_id, parent_event.method_id)))) LEFT JOIN party collector ON ((collector.party_id = taxonoccurrence.collector_id))) LEFT JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) LEFT JOIN taxonverbatim USING (taxonverbatim_id)) LEFT JOIN taxonlabel USING (taxonlabel_id)) LEFT JOIN threatened_taxonlabel ON ((threatened_taxonlabel.taxonlabel_id = taxonlabel.taxonlabel_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN family_higher_plant_group ON ((family_higher_plant_group.family = taxonverbatim.family))) LEFT JOIN cultivated_family_locations ON (((cultivated_family_locations.family = taxonverbatim.family) AND (cultivated_family_locations.country = canon_place.country)))) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) LEFT JOIN specimenreplicate USING (plantobservation_id)) LEFT JOIN sourcelist ON ((sourcelist.sourcelist_id = specimenreplicate.institution_id))) WHERE COALESCE(taxondetermination.iscurrent, true);
2437 2437

  
2438 2438

  
2439 2439
--

Also available in: Unified diff