Project

General

Profile

« Previous | Next » 

Revision 5961

schemas/vegbien.sql: analytical_stem_view: Updated to use reference instead of party to store the datasource name

View differences:

schemas/vegbien.my.sql
1070 1070

  
1071 1071

  
1072 1072
--
1073
-- Name: reference; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1074
--
1075

  
1076
CREATE TABLE reference (
1077
    reference_id int(11) NOT NULL,
1078
    shortname text,
1079
    `fulltext` text,
1080
    referencetype text,
1081
    title text,
1082
    titlesuperior text,
1083
    referencejournal_id int(11),
1084
    volume text,
1085
    issue text,
1086
    pagerange text,
1087
    totalpages int(11),
1088
    publisher text,
1089
    publicationplace text,
1090
    isbn text,
1091
    edition text,
1092
    numberofvolumes int(11),
1093
    chapternumber int(11),
1094
    reportnumber int(11),
1095
    communicationtype text,
1096
    degree text,
1097
    url text,
1098
    doi text,
1099
    additionalinfo text,
1100
    pubdate date,
1101
    accessdate date,
1102
    conferencedate date,
1103
    accessioncode text
1104
);
1105

  
1106

  
1107
--
1073 1108
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1074 1109
--
1075 1110

  
......
2199 2234

  
2200 2235

  
2201 2236
--
2202
-- Name: reference; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2203
--
2204

  
2205
CREATE TABLE reference (
2206
    reference_id int(11) NOT NULL,
2207
    shortname text,
2208
    `fulltext` text,
2209
    referencetype text,
2210
    title text,
2211
    titlesuperior text,
2212
    referencejournal_id int(11),
2213
    volume text,
2214
    issue text,
2215
    pagerange text,
2216
    totalpages int(11),
2217
    publisher text,
2218
    publicationplace text,
2219
    isbn text,
2220
    edition text,
2221
    numberofvolumes int(11),
2222
    chapternumber int(11),
2223
    reportnumber int(11),
2224
    communicationtype text,
2225
    degree text,
2226
    url text,
2227
    doi text,
2228
    additionalinfo text,
2229
    pubdate date,
2230
    accessdate date,
2231
    conferencedate date,
2232
    accessioncode text
2233
);
2234

  
2235

  
2236
--
2237 2237
-- Name: reference_reference_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2238 2238
--
2239 2239

  
schemas/vegbien.sql
1626 1626

  
1627 1627

  
1628 1628
--
1629
-- Name: reference; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1630
--
1631

  
1632
CREATE TABLE reference (
1633
    reference_id integer NOT NULL,
1634
    shortname text,
1635
    fulltext text,
1636
    referencetype text,
1637
    title text,
1638
    titlesuperior text,
1639
    referencejournal_id integer,
1640
    volume text,
1641
    issue text,
1642
    pagerange text,
1643
    totalpages integer,
1644
    publisher text,
1645
    publicationplace text,
1646
    isbn text,
1647
    edition text,
1648
    numberofvolumes integer,
1649
    chapternumber integer,
1650
    reportnumber integer,
1651
    communicationtype text,
1652
    degree text,
1653
    url text,
1654
    doi text,
1655
    additionalinfo text,
1656
    pubdate date,
1657
    accessdate date,
1658
    conferencedate date,
1659
    accessioncode text
1660
);
1661

  
1662

  
1663
--
1629 1664
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1630 1665
--
1631 1666

  
......
1877 1912
--
1878 1913

  
1879 1914
CREATE VIEW analytical_stem_view AS
1880
    SELECT datasource.organizationname AS "institutionCode", place.country, place.stateprovince AS "stateProvince", place.county, coordinates.latitude_deg AS "decimalLatitude", coordinates.longitude_deg AS "decimalLongitude", location.sourceaccessioncode AS "plotName", location.elevation_m AS "elevationInMeters", _m2_to_ha(location.area_m2) AS "plotArea_ha", method.name AS "samplingProtocol", aggregateoccurrence.collectiondate AS "dateCollected", accepted_taxonverbatim.family, accepted_taxonverbatim.genus, ((accepted_taxonverbatim.genus || ' '::text) || accepted_taxonverbatim.specific_epithet) AS "speciesBinomial", COALESCE(accepted_taxonverbatim.taxonomicname, accepted_taxonverbatim.taxonname) AS "scientificName", accepted_taxonverbatim.author AS "scientificNameAuthorship", NULLIF(array_to_string(ARRAY[accepted_taxonlabel.taxonomicname, parsed_taxonverbatim.morphospecies], ' '::text), ''::text) AS "scientificNameWithMorphospecies", NULLIF(array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], ' '::text), ''::text) AS "identifiedBy", taxonoccurrence.growthform AS "growthForm", taxonoccurrence.iscultivated AS cultivated, taxonoccurrence.cultivatedbasis AS "cultivatedBasis", _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.verbatimcollectorname AS "recordedBy", plantobservation.collectionnumber AS "recordNumber" FROM (((((((((((((((((((party datasource JOIN location ON ((location.reference_id = datasource.party_id))) LEFT JOIN locationplace USING (location_id)) LEFT JOIN place USING (place_id)) LEFT JOIN coordinates USING (coordinates_id)) JOIN locationevent USING (location_id)) LEFT JOIN method USING (method_id)) JOIN taxonoccurrence USING (locationevent_id)) JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) JOIN taxonverbatim datasource_taxonverbatim USING (taxonverbatim_id)) JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) JOIN taxonlabel parsed_taxonlabel ON ((parsed_taxonlabel.taxonlabel_id = datasource_taxonlabel.matched_label_id))) LEFT JOIN taxonverbatim parsed_taxonverbatim ON ((parsed_taxonverbatim.taxonlabel_id = parsed_taxonlabel.taxonlabel_id))) JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) JOIN taxonverbatim accepted_taxonverbatim ON ((accepted_taxonverbatim.taxonlabel_id = accepted_taxonlabel.taxonlabel_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) LEFT JOIN specimenreplicate USING (plantobservation_id)) WHERE ((datasource.reference_id = datasource.party_id) AND (NOT taxondetermination.isoriginal));
1915
    SELECT reference.shortname AS "institutionCode", place.country, place.stateprovince AS "stateProvince", place.county, coordinates.latitude_deg AS "decimalLatitude", coordinates.longitude_deg AS "decimalLongitude", location.sourceaccessioncode AS "plotName", location.elevation_m AS "elevationInMeters", _m2_to_ha(location.area_m2) AS "plotArea_ha", method.name AS "samplingProtocol", aggregateoccurrence.collectiondate AS "dateCollected", accepted_taxonverbatim.family, accepted_taxonverbatim.genus, ((accepted_taxonverbatim.genus || ' '::text) || accepted_taxonverbatim.specific_epithet) AS "speciesBinomial", COALESCE(accepted_taxonverbatim.taxonomicname, accepted_taxonverbatim.taxonname) AS "scientificName", accepted_taxonverbatim.author AS "scientificNameAuthorship", NULLIF(array_to_string(ARRAY[accepted_taxonlabel.taxonomicname, parsed_taxonverbatim.morphospecies], ' '::text), ''::text) AS "scientificNameWithMorphospecies", NULLIF(array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], ' '::text), ''::text) AS "identifiedBy", taxonoccurrence.growthform AS "growthForm", taxonoccurrence.iscultivated AS cultivated, taxonoccurrence.cultivatedbasis AS "cultivatedBasis", _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.verbatimcollectorname AS "recordedBy", plantobservation.collectionnumber AS "recordNumber" FROM (((((((((((((((((((reference JOIN location USING (reference_id)) LEFT JOIN locationplace USING (location_id)) LEFT JOIN place USING (place_id)) LEFT JOIN coordinates USING (coordinates_id)) JOIN locationevent USING (location_id)) LEFT JOIN method USING (method_id)) JOIN taxonoccurrence USING (locationevent_id)) JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) JOIN taxonverbatim reference_taxonverbatim USING (taxonverbatim_id)) JOIN taxonlabel reference_taxonlabel USING (taxonlabel_id)) JOIN taxonlabel parsed_taxonlabel ON ((parsed_taxonlabel.taxonlabel_id = reference_taxonlabel.matched_label_id))) LEFT JOIN taxonverbatim parsed_taxonverbatim ON ((parsed_taxonverbatim.taxonlabel_id = parsed_taxonlabel.taxonlabel_id))) JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = reference_taxonlabel.canon_label_id))) JOIN taxonverbatim accepted_taxonverbatim ON ((accepted_taxonverbatim.taxonlabel_id = accepted_taxonlabel.taxonlabel_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) LEFT JOIN specimenreplicate USING (plantobservation_id)) WHERE (NOT taxondetermination.isoriginal);
1881 1916

  
1882 1917

  
1883 1918
--
......
2936 2971

  
2937 2972

  
2938 2973
--
2939
-- Name: reference; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2940
--
2941

  
2942
CREATE TABLE reference (
2943
    reference_id integer NOT NULL,
2944
    shortname text,
2945
    fulltext text,
2946
    referencetype text,
2947
    title text,
2948
    titlesuperior text,
2949
    referencejournal_id integer,
2950
    volume text,
2951
    issue text,
2952
    pagerange text,
2953
    totalpages integer,
2954
    publisher text,
2955
    publicationplace text,
2956
    isbn text,
2957
    edition text,
2958
    numberofvolumes integer,
2959
    chapternumber integer,
2960
    reportnumber integer,
2961
    communicationtype text,
2962
    degree text,
2963
    url text,
2964
    doi text,
2965
    additionalinfo text,
2966
    pubdate date,
2967
    accessdate date,
2968
    conferencedate date,
2969
    accessioncode text
2970
);
2971

  
2972

  
2973
--
2974 2974
-- Name: reference_reference_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2975 2975
--
2976 2976

  

Also available in: Unified diff