Revision 5655
Added by Aaron Marcuse-Kubitza about 12 years ago
vegbien.my.sql | ||
---|---|---|
227 | 227 |
parent_id int(11), |
228 | 228 |
taxonepithet text, |
229 | 229 |
rank text, |
230 |
verbatimrank text, |
|
231 | 230 |
identifyingtaxonomicname text, |
232 |
binomial text, |
|
233 |
author text, |
|
234 |
taxonomicname text, |
|
235 |
morphospecies text, |
|
236 |
family text, |
|
237 |
genus text, |
|
238 |
species text, |
|
239 |
description text, |
|
240 | 231 |
accessioncode text |
241 | 232 |
); |
242 | 233 |
|
... | ... | |
312 | 303 |
|
313 | 304 |
|
314 | 305 |
-- |
315 |
-- Name: COLUMN taxonlabel.verbatimrank; Type: COMMENT; Schema: public; Owner: - |
|
316 |
-- |
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
|
321 |
-- |
|
322 | 306 |
-- Name: COLUMN taxonlabel.identifyingtaxonomicname; Type: COMMENT; Schema: public; Owner: - |
323 | 307 |
-- |
324 | 308 |
|
... | ... | |
326 | 310 |
|
327 | 311 |
|
328 | 312 |
-- |
329 |
-- Name: COLUMN taxonlabel.binomial; Type: COMMENT; Schema: public; Owner: - |
|
330 |
-- |
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
-- |
|
336 |
-- Name: COLUMN taxonlabel.author; Type: COMMENT; Schema: public; Owner: - |
|
337 |
-- |
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
-- |
|
343 |
-- Name: COLUMN taxonlabel.taxonomicname; Type: COMMENT; Schema: public; Owner: - |
|
344 |
-- |
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
-- |
|
350 |
-- Name: COLUMN taxonlabel.family; Type: COMMENT; Schema: public; Owner: - |
|
351 |
-- |
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
-- |
|
357 |
-- Name: COLUMN taxonlabel.genus; Type: COMMENT; Schema: public; Owner: - |
|
358 |
-- |
|
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
363 |
-- |
|
364 |
-- Name: COLUMN taxonlabel.species; Type: COMMENT; Schema: public; Owner: - |
|
365 |
-- |
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
-- |
|
371 | 313 |
-- Name: taxonlabel_update_ancestors(taxonlabel, int(11)); Type: FUNCTION; Schema: public; Owner: - |
372 | 314 |
-- |
373 | 315 |
|
... | ... | |
1082 | 1024 |
|
1083 | 1025 |
|
1084 | 1026 |
-- |
1027 |
-- Name: taxonverbatim; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
1028 |
-- |
|
1029 |
|
|
1030 |
CREATE TABLE taxonverbatim ( |
|
1031 |
taxonlabel_id int(11) NOT NULL, |
|
1032 |
verbatimrank text, |
|
1033 |
taxonomicname text, |
|
1034 |
binomial text, |
|
1035 |
author text, |
|
1036 |
family text, |
|
1037 |
genus text, |
|
1038 |
species text, |
|
1039 |
morphospecies text, |
|
1040 |
description text |
|
1041 |
); |
|
1042 |
|
|
1043 |
|
|
1044 |
-- |
|
1045 |
-- Name: TABLE taxonverbatim; Type: COMMENT; Schema: public; Owner: - |
|
1046 |
-- |
|
1047 |
|
|
1048 |
|
|
1049 |
|
|
1050 |
|
|
1051 |
-- |
|
1052 |
-- Name: COLUMN taxonverbatim.verbatimrank; Type: COMMENT; Schema: public; Owner: - |
|
1053 |
-- |
|
1054 |
|
|
1055 |
|
|
1056 |
|
|
1057 |
|
|
1058 |
-- |
|
1059 |
-- Name: COLUMN taxonverbatim.taxonomicname; Type: COMMENT; Schema: public; Owner: - |
|
1060 |
-- |
|
1061 |
|
|
1062 |
|
|
1063 |
|
|
1064 |
|
|
1065 |
-- |
|
1066 |
-- Name: COLUMN taxonverbatim.binomial; Type: COMMENT; Schema: public; Owner: - |
|
1067 |
-- |
|
1068 |
|
|
1069 |
|
|
1070 |
|
|
1071 |
|
|
1072 |
-- |
|
1073 |
-- Name: COLUMN taxonverbatim.author; Type: COMMENT; Schema: public; Owner: - |
|
1074 |
-- |
|
1075 |
|
|
1076 |
|
|
1077 |
|
|
1078 |
|
|
1079 |
-- |
|
1080 |
-- Name: COLUMN taxonverbatim.family; Type: COMMENT; Schema: public; Owner: - |
|
1081 |
-- |
|
1082 |
|
|
1083 |
|
|
1084 |
|
|
1085 |
|
|
1086 |
-- |
|
1087 |
-- Name: COLUMN taxonverbatim.genus; Type: COMMENT; Schema: public; Owner: - |
|
1088 |
-- |
|
1089 |
|
|
1090 |
|
|
1091 |
|
|
1092 |
|
|
1093 |
-- |
|
1094 |
-- Name: COLUMN taxonverbatim.species; Type: COMMENT; Schema: public; Owner: - |
|
1095 |
-- |
|
1096 |
|
|
1097 |
|
|
1098 |
|
|
1099 |
|
|
1100 |
-- |
|
1085 | 1101 |
-- Name: analytical_db_view; Type: VIEW; Schema: public; Owner: - |
1086 | 1102 |
-- |
1087 | 1103 |
|
1088 | 1104 |
CREATE VIEW analytical_db_view AS |
1089 |
SELECT datasource.organizationname AS `dataSourceName`, accepted_taxonlabel.family, accepted_taxonlabel.genus, accepted_taxonlabel.species, COALESCE(accepted_taxonlabel.taxonomicname, accepted_taxonlabel.binomial) AS taxon, accepted_taxonlabel.author AS `taxonAuthor`, accepted_taxonlabel.taxonepithet AS `taxonMorphospecies`, placepath.country, placepath.stateprovince AS `stateProvince`, placepath.county 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`, functions._m2_to_ha(location.area_m2) AS `plotAreaHa`, method.name AS `plotMethod`, locationcoords.latitude_deg AS latitude, locationcoords.longitude_deg AS longitude, location.elevation_m, taxonoccurrence.iscultivated AS `isCultivated`, taxonoccurrence.cultivatedbasis AS `isCultivatedReason`, _fraction_to_percent(aggregateoccurrence.cover_fraction) AS `pctCover` FROM ((((((((((((((location JOIN party datasource ON (((datasource.party_id = location.creator_id) AND (datasource.organizationname IS NOT NULL)))) LEFT JOIN locationcoords USING (location_id)) LEFT JOIN locationplace USING (location_id)) LEFT JOIN placepath USING (placepath_id)) JOIN locationevent USING (location_id)) LEFT JOIN method USING (method_id)) JOIN taxonoccurrence USING (locationevent_id)) JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN specimenreplicate USING (plantobservation_id));
|
|
1105 |
SELECT datasource.organizationname AS `dataSourceName`, taxonverbatim.family, taxonverbatim.genus, taxonverbatim.species, COALESCE(taxonverbatim.taxonomicname, taxonverbatim.binomial) AS taxon, taxonverbatim.author AS `taxonAuthor`, taxonverbatim.morphospecies AS `taxonMorphospecies`, placepath.country, placepath.stateprovince AS `stateProvince`, placepath.county 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`, functions._m2_to_ha(location.area_m2) AS `plotAreaHa`, method.name AS `plotMethod`, locationcoords.latitude_deg AS latitude, locationcoords.longitude_deg AS longitude, location.elevation_m, taxonoccurrence.iscultivated AS `isCultivated`, taxonoccurrence.cultivatedbasis AS `isCultivatedReason`, _fraction_to_percent(aggregateoccurrence.cover_fraction) AS `pctCover` FROM (((((((((((((((location JOIN party datasource ON (((datasource.party_id = location.creator_id) AND (datasource.organizationname IS NOT NULL)))) LEFT JOIN locationcoords USING (location_id)) LEFT JOIN locationplace USING (location_id)) LEFT JOIN placepath USING (placepath_id)) JOIN locationevent USING (location_id)) LEFT JOIN method USING (method_id)) JOIN taxonoccurrence USING (locationevent_id)) JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) JOIN taxonverbatim ON ((taxonverbatim.taxonlabel_id = accepted_taxonlabel.taxonlabel_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN specimenreplicate USING (plantobservation_id));
|
|
1090 | 1106 |
|
1091 | 1107 |
|
1092 | 1108 |
-- |
... | ... | |
3625 | 3641 |
|
3626 | 3642 |
|
3627 | 3643 |
-- |
3644 |
-- Name: taxonverbatim_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3645 |
-- |
|
3646 |
|
|
3647 |
ALTER TABLE taxonverbatim |
|
3648 |
ADD CONSTRAINT taxonverbatim_pkey PRIMARY KEY (taxonlabel_id); |
|
3649 |
|
|
3650 |
|
|
3651 |
-- |
|
3628 | 3652 |
-- Name: telephone_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
3629 | 3653 |
-- |
3630 | 3654 |
|
... | ... | |
4992 | 5016 |
-- Name: taxonlabel_canon_label_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
4993 | 5017 |
-- |
4994 | 5018 |
|
4995 |
ALTER TABLE taxonlabel |
|
4996 |
ADD CONSTRAINT taxonlabel_canon_label_id_fkey FOREIGN KEY (canon_label_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4997 | 5019 |
|
4998 | 5020 |
|
5021 |
|
|
4999 | 5022 |
-- |
5000 | 5023 |
-- Name: taxonlabel_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
5001 | 5024 |
-- |
... | ... | |
5089 | 5112 |
|
5090 | 5113 |
|
5091 | 5114 |
-- |
5115 |
-- Name: taxonverbatim_taxonlabel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5116 |
-- |
|
5117 |
|
|
5118 |
ALTER TABLE taxonverbatim |
|
5119 |
ADD CONSTRAINT taxonverbatim_taxonlabel_id_fkey FOREIGN KEY (taxonlabel_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5120 |
|
|
5121 |
|
|
5122 |
-- |
|
5092 | 5123 |
-- Name: telephone_party_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
5093 | 5124 |
-- |
5094 | 5125 |
|
Also available in: Unified diff
schemas/vegbien.sql: taxonlabel: Moved non-scoping fields to new taxonverbatim subclass table, which contains the component parts of the taxonlabel