Project

General

Profile

« Previous | Next » 

Revision 6060

schemas/vegbien.sql: analytical_stem_view: Removed join on specimenreplicate, because it isn't used in the analytical DB. Each specimen will still get an entry in analytical_*, because it gets its own location.

View differences:

schemas/vegbien.my.sql
1180 1180

  
1181 1181

  
1182 1182
--
1183
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1184
--
1185

  
1186
CREATE TABLE specimenreplicate (
1187
    specimenreplicate_id int(11) NOT NULL,
1188
    reference_id int(11) NOT NULL,
1189
    sourceaccessioncode text,
1190
    plantobservation_id int(11),
1191
    institution_id int(11),
1192
    collectioncode_dwc text,
1193
    catalognumber_dwc text,
1194
    description text,
1195
    specimen_id int(11),
1196
    accessioncode text
1197
);
1198

  
1199

  
1200
--
1201
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
1202
--
1203

  
1204

  
1205

  
1206

  
1207
--
1208
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
1209
--
1210

  
1211

  
1212

  
1213

  
1214
--
1215
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
1216
--
1217

  
1218

  
1219

  
1220

  
1221
--
1222 1183
-- Name: stemobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1223 1184
--
1224 1185

  
......
2859 2820

  
2860 2821

  
2861 2822
--
2823
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2824
--
2825

  
2826
CREATE TABLE specimenreplicate (
2827
    specimenreplicate_id int(11) NOT NULL,
2828
    reference_id int(11) NOT NULL,
2829
    sourceaccessioncode text,
2830
    plantobservation_id int(11),
2831
    institution_id int(11),
2832
    collectioncode_dwc text,
2833
    catalognumber_dwc text,
2834
    description text,
2835
    specimen_id int(11),
2836
    accessioncode text
2837
);
2838

  
2839

  
2840
--
2841
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
2842
--
2843

  
2844

  
2845

  
2846

  
2847
--
2848
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
2849
--
2850

  
2851

  
2852

  
2853

  
2854
--
2855
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
2856
--
2857

  
2858

  
2859

  
2860

  
2861
--
2862 2862
-- Name: specimenreplicate_specimenreplicate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2863 2863
--
2864 2864

  
schemas/vegbien.sql
1836 1836

  
1837 1837

  
1838 1838
--
1839
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1840
--
1841

  
1842
CREATE TABLE specimenreplicate (
1843
    specimenreplicate_id integer NOT NULL,
1844
    reference_id integer NOT NULL,
1845
    sourceaccessioncode text,
1846
    plantobservation_id integer,
1847
    institution_id integer,
1848
    collectioncode_dwc text,
1849
    catalognumber_dwc text,
1850
    description text,
1851
    specimen_id integer,
1852
    accessioncode text,
1853
    CONSTRAINT specimenreplicate_required_key CHECK ((((plantobservation_id IS NOT NULL) OR (sourceaccessioncode IS NOT NULL)) OR (catalognumber_dwc IS NOT NULL)))
1854
);
1855

  
1856

  
1857
--
1858
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
1859
--
1860

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

  
1863

  
1864
--
1865
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
1866
--
1867

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

  
1870

  
1871
--
1872
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
1873
--
1874

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

  
1877

  
1878
--
1879 1839
-- Name: stemobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1880 1840
--
1881 1841

  
......
2087 2047
--
2088 2048

  
2089 2049
CREATE VIEW analytical_stem_view AS
2090
    SELECT reference.shortname AS "institutionCode", canon_place.country, canon_place.stateprovince AS "stateProvince", datasource_place.county, coordinates.latitude_deg AS "decimalLatitude", coordinates.longitude_deg AS "decimalLongitude", canon_place.georeference_valid AS "georeferenceValid", "newWorldCountries"."isNewWorld", _m_to_km(canon_place.distance_to_country_m) AS "distanceToCountry_km", _m_to_km(canon_place.distance_to_state_m) AS "distanceToStateProvince_km", 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", family_higher_plant_group.higher_plant_group AS "higherPlantGroup", 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 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"."newWorldCountries" ON ((("newWorldCountries"."countryNameStd")::text = canon_place.country))) 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 family_higher_plant_group ON ((family_higher_plant_group.family = accepted_taxonverbatim.family))) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) LEFT JOIN specimenreplicate USING (plantobservation_id)) WHERE (NOT taxondetermination.isoriginal);
2050
    SELECT reference.shortname AS "institutionCode", canon_place.country, canon_place.stateprovince AS "stateProvince", datasource_place.county, coordinates.latitude_deg AS "decimalLatitude", coordinates.longitude_deg AS "decimalLongitude", canon_place.georeference_valid AS "georeferenceValid", "newWorldCountries"."isNewWorld", _m_to_km(canon_place.distance_to_country_m) AS "distanceToCountry_km", _m_to_km(canon_place.distance_to_state_m) AS "distanceToStateProvince_km", 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", family_higher_plant_group.higher_plant_group AS "higherPlantGroup", 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 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"."newWorldCountries" ON ((("newWorldCountries"."countryNameStd")::text = canon_place.country))) 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 family_higher_plant_group ON ((family_higher_plant_group.family = accepted_taxonverbatim.family))) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) WHERE (NOT taxondetermination.isoriginal);
2091 2051

  
2092 2052

  
2093 2053
--
......
3742 3702

  
3743 3703

  
3744 3704
--
3705
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3706
--
3707

  
3708
CREATE TABLE specimenreplicate (
3709
    specimenreplicate_id integer NOT NULL,
3710
    reference_id integer NOT NULL,
3711
    sourceaccessioncode text,
3712
    plantobservation_id integer,
3713
    institution_id integer,
3714
    collectioncode_dwc text,
3715
    catalognumber_dwc text,
3716
    description text,
3717
    specimen_id integer,
3718
    accessioncode text,
3719
    CONSTRAINT specimenreplicate_required_key CHECK ((((plantobservation_id IS NOT NULL) OR (sourceaccessioncode IS NOT NULL)) OR (catalognumber_dwc IS NOT NULL)))
3720
);
3721

  
3722

  
3723
--
3724
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
3725
--
3726

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

  
3729

  
3730
--
3731
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
3732
--
3733

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

  
3736

  
3737
--
3738
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
3739
--
3740

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

  
3743

  
3744
--
3745 3745
-- Name: specimenreplicate_specimenreplicate_id_seq; Type: SEQUENCE; Schema: public; Owner: -
3746 3746
--
3747 3747

  

Also available in: Unified diff