Revision 4709
Added by Aaron Marcuse-Kubitza over 12 years ago
schemas/vegbien.my.sql | ||
---|---|---|
691 | 691 |
|
692 | 692 |
|
693 | 693 |
-- |
694 |
-- Name: plantname; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
695 |
-- |
|
696 |
|
|
697 |
CREATE TABLE plantname ( |
|
698 |
plantname_id int(11) NOT NULL, |
|
699 |
parent_id int(11), |
|
700 |
scope_id int(11), |
|
701 |
rank text NOT NULL, |
|
702 |
verbatimrank text, |
|
703 |
plantname text NOT NULL, |
|
704 |
description text, |
|
705 |
accessioncode text |
|
706 |
); |
|
707 |
|
|
708 |
|
|
709 |
-- |
|
710 |
-- Name: TABLE plantname; Type: COMMENT; Schema: public; Owner: - |
|
711 |
-- |
|
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
|
716 |
-- |
|
717 |
-- Name: COLUMN plantname.rank; Type: COMMENT; Schema: public; Owner: - |
|
718 |
-- |
|
719 |
|
|
720 |
|
|
721 |
|
|
722 |
|
|
723 |
-- |
|
724 |
-- Name: plantname_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
725 |
-- |
|
726 |
|
|
727 |
CREATE TABLE plantname_ancestor ( |
|
728 |
plantname_id int(11) NOT NULL, |
|
729 |
ancestor_id int(11) NOT NULL |
|
730 |
); |
|
731 |
|
|
732 |
|
|
733 |
-- |
|
734 | 694 |
-- Name: plantobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: |
735 | 695 |
-- |
736 | 696 |
|
... | ... | |
886 | 846 |
-- |
887 | 847 |
|
888 | 848 |
CREATE VIEW analytical_db_view AS |
889 |
SELECT datasource.organizationname AS `dataSourceName`, family.plantname AS family, genus.plantname AS genus, species.plantname AS species, binomial.plantname AS taxon, authority.plantname AS `taxonAuthor`, variety.plantname AS `taxonMorphospecies`, country.placename AS country, stateprovince.placename AS `stateProvince`, county.placename AS `countyParish`, taxonoccurrence.verbatimcollectorname AS collector, plantobservation.collectionnumber AS `collectionNumber`, array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], CAST(' ' AS text)) AS `identifiedBy`, aggregateoccurrence.collectiondate AS `observationDate`, location.authorlocationcode AS `plotCode`, location.area AS `plotAreaHa`, method.name AS `plotMethod`, locationdetermination.latitude, locationdetermination.longitude, location.elevation AS elevation_m, taxonoccurrence.iscultivated AS `isCultivated`, taxonoccurrence.cultivatedbasis AS `isCultivatedReason`, aggregateoccurrence.cover AS `pctCover` FROM (((((((((((((((((((((((((((((((((((((((((location JOIN party datasource ON (((datasource.party_id = location.datasource_id) AND (datasource.organizationname IS NOT NULL)))) JOIN locationdetermination USING (location_id)) LEFT JOIN namedplace_ancestor continent_ancestor ON ((continent_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace continent ON (((continent.namedplace_id = continent_ancestor.ancestor_id) AND (continent.rank = CAST('continent' AS placerank))))) LEFT JOIN namedplace_ancestor country_ancestor ON ((country_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace country ON (((country.namedplace_id = country_ancestor.ancestor_id) AND (country.rank = CAST('country' AS placerank))))) LEFT JOIN namedplace_ancestor stateprovince_ancestor ON ((stateprovince_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace stateprovince ON (((stateprovince.namedplace_id = stateprovince_ancestor.ancestor_id) AND (stateprovince.rank = CAST('stateProvince' AS placerank))))) LEFT JOIN namedplace_ancestor county_ancestor ON ((county_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace county ON (((county.namedplace_id = county_ancestor.ancestor_id) AND (county.rank = CAST('county' AS placerank))))) JOIN locationevent USING (location_id)) 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 plantconcept USING (plantconcept_id)) LEFT JOIN plantname_ancestor binomial_ancestor ON ((binomial_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname binomial ON (((binomial.plantname_id = binomial_ancestor.ancestor_id) AND (binomial.rank = CAST('binomial' AS taxonrank))))) LEFT JOIN plantname_ancestor kingdom_ancestor ON ((kingdom_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname kingdom ON (((kingdom.plantname_id = kingdom_ancestor.ancestor_id) AND (kingdom.rank = CAST('kingdom' AS taxonrank))))) LEFT JOIN plantname_ancestor division_ancestor ON ((division_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname division ON (((division.plantname_id = division_ancestor.ancestor_id) AND (division.rank = CAST('division' AS taxonrank))))) LEFT JOIN plantname_ancestor class_ancestor ON ((class_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname class ON (((class.plantname_id = class_ancestor.ancestor_id) AND (class.rank = CAST('class' AS taxonrank))))) LEFT JOIN plantname_ancestor order_ancestor ON ((order_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname `order` ON (((`order`.plantname_id = order_ancestor.ancestor_id) AND (`order`.rank = CAST('order' AS taxonrank))))) LEFT JOIN plantname_ancestor family_ancestor ON ((family_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname family ON (((family.plantname_id = family_ancestor.ancestor_id) AND (family.rank = CAST('family' AS taxonrank))))) LEFT JOIN plantname_ancestor genus_ancestor ON ((genus_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname genus ON (((genus.plantname_id = genus_ancestor.ancestor_id) AND (genus.rank = CAST('genus' AS taxonrank))))) LEFT JOIN plantname_ancestor species_ancestor ON ((species_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname species ON (((species.plantname_id = species_ancestor.ancestor_id) AND (species.rank = CAST('species' AS taxonrank))))) LEFT JOIN plantname_ancestor subspecies_ancestor ON ((subspecies_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname subspecies ON (((subspecies.plantname_id = subspecies_ancestor.ancestor_id) AND (subspecies.rank = CAST('subspecies' AS taxonrank))))) LEFT JOIN plantname_ancestor authority_ancestor ON ((authority_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname authority ON (((authority.plantname_id = authority_ancestor.ancestor_id) AND (authority.rank = CAST('authority' AS taxonrank))))) LEFT JOIN plantname_ancestor variety_ancestor ON ((variety_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname variety ON (((variety.plantname_id = variety_ancestor.ancestor_id) AND (variety.rank = CAST('variety' AS taxonrank))))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN specimenreplicate USING (plantobservation_id));
|
|
849 |
SELECT datasource.organizationname AS `dataSourceName`, plantconcept.family, plantconcept.genus, plantconcept.species, COALESCE(plantconcept.scientificnamewithauthor, plantconcept.scientificname) AS taxon, plantconcept.scientificnameauthor AS `taxonAuthor`, plantconcept.variety AS `taxonMorphospecies`, country.placename AS country, stateprovince.placename AS `stateProvince`, county.placename AS `countyParish`, taxonoccurrence.verbatimcollectorname AS collector, plantobservation.collectionnumber AS `collectionNumber`, array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], CAST(' ' AS text)) AS `identifiedBy`, aggregateoccurrence.collectiondate AS `observationDate`, location.authorlocationcode AS `plotCode`, location.area AS `plotAreaHa`, method.name AS `plotMethod`, locationdetermination.latitude, locationdetermination.longitude, location.elevation AS elevation_m, taxonoccurrence.iscultivated AS `isCultivated`, taxonoccurrence.cultivatedbasis AS `isCultivatedReason`, aggregateoccurrence.cover AS `pctCover` FROM (((((((((((((((((((location JOIN party datasource ON (((datasource.party_id = location.datasource_id) AND (datasource.organizationname IS NOT NULL)))) JOIN locationdetermination USING (location_id)) LEFT JOIN namedplace_ancestor continent_ancestor ON ((continent_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace continent ON (((continent.namedplace_id = continent_ancestor.ancestor_id) AND (continent.rank = CAST('continent' AS placerank))))) LEFT JOIN namedplace_ancestor country_ancestor ON ((country_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace country ON (((country.namedplace_id = country_ancestor.ancestor_id) AND (country.rank = CAST('country' AS placerank))))) LEFT JOIN namedplace_ancestor stateprovince_ancestor ON ((stateprovince_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace stateprovince ON (((stateprovince.namedplace_id = stateprovince_ancestor.ancestor_id) AND (stateprovince.rank = CAST('stateProvince' AS placerank))))) LEFT JOIN namedplace_ancestor county_ancestor ON ((county_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace county ON (((county.namedplace_id = county_ancestor.ancestor_id) AND (county.rank = CAST('county' AS placerank))))) JOIN locationevent USING (location_id)) 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 plantconcept USING (plantconcept_id)) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN specimenreplicate USING (plantobservation_id));
|
|
890 | 850 |
|
891 | 851 |
|
892 | 852 |
-- |
... | ... | |
1707 | 1667 |
|
1708 | 1668 |
|
1709 | 1669 |
-- |
1670 |
-- Name: plantname; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
1671 |
-- |
|
1672 |
|
|
1673 |
CREATE TABLE plantname ( |
|
1674 |
plantname_id int(11) NOT NULL, |
|
1675 |
parent_id int(11), |
|
1676 |
scope_id int(11), |
|
1677 |
rank text NOT NULL, |
|
1678 |
verbatimrank text, |
|
1679 |
plantname text NOT NULL, |
|
1680 |
description text, |
|
1681 |
accessioncode text |
|
1682 |
); |
|
1683 |
|
|
1684 |
|
|
1685 |
-- |
|
1686 |
-- Name: TABLE plantname; Type: COMMENT; Schema: public; Owner: - |
|
1687 |
-- |
|
1688 |
|
|
1689 |
|
|
1690 |
|
|
1691 |
|
|
1692 |
-- |
|
1693 |
-- Name: COLUMN plantname.rank; Type: COMMENT; Schema: public; Owner: - |
|
1694 |
-- |
|
1695 |
|
|
1696 |
|
|
1697 |
|
|
1698 |
|
|
1699 |
-- |
|
1700 |
-- Name: plantname_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
1701 |
-- |
|
1702 |
|
|
1703 |
CREATE TABLE plantname_ancestor ( |
|
1704 |
plantname_id int(11) NOT NULL, |
|
1705 |
ancestor_id int(11) NOT NULL |
|
1706 |
); |
|
1707 |
|
|
1708 |
|
|
1709 |
-- |
|
1710 | 1710 |
-- Name: plantname_plantname_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
1711 | 1711 |
-- |
1712 | 1712 |
|
schemas/vegbien.sql | ||
---|---|---|
929 | 929 |
|
930 | 930 |
|
931 | 931 |
-- |
932 |
-- Name: plantname; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
933 |
-- |
|
934 |
|
|
935 |
CREATE TABLE plantname ( |
|
936 |
plantname_id integer NOT NULL, |
|
937 |
parent_id integer, |
|
938 |
scope_id integer, |
|
939 |
rank taxonrank NOT NULL, |
|
940 |
verbatimrank text, |
|
941 |
plantname text NOT NULL, |
|
942 |
description text, |
|
943 |
accessioncode text |
|
944 |
); |
|
945 |
|
|
946 |
|
|
947 |
-- |
|
948 |
-- Name: TABLE plantname; Type: COMMENT; Schema: public; Owner: - |
|
949 |
-- |
|
950 |
|
|
951 |
COMMENT ON TABLE plantname IS 'To include a taxon name at a rank with no explicit column, create a plantname for it and point to it using plantname_id. To include multiple such names, chain the plantnames together using parent_id, as a form of ordered linked list. Note that lower-level taxa should point to higher-level taxa.'; |
|
952 |
|
|
953 |
|
|
954 |
-- |
|
955 |
-- Name: COLUMN plantname.rank; Type: COMMENT; Schema: public; Owner: - |
|
956 |
-- |
|
957 |
|
|
958 |
COMMENT ON COLUMN plantname.rank IS 'Even if you specify a custom verbatimrank, you must also specify a closest-match rank from the taxonrank closed list.'; |
|
959 |
|
|
960 |
|
|
961 |
-- |
|
962 |
-- Name: plantname_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
963 |
-- |
|
964 |
|
|
965 |
CREATE TABLE plantname_ancestor ( |
|
966 |
plantname_id integer NOT NULL, |
|
967 |
ancestor_id integer NOT NULL |
|
968 |
); |
|
969 |
|
|
970 |
|
|
971 |
-- |
|
972 | 932 |
-- Name: plantobservation; Type: TABLE; Schema: public; Owner: -; Tablespace: |
973 | 933 |
-- |
974 | 934 |
|
... | ... | |
1125 | 1085 |
-- |
1126 | 1086 |
|
1127 | 1087 |
CREATE VIEW analytical_db_view AS |
1128 |
SELECT datasource.organizationname AS "dataSourceName", family.plantname AS family, genus.plantname AS genus, species.plantname AS species, binomial.plantname AS taxon, authority.plantname AS "taxonAuthor", variety.plantname AS "taxonMorphospecies", country.placename AS country, stateprovince.placename AS "stateProvince", county.placename AS "countyParish", taxonoccurrence.verbatimcollectorname AS collector, plantobservation.collectionnumber AS "collectionNumber", array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], ' '::text) AS "identifiedBy", aggregateoccurrence.collectiondate AS "observationDate", location.authorlocationcode AS "plotCode", location.area AS "plotAreaHa", method.name AS "plotMethod", locationdetermination.latitude, locationdetermination.longitude, location.elevation AS elevation_m, taxonoccurrence.iscultivated AS "isCultivated", taxonoccurrence.cultivatedbasis AS "isCultivatedReason", aggregateoccurrence.cover AS "pctCover" FROM (((((((((((((((((((((((((((((((((((((((((location JOIN party datasource ON (((datasource.party_id = location.datasource_id) AND (datasource.organizationname IS NOT NULL)))) JOIN locationdetermination USING (location_id)) LEFT JOIN namedplace_ancestor continent_ancestor ON ((continent_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace continent ON (((continent.namedplace_id = continent_ancestor.ancestor_id) AND (continent.rank = 'continent'::placerank)))) LEFT JOIN namedplace_ancestor country_ancestor ON ((country_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace country ON (((country.namedplace_id = country_ancestor.ancestor_id) AND (country.rank = 'country'::placerank)))) LEFT JOIN namedplace_ancestor stateprovince_ancestor ON ((stateprovince_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace stateprovince ON (((stateprovince.namedplace_id = stateprovince_ancestor.ancestor_id) AND (stateprovince.rank = 'stateProvince'::placerank)))) LEFT JOIN namedplace_ancestor county_ancestor ON ((county_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace county ON (((county.namedplace_id = county_ancestor.ancestor_id) AND (county.rank = 'county'::placerank)))) JOIN locationevent USING (location_id)) 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 plantconcept USING (plantconcept_id)) LEFT JOIN plantname_ancestor binomial_ancestor ON ((binomial_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname binomial ON (((binomial.plantname_id = binomial_ancestor.ancestor_id) AND (binomial.rank = 'binomial'::taxonrank)))) LEFT JOIN plantname_ancestor kingdom_ancestor ON ((kingdom_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname kingdom ON (((kingdom.plantname_id = kingdom_ancestor.ancestor_id) AND (kingdom.rank = 'kingdom'::taxonrank)))) LEFT JOIN plantname_ancestor division_ancestor ON ((division_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname division ON (((division.plantname_id = division_ancestor.ancestor_id) AND (division.rank = 'division'::taxonrank)))) LEFT JOIN plantname_ancestor class_ancestor ON ((class_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname class ON (((class.plantname_id = class_ancestor.ancestor_id) AND (class.rank = 'class'::taxonrank)))) LEFT JOIN plantname_ancestor order_ancestor ON ((order_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname "order" ON ((("order".plantname_id = order_ancestor.ancestor_id) AND ("order".rank = 'order'::taxonrank)))) LEFT JOIN plantname_ancestor family_ancestor ON ((family_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname family ON (((family.plantname_id = family_ancestor.ancestor_id) AND (family.rank = 'family'::taxonrank)))) LEFT JOIN plantname_ancestor genus_ancestor ON ((genus_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname genus ON (((genus.plantname_id = genus_ancestor.ancestor_id) AND (genus.rank = 'genus'::taxonrank)))) LEFT JOIN plantname_ancestor species_ancestor ON ((species_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname species ON (((species.plantname_id = species_ancestor.ancestor_id) AND (species.rank = 'species'::taxonrank)))) LEFT JOIN plantname_ancestor subspecies_ancestor ON ((subspecies_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname subspecies ON (((subspecies.plantname_id = subspecies_ancestor.ancestor_id) AND (subspecies.rank = 'subspecies'::taxonrank)))) LEFT JOIN plantname_ancestor authority_ancestor ON ((authority_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname authority ON (((authority.plantname_id = authority_ancestor.ancestor_id) AND (authority.rank = 'authority'::taxonrank)))) LEFT JOIN plantname_ancestor variety_ancestor ON ((variety_ancestor.plantname_id = plantconcept.plantname_id))) LEFT JOIN plantname variety ON (((variety.plantname_id = variety_ancestor.ancestor_id) AND (variety.rank = 'variety'::taxonrank)))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN specimenreplicate USING (plantobservation_id));
|
|
1088 |
SELECT datasource.organizationname AS "dataSourceName", plantconcept.family, plantconcept.genus, plantconcept.species, COALESCE(plantconcept.scientificnamewithauthor, plantconcept.scientificname) AS taxon, plantconcept.scientificnameauthor AS "taxonAuthor", plantconcept.variety AS "taxonMorphospecies", country.placename AS country, stateprovince.placename AS "stateProvince", county.placename AS "countyParish", taxonoccurrence.verbatimcollectorname AS collector, plantobservation.collectionnumber AS "collectionNumber", array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], ' '::text) AS "identifiedBy", aggregateoccurrence.collectiondate AS "observationDate", location.authorlocationcode AS "plotCode", location.area AS "plotAreaHa", method.name AS "plotMethod", locationdetermination.latitude, locationdetermination.longitude, location.elevation AS elevation_m, taxonoccurrence.iscultivated AS "isCultivated", taxonoccurrence.cultivatedbasis AS "isCultivatedReason", aggregateoccurrence.cover AS "pctCover" FROM (((((((((((((((((((location JOIN party datasource ON (((datasource.party_id = location.datasource_id) AND (datasource.organizationname IS NOT NULL)))) JOIN locationdetermination USING (location_id)) LEFT JOIN namedplace_ancestor continent_ancestor ON ((continent_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace continent ON (((continent.namedplace_id = continent_ancestor.ancestor_id) AND (continent.rank = 'continent'::placerank)))) LEFT JOIN namedplace_ancestor country_ancestor ON ((country_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace country ON (((country.namedplace_id = country_ancestor.ancestor_id) AND (country.rank = 'country'::placerank)))) LEFT JOIN namedplace_ancestor stateprovince_ancestor ON ((stateprovince_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace stateprovince ON (((stateprovince.namedplace_id = stateprovince_ancestor.ancestor_id) AND (stateprovince.rank = 'stateProvince'::placerank)))) LEFT JOIN namedplace_ancestor county_ancestor ON ((county_ancestor.namedplace_id = locationdetermination.namedplace_id))) LEFT JOIN namedplace county ON (((county.namedplace_id = county_ancestor.ancestor_id) AND (county.rank = 'county'::placerank)))) JOIN locationevent USING (location_id)) 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 plantconcept USING (plantconcept_id)) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN specimenreplicate USING (plantobservation_id));
|
|
1129 | 1089 |
|
1130 | 1090 |
|
1131 | 1091 |
-- |
... | ... | |
1143 | 1103 |
ON $0.namedplace_id = $0_ancestor.ancestor_id |
1144 | 1104 |
AND $0.rank = ''$0'' |
1145 | 1105 |
----- |
1146 |
|
|
1147 |
plantname: |
|
1148 |
For each taxonrank value, sanitize and replace regexp ".*" with: |
|
1149 |
----- |
|
1150 |
LEFT JOIN plantname_ancestor AS $0_ancestor |
|
1151 |
ON $0_ancestor.plantname_id = plantconcept.plantname_id |
|
1152 |
LEFT JOIN plantname AS $0 |
|
1153 |
ON $0.plantname_id = $0_ancestor.ancestor_id |
|
1154 |
AND $0.rank = ''$0'' |
|
1155 |
----- |
|
1156 |
If sanitized, replace ''$0'' with original string. |
|
1157 |
If get syntax errors, double-quote applicable names. |
|
1158 | 1106 |
'; |
1159 | 1107 |
|
1160 | 1108 |
|
... | ... | |
2130 | 2078 |
|
2131 | 2079 |
|
2132 | 2080 |
-- |
2081 |
-- Name: plantname; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2082 |
-- |
|
2083 |
|
|
2084 |
CREATE TABLE plantname ( |
|
2085 |
plantname_id integer NOT NULL, |
|
2086 |
parent_id integer, |
|
2087 |
scope_id integer, |
|
2088 |
rank taxonrank NOT NULL, |
|
2089 |
verbatimrank text, |
|
2090 |
plantname text NOT NULL, |
|
2091 |
description text, |
|
2092 |
accessioncode text |
|
2093 |
); |
|
2094 |
|
|
2095 |
|
|
2096 |
-- |
|
2097 |
-- Name: TABLE plantname; Type: COMMENT; Schema: public; Owner: - |
|
2098 |
-- |
|
2099 |
|
|
2100 |
COMMENT ON TABLE plantname IS 'To include a taxon name at a rank with no explicit column, create a plantname for it and point to it using plantname_id. To include multiple such names, chain the plantnames together using parent_id, as a form of ordered linked list. Note that lower-level taxa should point to higher-level taxa.'; |
|
2101 |
|
|
2102 |
|
|
2103 |
-- |
|
2104 |
-- Name: COLUMN plantname.rank; Type: COMMENT; Schema: public; Owner: - |
|
2105 |
-- |
|
2106 |
|
|
2107 |
COMMENT ON COLUMN plantname.rank IS 'Even if you specify a custom verbatimrank, you must also specify a closest-match rank from the taxonrank closed list.'; |
|
2108 |
|
|
2109 |
|
|
2110 |
-- |
|
2111 |
-- Name: plantname_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2112 |
-- |
|
2113 |
|
|
2114 |
CREATE TABLE plantname_ancestor ( |
|
2115 |
plantname_id integer NOT NULL, |
|
2116 |
ancestor_id integer NOT NULL |
|
2117 |
); |
|
2118 |
|
|
2119 |
|
|
2120 |
-- |
|
2133 | 2121 |
-- Name: plantname_plantname_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
2134 | 2122 |
-- |
2135 | 2123 |
|
Also available in: Unified diff
schemas/vegbien.sql: Changed analytical_db_view to use new denormalized taxonomic names in plantconcept, which significantly reduces the number of joins. Note that changing the tables used by a view which depends on other tables will cause those tables to be reordered in dependency order to appear before the view, causing things to be moved around in the svn diff.