Project

General

Profile

« Previous | Next » 

Revision 6531

schemas/vegbien.sql: Merged darwin_core into analytical_stem

View differences:

schemas/vegbien.my.sql
718 718
    `coordinateUncertaintyInMeters` double precision,
719 719
    geovalid int(1),
720 720
    `isNewWorld` int(1),
721
    `distanceToCountry_km` double precision,
722
    `distanceToStateProvince_km` double precision,
723 721
    `plotName` varchar(255) NOT NULL,
724 722
    `elevationInMeters` double precision,
725 723
    `plotArea_ha` double precision,
......
751 749

  
752 750
CREATE TABLE analytical_stem (
753 751
    `institutionCode` varchar(255) NOT NULL,
752
    `subInstitutionCode` varchar(255),
753
    `collectionCode` varchar(255),
754
    `catalogNumber` varchar(255),
755
    `occurrenceID` varchar(255),
754 756
    country varchar(255),
755 757
    `stateProvince` varchar(255),
756 758
    county varchar(255),
......
759 761
    `coordinateUncertaintyInMeters` double precision,
760 762
    geovalid int(1),
761 763
    `isNewWorld` int(1),
762
    `distanceToCountry_km` double precision,
763
    `distanceToStateProvince_km` double precision,
764
    `projectID` int(11),
764 765
    `plotName` varchar(255) NOT NULL,
765 766
    `elevationInMeters` double precision,
766 767
    `plotArea_ha` double precision,
......
772 773
    `speciesBinomial` varchar(255),
773 774
    `scientificName` varchar(255),
774 775
    `scientificNameAuthorship` varchar(255),
776
    `speciesBinomialWithMorphospecies` varchar(255),
775 777
    `scientificNameWithMorphospecies` varchar(255),
776 778
    threatened int(1),
777 779
    `identifiedBy` varchar(255),
778 780
    `growthForm` varchar(255),
779 781
    cultivated int(1),
780 782
    `cultivatedBasis` varchar(255),
783
    `recordedBy` varchar(255),
784
    `recordNumber` varchar(255),
781 785
    `coverPercent` double precision,
782 786
    `diameterBreastHeight_cm` double precision,
783 787
    height_m double precision,
784 788
    tag varchar(255),
785 789
    `organismX_m` double precision,
786 790
    `organismY_m` double precision,
787
    `recordedBy` varchar(255),
788
    `recordNumber` varchar(255)
791
    `taxonOccurrenceID` varchar(255),
792
    `authorTaxonCode` varchar(255),
793
    `individualID` varchar(255),
794
    `authorStemCode` varchar(255)
789 795
);
790 796

  
791 797

  
......
1240 1246

  
1241 1247

  
1242 1248
--
1249
-- Name: project; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1250
--
1251

  
1252
CREATE TABLE project (
1253
    project_id int(11) NOT NULL,
1254
    source_id int(11) NOT NULL,
1255
    sourceaccessioncode varchar(255),
1256
    projectname varchar(255),
1257
    projectdescription varchar(255),
1258
    startdate date,
1259
    stopdate date,
1260
    accessioncode varchar(255)
1261
);
1262

  
1263

  
1264
--
1243 1265
-- Name: source; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1244 1266
--
1245 1267

  
......
1279 1301

  
1280 1302

  
1281 1303
--
1304
-- Name: sourcename; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1305
--
1306

  
1307
CREATE TABLE sourcename (
1308
    sourcename_id int(11) NOT NULL,
1309
    source_id int(11) NOT NULL,
1310
    system varchar(255),
1311
    name varchar(255) NOT NULL,
1312
    matched_source_id int(11)
1313
);
1314

  
1315

  
1316
--
1317
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1318
--
1319

  
1320
CREATE TABLE specimenreplicate (
1321
    specimenreplicate_id int(11) NOT NULL,
1322
    source_id int(11) NOT NULL,
1323
    sourceaccessioncode varchar(255),
1324
    plantobservation_id int(11),
1325
    institution_id int(11),
1326
    collectioncode_dwc varchar(255),
1327
    catalognumber_dwc varchar(255),
1328
    description varchar(255),
1329
    specimen_id int(11),
1330
    accessioncode varchar(255)
1331
);
1332

  
1333

  
1334
--
1335
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
1336
--
1337

  
1338

  
1339

  
1340

  
1341
--
1342
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
1343
--
1344

  
1345

  
1346

  
1347

  
1348
--
1349
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
1350
--
1351

  
1352

  
1353

  
1354

  
1355
--
1282 1356
-- Name: stemobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1283 1357
--
1284 1358

  
......
1960 2034

  
1961 2035

  
1962 2036
--
1963
-- Name: project; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1964
--
1965

  
1966
CREATE TABLE project (
1967
    project_id int(11) NOT NULL,
1968
    source_id int(11) NOT NULL,
1969
    sourceaccessioncode varchar(255),
1970
    projectname varchar(255),
1971
    projectdescription varchar(255),
1972
    startdate date,
1973
    stopdate date,
1974
    accessioncode varchar(255)
1975
);
1976

  
1977

  
1978
--
1979
-- Name: sourcename; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1980
--
1981

  
1982
CREATE TABLE sourcename (
1983
    sourcename_id int(11) NOT NULL,
1984
    source_id int(11) NOT NULL,
1985
    system varchar(255),
1986
    name varchar(255) NOT NULL,
1987
    matched_source_id int(11)
1988
);
1989

  
1990

  
1991
--
1992
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1993
--
1994

  
1995
CREATE TABLE specimenreplicate (
1996
    specimenreplicate_id int(11) NOT NULL,
1997
    source_id int(11) NOT NULL,
1998
    sourceaccessioncode varchar(255),
1999
    plantobservation_id int(11),
2000
    institution_id int(11),
2001
    collectioncode_dwc varchar(255),
2002
    catalognumber_dwc varchar(255),
2003
    description varchar(255),
2004
    specimen_id int(11),
2005
    accessioncode varchar(255)
2006
);
2007

  
2008

  
2009
--
2010
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
2011
--
2012

  
2013

  
2014

  
2015

  
2016
--
2017
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
2018
--
2019

  
2020

  
2021

  
2022

  
2023
--
2024
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
2025
--
2026

  
2027

  
2028

  
2029

  
2030
--
2031 2037
-- Name: darwin_core_view; Type: VIEW; Schema: public; Owner: -
2032 2038
--
2033 2039

  
......
4963 4969

  
4964 4970

  
4965 4971
--
4966
-- Name: analytical_stem_institutionCode_plotName_dateCollected_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4972
-- Name: analytical_stem_institutionCode_occurrenceID_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4967 4973
--
4968 4974

  
4969
CREATE INDEX `analytical_stem_institutionCode_plotName_dateCollected_idx` ON analytical_stem  (`institutionCode`, `plotName`, `dateCollected`);
4975
CREATE INDEX `analytical_stem_institutionCode_occurrenceID_idx` ON analytical_stem  (`institutionCode`, `occurrenceID`);
4970 4976

  
4971 4977

  
4972 4978
--
4979
-- Name: analytical_stem_institutionCode_projectID_plotName_dateColl_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4980
--
4981

  
4982
CREATE INDEX `analytical_stem_institutionCode_projectID_plotName_dateColl_idx` ON analytical_stem  (`institutionCode`, `projectID`, `plotName`, `dateCollected`);
4983

  
4984

  
4985
--
4986
-- Name: analytical_stem_institutionCode_subInstitutionCode_collecti_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4987
--
4988

  
4989
CREATE INDEX `analytical_stem_institutionCode_subInstitutionCode_collecti_idx` ON analytical_stem  (`institutionCode`, `subInstitutionCode`, `collectionCode`, `catalogNumber`);
4990

  
4991

  
4992
--
4973 4993
-- Name: commclass_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4974 4994
--
4975 4995

  
......
5540 5560
-- Name: address_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5541 5561
--
5542 5562

  
5543
ALTER TABLE address
5544
    ADD CONSTRAINT address_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;
5545 5563

  
5546 5564

  
5565

  
5547 5566
--
5548 5567
-- Name: address_party_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5549 5568
--
......
6020 6039
-- Name: partymember_parentparty_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
6021 6040
--
6022 6041

  
6023
ALTER TABLE partymember
6024
    ADD CONSTRAINT partymember_parentparty_id_fkey FOREIGN KEY (parentparty_id) REFERENCES party(party_id) ON UPDATE CASCADE ON DELETE CASCADE;
6025 6042

  
6026 6043

  
6044

  
6027 6045
--
6028 6046
-- Name: place_canon_place_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
6029 6047
--
......
6657 6675

  
6658 6676

  
6659 6677
--
6660
-- Name: source; Type: ACL; Schema: public; Owner: -
6678
-- Name: project; Type: ACL; Schema: public; Owner: -
6661 6679
--
6662 6680

  
6663 6681

  
......
6667 6685

  
6668 6686

  
6669 6687
--
6670
-- Name: stemobservation; Type: ACL; Schema: public; Owner: -
6688
-- Name: source; Type: ACL; Schema: public; Owner: -
6671 6689
--
6672 6690

  
6673 6691

  
......
6677 6695

  
6678 6696

  
6679 6697
--
6680
-- Name: taxondetermination; Type: ACL; Schema: public; Owner: -
6698
-- Name: sourcename; Type: ACL; Schema: public; Owner: -
6681 6699
--
6682 6700

  
6683 6701

  
......
6687 6705

  
6688 6706

  
6689 6707
--
6690
-- Name: taxonoccurrence; Type: ACL; Schema: public; Owner: -
6708
-- Name: specimenreplicate; Type: ACL; Schema: public; Owner: -
6691 6709
--
6692 6710

  
6693 6711

  
......
6697 6715

  
6698 6716

  
6699 6717
--
6700
-- Name: taxonverbatim; Type: ACL; Schema: public; Owner: -
6718
-- Name: stemobservation; Type: ACL; Schema: public; Owner: -
6701 6719
--
6702 6720

  
6703 6721

  
......
6707 6725

  
6708 6726

  
6709 6727
--
6710
-- Name: threatened_taxonlabel; Type: ACL; Schema: public; Owner: -
6728
-- Name: taxondetermination; Type: ACL; Schema: public; Owner: -
6711 6729
--
6712 6730

  
6713 6731

  
......
6717 6735

  
6718 6736

  
6719 6737
--
6720
-- Name: analytical_stem_view; Type: ACL; Schema: public; Owner: -
6738
-- Name: taxonoccurrence; Type: ACL; Schema: public; Owner: -
6721 6739
--
6722 6740

  
6723 6741

  
......
6727 6745

  
6728 6746

  
6729 6747
--
6730
-- Name: classcontributor; Type: ACL; Schema: public; Owner: -
6748
-- Name: taxonverbatim; Type: ACL; Schema: public; Owner: -
6731 6749
--
6732 6750

  
6733 6751

  
......
6737 6755

  
6738 6756

  
6739 6757
--
6740
-- Name: commclass; Type: ACL; Schema: public; Owner: -
6758
-- Name: threatened_taxonlabel; Type: ACL; Schema: public; Owner: -
6741 6759
--
6742 6760

  
6743 6761

  
......
6747 6765

  
6748 6766

  
6749 6767
--
6750
-- Name: commconcept; Type: ACL; Schema: public; Owner: -
6768
-- Name: analytical_stem_view; Type: ACL; Schema: public; Owner: -
6751 6769
--
6752 6770

  
6753 6771

  
......
6757 6775

  
6758 6776

  
6759 6777
--
6760
-- Name: commcorrelation; Type: ACL; Schema: public; Owner: -
6778
-- Name: classcontributor; Type: ACL; Schema: public; Owner: -
6761 6779
--
6762 6780

  
6763 6781

  
......
6767 6785

  
6768 6786

  
6769 6787
--
6770
-- Name: commdetermination; Type: ACL; Schema: public; Owner: -
6788
-- Name: commclass; Type: ACL; Schema: public; Owner: -
6771 6789
--
6772 6790

  
6773 6791

  
......
6777 6795

  
6778 6796

  
6779 6797
--
6780
-- Name: commlineage; Type: ACL; Schema: public; Owner: -
6798
-- Name: commconcept; Type: ACL; Schema: public; Owner: -
6781 6799
--
6782 6800

  
6783 6801

  
......
6787 6805

  
6788 6806

  
6789 6807
--
6790
-- Name: commname; Type: ACL; Schema: public; Owner: -
6808
-- Name: commcorrelation; Type: ACL; Schema: public; Owner: -
6791 6809
--
6792 6810

  
6793 6811

  
......
6797 6815

  
6798 6816

  
6799 6817
--
6800
-- Name: commstatus; Type: ACL; Schema: public; Owner: -
6818
-- Name: commdetermination; Type: ACL; Schema: public; Owner: -
6801 6819
--
6802 6820

  
6803 6821

  
......
6807 6825

  
6808 6826

  
6809 6827
--
6810
-- Name: commusage; Type: ACL; Schema: public; Owner: -
6828
-- Name: commlineage; Type: ACL; Schema: public; Owner: -
6811 6829
--
6812 6830

  
6813 6831

  
......
6817 6835

  
6818 6836

  
6819 6837
--
6820
-- Name: coverindex; Type: ACL; Schema: public; Owner: -
6838
-- Name: commname; Type: ACL; Schema: public; Owner: -
6821 6839
--
6822 6840

  
6823 6841

  
......
6827 6845

  
6828 6846

  
6829 6847
--
6830
-- Name: covermethod; Type: ACL; Schema: public; Owner: -
6848
-- Name: commstatus; Type: ACL; Schema: public; Owner: -
6831 6849
--
6832 6850

  
6833 6851

  
......
6837 6855

  
6838 6856

  
6839 6857
--
6840
-- Name: project; Type: ACL; Schema: public; Owner: -
6858
-- Name: commusage; Type: ACL; Schema: public; Owner: -
6841 6859
--
6842 6860

  
6843 6861

  
......
6847 6865

  
6848 6866

  
6849 6867
--
6850
-- Name: sourcename; Type: ACL; Schema: public; Owner: -
6868
-- Name: coverindex; Type: ACL; Schema: public; Owner: -
6851 6869
--
6852 6870

  
6853 6871

  
......
6857 6875

  
6858 6876

  
6859 6877
--
6860
-- Name: specimenreplicate; Type: ACL; Schema: public; Owner: -
6878
-- Name: covermethod; Type: ACL; Schema: public; Owner: -
6861 6879
--
6862 6880

  
6863 6881

  
schemas/filter_ERD.csv
11 11
"^ALTER TABLE (?!sourcecontributor)\b[^;]*\bFOREIGN KEY\b[^;]*\((?:source_id|commauthority_id|concept_reference_id)\) REFERENCES source\b[^;]*;",,inward
12 12
"^ALTER TABLE \b[^;]*\bFOREIGN KEY\b[^;]*\bREFERENCES sourcename\b[^;]*;",,inward
13 13
"^ALTER TABLE (?:projectcontributor)\b[^;]*\bFOREIGN KEY\b[^;]*\((?:project_id)\) REFERENCES \b[^;]*;",,inward
14
"^ALTER TABLE (?:partymember)\b[^;]*\bFOREIGN KEY\b[^;]*\((?:parentparty_id)\) REFERENCES \b[^;]*;",,inward
15
"^ALTER TABLE (?:address)\b[^;]*\bFOREIGN KEY\b[^;]*\((?:organization_id)\) REFERENCES \b[^;]*;",,inward
schemas/vegbien.sql
928 928
ALTER TABLE analytical_stem ALTER COLUMN "institutionCode" SET NOT NULL;
929 929
ALTER TABLE analytical_stem ALTER COLUMN "plotName" SET NOT NULL;
930 930

  
931
CREATE INDEX ON analytical_stem ("institutionCode", "plotName", "dateCollected" );
931
CREATE INDEX ON analytical_stem ("institutionCode", "occurrenceID" );
932
CREATE INDEX ON analytical_stem ("institutionCode", "subInstitutionCode", "collectionCode", "catalogNumber" );
933
CREATE INDEX ON analytical_stem ("institutionCode", "projectID", "plotName", "dateCollected" );
932 934
$$;
933 935

  
934 936

  
......
1462 1464
    "coordinateUncertaintyInMeters" double precision,
1463 1465
    geovalid boolean,
1464 1466
    "isNewWorld" boolean,
1465
    "distanceToCountry_km" double precision,
1466
    "distanceToStateProvince_km" double precision,
1467 1467
    "plotName" text NOT NULL,
1468 1468
    "elevationInMeters" double precision,
1469 1469
    "plotArea_ha" double precision,
......
1495 1495

  
1496 1496
CREATE TABLE analytical_stem (
1497 1497
    "institutionCode" text NOT NULL,
1498
    "subInstitutionCode" text,
1499
    "collectionCode" text,
1500
    "catalogNumber" text,
1501
    "occurrenceID" text,
1498 1502
    country text,
1499 1503
    "stateProvince" text,
1500 1504
    county text,
......
1503 1507
    "coordinateUncertaintyInMeters" double precision,
1504 1508
    geovalid boolean,
1505 1509
    "isNewWorld" boolean,
1506
    "distanceToCountry_km" double precision,
1507
    "distanceToStateProvince_km" double precision,
1510
    "projectID" integer,
1508 1511
    "plotName" text NOT NULL,
1509 1512
    "elevationInMeters" double precision,
1510 1513
    "plotArea_ha" double precision,
......
1516 1519
    "speciesBinomial" text,
1517 1520
    "scientificName" text,
1518 1521
    "scientificNameAuthorship" text,
1522
    "speciesBinomialWithMorphospecies" text,
1519 1523
    "scientificNameWithMorphospecies" text,
1520 1524
    threatened boolean,
1521 1525
    "identifiedBy" text,
1522 1526
    "growthForm" growthform,
1523 1527
    cultivated boolean,
1524 1528
    "cultivatedBasis" text,
1529
    "recordedBy" text,
1530
    "recordNumber" text,
1525 1531
    "coverPercent" double precision,
1526 1532
    "diameterBreastHeight_cm" double precision,
1527 1533
    height_m double precision,
1528 1534
    tag text,
1529 1535
    "organismX_m" double precision,
1530 1536
    "organismY_m" double precision,
1531
    "recordedBy" text,
1532
    "recordNumber" text
1537
    "taxonOccurrenceID" text,
1538
    "authorTaxonCode" text,
1539
    "individualID" text,
1540
    "authorStemCode" text
1533 1541
);
1534 1542

  
1535 1543

  
......
1538 1546
--
1539 1547

  
1540 1548
CREATE VIEW analytical_aggregate_view AS
1541
    SELECT analytical_stem."institutionCode", analytical_stem.country, analytical_stem."stateProvince", analytical_stem.county, analytical_stem."decimalLatitude", analytical_stem."decimalLongitude", analytical_stem."coordinateUncertaintyInMeters", analytical_stem.geovalid, analytical_stem."isNewWorld", analytical_stem."distanceToCountry_km", analytical_stem."distanceToStateProvince_km", analytical_stem."plotName", analytical_stem."elevationInMeters", analytical_stem."plotArea_ha", analytical_stem."samplingProtocol", analytical_stem."dateCollected", analytical_stem."higherPlantGroup", analytical_stem.family, analytical_stem.genus, analytical_stem."speciesBinomial", analytical_stem."scientificName", analytical_stem."scientificNameAuthorship", analytical_stem."scientificNameWithMorphospecies", analytical_stem.threatened, analytical_stem."identifiedBy", analytical_stem."growthForm", analytical_stem.cultivated, analytical_stem."cultivatedBasis", sum(analytical_stem."coverPercent") AS "coverPercent", count(analytical_stem."diameterBreastHeight_cm") AS "individualCount", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((1)::double precision))) AS "individualCount_1cm_or_more", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((2.5)::double precision))) AS "individualCount_2_5cm_or_more", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((10)::double precision))) AS "individualCount_10cm_or_more" FROM analytical_stem GROUP BY analytical_stem."institutionCode", analytical_stem.country, analytical_stem."stateProvince", analytical_stem.county, analytical_stem."decimalLatitude", analytical_stem."decimalLongitude", analytical_stem."coordinateUncertaintyInMeters", analytical_stem.geovalid, analytical_stem."isNewWorld", analytical_stem."distanceToCountry_km", analytical_stem."distanceToStateProvince_km", analytical_stem."plotName", analytical_stem."elevationInMeters", analytical_stem."plotArea_ha", analytical_stem."samplingProtocol", analytical_stem."dateCollected", analytical_stem."higherPlantGroup", analytical_stem.family, analytical_stem.genus, analytical_stem."speciesBinomial", analytical_stem."scientificName", analytical_stem."scientificNameAuthorship", analytical_stem."scientificNameWithMorphospecies", analytical_stem.threatened, analytical_stem."identifiedBy", analytical_stem."growthForm", analytical_stem.cultivated, analytical_stem."cultivatedBasis";
1549
    SELECT analytical_stem."institutionCode", analytical_stem.country, analytical_stem."stateProvince", analytical_stem.county, analytical_stem."decimalLatitude", analytical_stem."decimalLongitude", analytical_stem."coordinateUncertaintyInMeters", analytical_stem.geovalid, analytical_stem."isNewWorld", analytical_stem."plotName", analytical_stem."elevationInMeters", analytical_stem."plotArea_ha", analytical_stem."samplingProtocol", analytical_stem."dateCollected", analytical_stem."higherPlantGroup", analytical_stem.family, analytical_stem.genus, analytical_stem."speciesBinomial", analytical_stem."scientificName", analytical_stem."scientificNameAuthorship", analytical_stem."scientificNameWithMorphospecies", analytical_stem.threatened, analytical_stem."identifiedBy", analytical_stem."growthForm", analytical_stem.cultivated, analytical_stem."cultivatedBasis", sum(analytical_stem."coverPercent") AS "coverPercent", count(analytical_stem."diameterBreastHeight_cm") AS "individualCount", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((1)::double precision))) AS "individualCount_1cm_or_more", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((2.5)::double precision))) AS "individualCount_2_5cm_or_more", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((10)::double precision))) AS "individualCount_10cm_or_more" FROM analytical_stem GROUP BY analytical_stem."institutionCode", analytical_stem.country, analytical_stem."stateProvince", analytical_stem.county, analytical_stem."decimalLatitude", analytical_stem."decimalLongitude", analytical_stem."coordinateUncertaintyInMeters", analytical_stem.geovalid, analytical_stem."isNewWorld", analytical_stem."plotName", analytical_stem."elevationInMeters", analytical_stem."plotArea_ha", analytical_stem."samplingProtocol", analytical_stem."dateCollected", analytical_stem."higherPlantGroup", analytical_stem.family, analytical_stem.genus, analytical_stem."speciesBinomial", analytical_stem."scientificName", analytical_stem."scientificNameAuthorship", analytical_stem."scientificNameWithMorphospecies", analytical_stem.threatened, analytical_stem."identifiedBy", analytical_stem."growthForm", analytical_stem.cultivated, analytical_stem."cultivatedBasis";
1542 1550

  
1543 1551

  
1544 1552
--
......
2013 2021

  
2014 2022

  
2015 2023
--
2024
-- Name: project; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2025
--
2026

  
2027
CREATE TABLE project (
2028
    project_id integer NOT NULL,
2029
    source_id integer NOT NULL,
2030
    sourceaccessioncode text,
2031
    projectname text,
2032
    projectdescription text,
2033
    startdate date,
2034
    stopdate date,
2035
    accessioncode text,
2036
    CONSTRAINT project_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (projectname IS NOT NULL)))
2037
);
2038

  
2039

  
2040
--
2016 2041
-- Name: source; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2017 2042
--
2018 2043

  
......
2052 2077

  
2053 2078

  
2054 2079
--
2080
-- Name: sourcename; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2081
--
2082

  
2083
CREATE TABLE sourcename (
2084
    sourcename_id integer NOT NULL,
2085
    source_id integer NOT NULL,
2086
    system text,
2087
    name text NOT NULL,
2088
    matched_source_id integer
2089
);
2090

  
2091

  
2092
--
2093
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2094
--
2095

  
2096
CREATE TABLE specimenreplicate (
2097
    specimenreplicate_id integer NOT NULL,
2098
    source_id integer NOT NULL,
2099
    sourceaccessioncode text,
2100
    plantobservation_id integer,
2101
    institution_id integer,
2102
    collectioncode_dwc text,
2103
    catalognumber_dwc text,
2104
    description text,
2105
    specimen_id integer,
2106
    accessioncode text,
2107
    CONSTRAINT specimenreplicate_required_key CHECK ((((plantobservation_id IS NOT NULL) OR (sourceaccessioncode IS NOT NULL)) OR (catalognumber_dwc IS NOT NULL)))
2108
);
2109

  
2110

  
2111
--
2112
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
2113
--
2114

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

  
2117

  
2118
--
2119
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
2120
--
2121

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

  
2124

  
2125
--
2126
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
2127
--
2128

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

  
2131

  
2132
--
2055 2133
-- Name: stemobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2056 2134
--
2057 2135

  
......
2273 2351
--
2274 2352

  
2275 2353
CREATE VIEW analytical_stem_view AS
2276
    SELECT source.shortname AS "institutionCode", 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", _m_to_km(canon_place.distance_to_country_m) AS "distanceToCountry_km", _m_to_km(canon_place.distance_to_state_m) AS "distanceToStateProvince_km", 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 "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", _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", collector.fullname AS "recordedBy", NULLIF(array_to_string(ARRAY[taxonoccurrence.sourceaccessioncode, taxonoccurrence.authortaxoncode, plantobservation.sourceaccessioncode, plantobservation.collectionnumber, stemobservation.sourceaccessioncode, stemobservation.authorstemcode, stemobservation.tag], '; '::text), ''::text) AS "recordNumber" 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 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)) WHERE taxondetermination.iscurrent;
2354
    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, 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 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)));
2277 2355

  
2278 2356

  
2279 2357
--
......
2799 2877

  
2800 2878

  
2801 2879
--
2802
-- Name: project; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2803
--
2804

  
2805
CREATE TABLE project (
2806
    project_id integer NOT NULL,
2807
    source_id integer NOT NULL,
2808
    sourceaccessioncode text,
2809
    projectname text,
2810
    projectdescription text,
2811
    startdate date,
2812
    stopdate date,
2813
    accessioncode text,
2814
    CONSTRAINT project_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (projectname IS NOT NULL)))
2815
);
2816

  
2817

  
2818
--
2819
-- Name: sourcename; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2820
--
2821

  
2822
CREATE TABLE sourcename (
2823
    sourcename_id integer NOT NULL,
2824
    source_id integer NOT NULL,
2825
    system text,
2826
    name text NOT NULL,
2827
    matched_source_id integer
2828
);
2829

  
2830

  
2831
--
2832
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2833
--
2834

  
2835
CREATE TABLE specimenreplicate (
2836
    specimenreplicate_id integer NOT NULL,
2837
    source_id integer NOT NULL,
2838
    sourceaccessioncode text,
2839
    plantobservation_id integer,
2840
    institution_id integer,
2841
    collectioncode_dwc text,
2842
    catalognumber_dwc text,
2843
    description text,
2844
    specimen_id integer,
2845
    accessioncode text,
2846
    CONSTRAINT specimenreplicate_required_key CHECK ((((plantobservation_id IS NOT NULL) OR (sourceaccessioncode IS NOT NULL)) OR (catalognumber_dwc IS NOT NULL)))
2847
);
2848

  
2849

  
2850
--
2851
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: -
2852
--
2853

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

  
2856

  
2857
--
2858
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: -
2859
--
2860

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

  
2863

  
2864
--
2865
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: -
2866
--
2867

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

  
2870

  
2871
--
2872 2880
-- Name: darwin_core_view; Type: VIEW; Schema: public; Owner: -
2873 2881
--
2874 2882

  
......
6038 6046

  
6039 6047

  
6040 6048
--
6041
-- Name: analytical_stem_institutionCode_plotName_dateCollected_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6049
-- Name: analytical_stem_institutionCode_occurrenceID_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6042 6050
--
6043 6051

  
6044
CREATE INDEX "analytical_stem_institutionCode_plotName_dateCollected_idx" ON analytical_stem USING btree ("institutionCode", "plotName", "dateCollected");
6052
CREATE INDEX "analytical_stem_institutionCode_occurrenceID_idx" ON analytical_stem USING btree ("institutionCode", "occurrenceID");
6045 6053

  
6046 6054

  
6047 6055
--
6056
-- Name: analytical_stem_institutionCode_projectID_plotName_dateColl_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6057
--
6058

  
6059
CREATE INDEX "analytical_stem_institutionCode_projectID_plotName_dateColl_idx" ON analytical_stem USING btree ("institutionCode", "projectID", "plotName", "dateCollected");
6060

  
6061

  
6062
--
6063
-- Name: analytical_stem_institutionCode_subInstitutionCode_collecti_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6064
--
6065

  
6066
CREATE INDEX "analytical_stem_institutionCode_subInstitutionCode_collecti_idx" ON analytical_stem USING btree ("institutionCode", "subInstitutionCode", "collectionCode", "catalogNumber");
6067

  
6068

  
6069
--
6048 6070
-- Name: commclass_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
6049 6071
--
6050 6072

  
......
7778 7800

  
7779 7801

  
7780 7802
--
7803
-- Name: project; Type: ACL; Schema: public; Owner: -
7804
--
7805

  
7806
REVOKE ALL ON TABLE project FROM PUBLIC;
7807
REVOKE ALL ON TABLE project FROM bien;
7808
GRANT ALL ON TABLE project TO bien;
7809
GRANT SELECT ON TABLE project TO bien_read;
7810

  
7811

  
7812
--
7781 7813
-- Name: source; Type: ACL; Schema: public; Owner: -
7782 7814
--
7783 7815

  
......
7788 7820

  
7789 7821

  
7790 7822
--
7823
-- Name: sourcename; Type: ACL; Schema: public; Owner: -
7824
--
7825

  
7826
REVOKE ALL ON TABLE sourcename FROM PUBLIC;
7827
REVOKE ALL ON TABLE sourcename FROM bien;
7828
GRANT ALL ON TABLE sourcename TO bien;
7829
GRANT SELECT ON TABLE sourcename TO bien_read;
7830

  
7831

  
7832
--
7833
-- Name: specimenreplicate; Type: ACL; Schema: public; Owner: -
7834
--
7835

  
7836
REVOKE ALL ON TABLE specimenreplicate FROM PUBLIC;
7837
REVOKE ALL ON TABLE specimenreplicate FROM bien;
7838
GRANT ALL ON TABLE specimenreplicate TO bien;
7839
GRANT SELECT ON TABLE specimenreplicate TO bien_read;
7840

  
7841

  
7842
--
7791 7843
-- Name: stemobservation; Type: ACL; Schema: public; Owner: -
7792 7844
--
7793 7845

  
......
7958 8010

  
7959 8011

  
7960 8012
--
7961
-- Name: project; Type: ACL; Schema: public; Owner: -
7962
--
7963

  
7964
REVOKE ALL ON TABLE project FROM PUBLIC;
7965
REVOKE ALL ON TABLE project FROM bien;
7966
GRANT ALL ON TABLE project TO bien;
7967
GRANT SELECT ON TABLE project TO bien_read;
7968

  
7969

  
7970
--
7971
-- Name: sourcename; Type: ACL; Schema: public; Owner: -
7972
--
7973

  
7974
REVOKE ALL ON TABLE sourcename FROM PUBLIC;
7975
REVOKE ALL ON TABLE sourcename FROM bien;
7976
GRANT ALL ON TABLE sourcename TO bien;
7977
GRANT SELECT ON TABLE sourcename TO bien_read;
7978

  
7979

  
7980
--
7981
-- Name: specimenreplicate; Type: ACL; Schema: public; Owner: -
7982
--
7983

  
7984
REVOKE ALL ON TABLE specimenreplicate FROM PUBLIC;
7985
REVOKE ALL ON TABLE specimenreplicate FROM bien;
7986
GRANT ALL ON TABLE specimenreplicate TO bien;
7987
GRANT SELECT ON TABLE specimenreplicate TO bien_read;
7988

  
7989

  
7990
--
7991 8013
-- Name: definedvalue; Type: ACL; Schema: public; Owner: -
7992 8014
--
7993 8015

  

Also available in: Unified diff