Project

General

Profile

« Previous | Next » 

Revision 6533

schemas/vegbien.sql: Removed no longer needed darwin_core table. Use analytical_stem instead, which is now identical.

View differences:

schemas/vegbien.my.sql
409 409

  
410 410

  
411 411
--
412
-- Name: sync_darwin_core_to_view(); Type: FUNCTION; Schema: public; Owner: -
413
--
414

  
415

  
416

  
417

  
418
--
419 412
-- Name: sync_geoscrub_input_to_view(); Type: FUNCTION; Schema: public; Owner: -
420 413
--
421 414

  
......
1982 1975

  
1983 1976

  
1984 1977
--
1985
-- Name: darwin_core; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1986
--
1987

  
1988
CREATE TABLE darwin_core (
1989
    `institutionCode` varchar(255),
1990
    `subInstitutionCode` varchar(255),
1991
    `collectionCode` varchar(255),
1992
    `catalogNumber` varchar(255),
1993
    `occurrenceID` varchar(255),
1994
    country varchar(255),
1995
    `stateProvince` varchar(255),
1996
    county varchar(255),
1997
    `decimalLatitude` double precision,
1998
    `decimalLongitude` double precision,
1999
    `coordinateUncertaintyInMeters` double precision,
2000
    geovalid int(1),
2001
    `isNewWorld` int(1),
2002
    `projectID` int(11),
2003
    `plotName` varchar(255),
2004
    `elevationInMeters` double precision,
2005
    `plotArea_ha` double precision,
2006
    `samplingProtocol` varchar(255),
2007
    `dateCollected` date,
2008
    `higherPlantGroup` varchar(255),
2009
    family varchar(255),
2010
    genus varchar(255),
2011
    `speciesBinomial` varchar(255),
2012
    `scientificName` varchar(255),
2013
    `scientificNameAuthorship` varchar(255),
2014
    `speciesBinomialWithMorphospecies` varchar(255),
2015
    `scientificNameWithMorphospecies` varchar(255),
2016
    threatened int(1),
2017
    `identifiedBy` varchar(255),
2018
    `growthForm` varchar(255),
2019
    cultivated int(1),
2020
    `cultivatedBasis` varchar(255),
2021
    `recordedBy` varchar(255),
2022
    `recordNumber` varchar(255),
2023
    `coverPercent` double precision,
2024
    `diameterBreastHeight_cm` double precision,
2025
    height_m double precision,
2026
    tag varchar(255),
2027
    `organismX_m` double precision,
2028
    `organismY_m` double precision,
2029
    `taxonOccurrenceID` varchar(255),
2030
    `authorTaxonCode` varchar(255),
2031
    `individualID` varchar(255),
2032
    `authorStemCode` varchar(255)
2033
);
2034

  
2035

  
2036
--
2037
-- Name: darwin_core_view; Type: VIEW; Schema: public; Owner: -
2038
--
2039

  
2040

  
2041

  
2042

  
2043
--
2044 1978
-- Name: dba_preassignacccode_dba_requestnumber_seq; Type: SEQUENCE; Schema: public; Owner: -
2045 1979
--
2046 1980

  
......
4022 3956

  
4023 3957

  
4024 3958
--
4025
-- Data for Name: darwin_core; Type: TABLE DATA; Schema: public; Owner: -
4026
--
4027

  
4028

  
4029

  
4030
--
4031 3959
-- Data for Name: definedvalue; Type: TABLE DATA; Schema: public; Owner: -
4032 3960
--
4033 3961

  
......
5032 4960

  
5033 4961

  
5034 4962
--
5035
-- Name: darwin_core_institutionCode_catalogNumber_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5036
--
5037

  
5038
CREATE INDEX `darwin_core_institutionCode_catalogNumber_idx` ON darwin_core  (`institutionCode`, `catalogNumber`);
5039

  
5040

  
5041
--
5042
-- Name: darwin_core_institutionCode_occurrenceID_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5043
--
5044

  
5045
CREATE INDEX `darwin_core_institutionCode_occurrenceID_idx` ON darwin_core  (`institutionCode`, `occurrenceID`);
5046

  
5047

  
5048
--
5049
-- Name: darwin_core_institutionCode_projectID_plotName_dateCollecte_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5050
--
5051

  
5052
CREATE INDEX `darwin_core_institutionCode_projectID_plotName_dateCollecte_idx` ON darwin_core  (`institutionCode`, `projectID`, `plotName`, `dateCollected`);
5053

  
5054

  
5055
--
5056
-- Name: darwin_core_institutionCode_subInstitutionCode_collectionCo_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5057
--
5058

  
5059
CREATE INDEX `darwin_core_institutionCode_subInstitutionCode_collectionCo_idx` ON darwin_core  (`institutionCode`, `subInstitutionCode`, `collectionCode`, `catalogNumber`);
5060

  
5061

  
5062
--
5063 4963
-- Name: graphic_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5064 4964
--
5065 4965

  
schemas/vegbien.sql
935 935

  
936 936

  
937 937
--
938
-- Name: sync_darwin_core_to_view(); Type: FUNCTION; Schema: public; Owner: -
939
--
940

  
941
CREATE FUNCTION sync_darwin_core_to_view() RETURNS void
942
    LANGUAGE sql
943
    AS $$
944
DROP TABLE IF EXISTS darwin_core;
945
CREATE TABLE darwin_core AS SELECT * FROM darwin_core_view;
946

  
947
CREATE INDEX ON darwin_core ("institutionCode", "projectID", "plotName", "dateCollected" );
948
CREATE INDEX ON darwin_core ("institutionCode", "occurrenceID" );
949
CREATE INDEX ON darwin_core ("institutionCode", "subInstitutionCode", "collectionCode", "catalogNumber" );
950
CREATE INDEX ON darwin_core ("institutionCode", "catalogNumber" );
951
$$;
952

  
953

  
954
--
955 938
-- Name: sync_geoscrub_input_to_view(); Type: FUNCTION; Schema: public; Owner: -
956 939
--
957 940

  
......
2825 2808

  
2826 2809

  
2827 2810
--
2828
-- Name: darwin_core; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2829
--
2830

  
2831
CREATE TABLE darwin_core (
2832
    "institutionCode" text,
2833
    "subInstitutionCode" text,
2834
    "collectionCode" text,
2835
    "catalogNumber" text,
2836
    "occurrenceID" text,
2837
    country text,
2838
    "stateProvince" text,
2839
    county text,
2840
    "decimalLatitude" double precision,
2841
    "decimalLongitude" double precision,
2842
    "coordinateUncertaintyInMeters" double precision,
2843
    geovalid boolean,
2844
    "isNewWorld" boolean,
2845
    "projectID" integer,
2846
    "plotName" text,
2847
    "elevationInMeters" double precision,
2848
    "plotArea_ha" double precision,
2849
    "samplingProtocol" text,
2850
    "dateCollected" date,
2851
    "higherPlantGroup" higher_plant_group,
2852
    family text,
2853
    genus text,
2854
    "speciesBinomial" text,
2855
    "scientificName" text,
2856
    "scientificNameAuthorship" text,
2857
    "speciesBinomialWithMorphospecies" text,
2858
    "scientificNameWithMorphospecies" text,
2859
    threatened boolean,
2860
    "identifiedBy" text,
2861
    "growthForm" growthform,
2862
    cultivated boolean,
2863
    "cultivatedBasis" text,
2864
    "recordedBy" text,
2865
    "recordNumber" text,
2866
    "coverPercent" double precision,
2867
    "diameterBreastHeight_cm" double precision,
2868
    height_m double precision,
2869
    tag text,
2870
    "organismX_m" double precision,
2871
    "organismY_m" double precision,
2872
    "taxonOccurrenceID" text,
2873
    "authorTaxonCode" text,
2874
    "individualID" text,
2875
    "authorStemCode" text
2876
);
2877

  
2878

  
2879
--
2880
-- Name: darwin_core_view; Type: VIEW; Schema: public; Owner: -
2881
--
2882

  
2883
CREATE VIEW darwin_core_view AS
2884
    SELECT source.shortname AS "institutionCode", sourcename.name AS "subInstitutionCode", 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, "newWorldCountries"."isNewWorld", locationevent.project_id AS "projectID", COALESCE(location.sourceaccessioncode, location.authorlocationcode) AS "plotName", location.elevation_m AS "elevationInMeters", _m2_to_ha(location.area_m2) AS "plotArea_ha", method.name AS "samplingProtocol", COALESCE(locationevent.obsstartdate, parent_plot_event.obsstartdate, 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[COALESCE(accepted_taxonverbatim.genus, accepted_taxonverbatim.family), COALESCE(accepted_taxonverbatim.specific_epithet, parsed_taxonverbatim.morphospecies)], ' '::text), ''::text) AS "speciesBinomialWithMorphospecies", NULLIF(array_to_string(ARRAY[accepted_taxonverbatim.taxonomicname, parsed_taxonverbatim.morphospecies], ' '::text), ''::text) AS "scientificNameWithMorphospecies", (threatened_taxonlabel.taxonlabel_id IS NOT NULL) AS threatened, identifiedby.fullname AS "identifiedBy", taxonoccurrence.growthform AS "growthForm", ((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, location.iscultivated)) 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 "individualID", stemobservation.authorstemcode AS "authorStemCode" FROM (((((((((((((((((((((((((((((source JOIN location USING (source_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".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 locationevent USING (location_id)) LEFT JOIN project USING (project_id)) LEFT JOIN method USING (method_id)) LEFT JOIN taxonoccurrence USING (locationevent_id)) LEFT JOIN locationevent parent_plot_event ON ((parent_plot_event.locationevent_id = locationevent.parent_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 datasource_taxonverbatim USING (taxonverbatim_id)) LEFT JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) LEFT 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))) LEFT JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) LEFT JOIN taxonverbatim accepted_taxonverbatim ON ((accepted_taxonverbatim.taxonlabel_id = accepted_taxonlabel.taxonlabel_id))) LEFT JOIN threatened_taxonlabel ON ((threatened_taxonlabel.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 cultivated_family_locations ON (((cultivated_family_locations.family = accepted_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 sourcename ON ((sourcename.sourcename_id = specimenreplicate.institution_id)));
2885

  
2886

  
2887
--
2888 2811
-- Name: dba_preassignacccode_dba_requestnumber_seq; Type: SEQUENCE; Schema: public; Owner: -
2889 2812
--
2890 2813

  
......
5099 5022

  
5100 5023

  
5101 5024
--
5102
-- Data for Name: darwin_core; Type: TABLE DATA; Schema: public; Owner: -
5103
--
5104

  
5105

  
5106

  
5107
--
5108 5025
-- Data for Name: definedvalue; Type: TABLE DATA; Schema: public; Owner: -
5109 5026
--
5110 5027

  
......
6109 6026

  
6110 6027

  
6111 6028
--
6112
-- Name: darwin_core_institutionCode_catalogNumber_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6113
--
6114

  
6115
CREATE INDEX "darwin_core_institutionCode_catalogNumber_idx" ON darwin_core USING btree ("institutionCode", "catalogNumber");
6116

  
6117

  
6118
--
6119
-- Name: darwin_core_institutionCode_occurrenceID_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6120
--
6121

  
6122
CREATE INDEX "darwin_core_institutionCode_occurrenceID_idx" ON darwin_core USING btree ("institutionCode", "occurrenceID");
6123

  
6124

  
6125
--
6126
-- Name: darwin_core_institutionCode_projectID_plotName_dateCollecte_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6127
--
6128

  
6129
CREATE INDEX "darwin_core_institutionCode_projectID_plotName_dateCollecte_idx" ON darwin_core USING btree ("institutionCode", "projectID", "plotName", "dateCollected");
6130

  
6131

  
6132
--
6133
-- Name: darwin_core_institutionCode_subInstitutionCode_collectionCo_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6134
--
6135

  
6136
CREATE INDEX "darwin_core_institutionCode_subInstitutionCode_collectionCo_idx" ON darwin_core USING btree ("institutionCode", "subInstitutionCode", "collectionCode", "catalogNumber");
6137

  
6138

  
6139
--
6140 6029
-- Name: graphic_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6141 6030
--
6142 6031

  
bin/make_analytical_db
37 37

  
38 38
$(mk_analytical_table analytical_stem)
39 39
$(mk_analytical_table analytical_aggregate)
40
$(mk_analytical_table darwin_core)
41 40
EOF

Also available in: Unified diff