485 |
485 |
$$;
|
486 |
486 |
|
487 |
487 |
|
|
488 |
SET default_tablespace = '';
|
|
489 |
|
|
490 |
SET default_with_oids = false;
|
|
491 |
|
488 |
492 |
--
|
489 |
|
-- Name: taxonconcept_update_ancestors(); Type: FUNCTION; Schema: public; Owner: -
|
|
493 |
-- Name: taxonconcept; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
490 |
494 |
--
|
491 |
495 |
|
492 |
|
CREATE FUNCTION taxonconcept_update_ancestors() RETURNS trigger
|
|
496 |
CREATE TABLE taxonconcept (
|
|
497 |
taxonconcept_id integer NOT NULL,
|
|
498 |
creator_id integer NOT NULL,
|
|
499 |
sourceaccessioncode text,
|
|
500 |
creationdate date,
|
|
501 |
accepted_concept_id integer,
|
|
502 |
matched_concept_id integer,
|
|
503 |
matched_concept_fit_fraction double precision,
|
|
504 |
parent_id integer,
|
|
505 |
taxonname text,
|
|
506 |
rank taxonrank,
|
|
507 |
verbatimrank text,
|
|
508 |
identifyingtaxonomicname text,
|
|
509 |
taxonomicname text,
|
|
510 |
author text,
|
|
511 |
taxonomicnamewithauthor text,
|
|
512 |
family text,
|
|
513 |
genus text,
|
|
514 |
species text,
|
|
515 |
description text,
|
|
516 |
accessioncode text,
|
|
517 |
CONSTRAINT taxonconcept_matched_concept_fit_fraction_range CHECK (((matched_concept_fit_fraction >= (0)::double precision) AND (matched_concept_fit_fraction <= (1)::double precision))),
|
|
518 |
CONSTRAINT taxonconcept_required_key CHECK (((((((sourceaccessioncode IS NOT NULL) OR (taxonname IS NOT NULL)) OR (identifyingtaxonomicname IS NOT NULL)) OR (taxonomicname IS NOT NULL)) OR (taxonomicnamewithauthor IS NOT NULL)) OR ((parent_id IS NOT NULL) AND ((creationdate IS NOT NULL) OR (author IS NOT NULL)))))
|
|
519 |
);
|
|
520 |
|
|
521 |
|
|
522 |
--
|
|
523 |
-- Name: TABLE taxonconcept; Type: COMMENT; Schema: public; Owner: -
|
|
524 |
--
|
|
525 |
|
|
526 |
COMMENT ON TABLE taxonconcept IS 'A taxon concept defined by an entity. Can be at any level in the taxonomic hierarchy. Can be either verbatim or accepted.
|
|
527 |
|
|
528 |
"A taxon (plural: taxa) is a group of one (or more) populations of organism(s), which a taxonomist adjudges to be a unit" (http://en.wikipedia.org/wiki/Taxon)
|
|
529 |
|
|
530 |
Note that taxonname stores only one rank (e.g. family) of the full taxonomic name. The higher-level ranks are stored in the taxon concept''s chain of parent_id ancestors.
|
|
531 |
|
|
532 |
To include a taxon name at a rank with no explicit column, create a parent taxonconcept for it and point to it using parent_id. To include multiple such names, chain the taxonconcepts together using parent_id. Note that lower-level taxa should point to higher-level taxa.
|
|
533 |
|
|
534 |
Equivalent to VegBank''s plantConcept and plantName tables, plus plantParent_ID and plantLevel from plantStatus.';
|
|
535 |
|
|
536 |
|
|
537 |
--
|
|
538 |
-- Name: COLUMN taxonconcept.creator_id; Type: COMMENT; Schema: public; Owner: -
|
|
539 |
--
|
|
540 |
|
|
541 |
COMMENT ON COLUMN taxonconcept.creator_id IS 'The entity that created the taxon concept.';
|
|
542 |
|
|
543 |
|
|
544 |
--
|
|
545 |
-- Name: COLUMN taxonconcept.sourceaccessioncode; Type: COMMENT; Schema: public; Owner: -
|
|
546 |
--
|
|
547 |
|
|
548 |
COMMENT ON COLUMN taxonconcept.sourceaccessioncode IS 'The datasource''s identifier for the taxonconcept.';
|
|
549 |
|
|
550 |
|
|
551 |
--
|
|
552 |
-- Name: COLUMN taxonconcept.creationdate; Type: COMMENT; Schema: public; Owner: -
|
|
553 |
--
|
|
554 |
|
|
555 |
COMMENT ON COLUMN taxonconcept.creationdate IS 'The date the taxonconcept was created or defined. For a taxonconcept applied in a taxondetermination, this is the date the determination was made.';
|
|
556 |
|
|
557 |
|
|
558 |
--
|
|
559 |
-- Name: COLUMN taxonconcept.accepted_concept_id; Type: COMMENT; Schema: public; Owner: -
|
|
560 |
--
|
|
561 |
|
|
562 |
COMMENT ON COLUMN taxonconcept.accepted_concept_id IS 'The accepted synonym of the taxonconcept.';
|
|
563 |
|
|
564 |
|
|
565 |
--
|
|
566 |
-- Name: COLUMN taxonconcept.matched_concept_id; Type: COMMENT; Schema: public; Owner: -
|
|
567 |
--
|
|
568 |
|
|
569 |
COMMENT ON COLUMN taxonconcept.matched_concept_id IS 'The taxonconcept containing the closest match to this taxonconcept. taxonconcepts should be linked in a four-level hierarchy of datasource concept -> parsed concept -> matched concept -> accepted concept. A previously-accepted name''s concept should be further linked to the synonym that has replaced it.
|
|
570 |
|
|
571 |
To indicate a synonym between taxonconcepts of different sources, choose one taxonconcept to be authoritative and point the other taxonconcept to it using this field.
|
|
572 |
|
|
573 |
An accepted name should point to itself in this field. This will happen automatically by setting it to the special value 0.';
|
|
574 |
|
|
575 |
|
|
576 |
--
|
|
577 |
-- Name: COLUMN taxonconcept.matched_concept_fit_fraction; Type: COMMENT; Schema: public; Owner: -
|
|
578 |
--
|
|
579 |
|
|
580 |
COMMENT ON COLUMN taxonconcept.matched_concept_fit_fraction IS 'The closeness of fit of the matched_concept.';
|
|
581 |
|
|
582 |
|
|
583 |
--
|
|
584 |
-- Name: COLUMN taxonconcept.parent_id; Type: COMMENT; Schema: public; Owner: -
|
|
585 |
--
|
|
586 |
|
|
587 |
COMMENT ON COLUMN taxonconcept.parent_id IS 'The parent taxonconcept. Note that while a taxon *name* may have multiple parents, a taxon *concept* has only one, based on the creator''s opinion of where that taxonconcept goes in the taxonomic hierarchy.';
|
|
588 |
|
|
589 |
|
|
590 |
--
|
|
591 |
-- Name: COLUMN taxonconcept.taxonname; Type: COMMENT; Schema: public; Owner: -
|
|
592 |
--
|
|
593 |
|
|
594 |
COMMENT ON COLUMN taxonconcept.taxonname IS 'The name of the taxon within its parent taxon. This is the lowest-rank portion of this taxonconcept''s full taxonomic name, if it has one.
|
|
595 |
|
|
596 |
The morphospecies suffix goes in this field.';
|
|
597 |
|
|
598 |
|
|
599 |
--
|
|
600 |
-- Name: COLUMN taxonconcept.rank; Type: COMMENT; Schema: public; Owner: -
|
|
601 |
--
|
|
602 |
|
|
603 |
COMMENT ON COLUMN taxonconcept.rank IS 'The taxonconcept''s level in the taxonomic hierarchy, standardized to a closed list. Even if you specify a custom verbatimrank, you should also specify a closest-match rank from the taxonrank closed list.';
|
|
604 |
|
|
605 |
|
|
606 |
--
|
|
607 |
-- Name: COLUMN taxonconcept.verbatimrank; Type: COMMENT; Schema: public; Owner: -
|
|
608 |
--
|
|
609 |
|
|
610 |
COMMENT ON COLUMN taxonconcept.verbatimrank IS 'The taxonconcept''s verbatim level in the taxonomic hierarchy. Does not need to be in the taxonrank closed list.';
|
|
611 |
|
|
612 |
|
|
613 |
--
|
|
614 |
-- Name: COLUMN taxonconcept.identifyingtaxonomicname; Type: COMMENT; Schema: public; Owner: -
|
|
615 |
--
|
|
616 |
|
|
617 |
COMMENT ON COLUMN taxonconcept.identifyingtaxonomicname IS 'The taxonomic name that uniquely identifies this taxonconcept. If set, the other fields will not be used in duplicate elimination.';
|
|
618 |
|
|
619 |
|
|
620 |
--
|
|
621 |
-- Name: COLUMN taxonconcept.taxonomicname; Type: COMMENT; Schema: public; Owner: -
|
|
622 |
--
|
|
623 |
|
|
624 |
COMMENT ON COLUMN taxonconcept.taxonomicname IS 'The concatenated taxonomic name which uniquely identifies this taxon. Does not include the author of the name.
|
|
625 |
|
|
626 |
Equivalent to Darwin Core''s scientificName.';
|
|
627 |
|
|
628 |
|
|
629 |
--
|
|
630 |
-- Name: COLUMN taxonconcept.author; Type: COMMENT; Schema: public; Owner: -
|
|
631 |
--
|
|
632 |
|
|
633 |
COMMENT ON COLUMN taxonconcept.author IS 'The author of the taxonomic name.
|
|
634 |
|
|
635 |
Equivalent to Darwin Core''s scientificNameAuthorship.';
|
|
636 |
|
|
637 |
|
|
638 |
--
|
|
639 |
-- Name: COLUMN taxonconcept.taxonomicnamewithauthor; Type: COMMENT; Schema: public; Owner: -
|
|
640 |
--
|
|
641 |
|
|
642 |
COMMENT ON COLUMN taxonconcept.taxonomicnamewithauthor IS 'The concatenated taxonomic name which uniquely identifies this taxon, plus the author of that name.
|
|
643 |
|
|
644 |
Equivalent to Darwin Core''s scientificName + scientificNameAuthorship.
|
|
645 |
Equivalent to "Name sec. x".';
|
|
646 |
|
|
647 |
|
|
648 |
--
|
|
649 |
-- Name: COLUMN taxonconcept.family; Type: COMMENT; Schema: public; Owner: -
|
|
650 |
--
|
|
651 |
|
|
652 |
COMMENT ON COLUMN taxonconcept.family IS 'The family of the taxonomic name. This is a cached field for easy querying; the identifying version of this field is stored in the chain of parent_id ancestors.';
|
|
653 |
|
|
654 |
|
|
655 |
--
|
|
656 |
-- Name: COLUMN taxonconcept.genus; Type: COMMENT; Schema: public; Owner: -
|
|
657 |
--
|
|
658 |
|
|
659 |
COMMENT ON COLUMN taxonconcept.genus IS 'The genus portion of the taxonomic name. This is a cached field for easy querying; the identifying version of this field is stored in the chain of parent_id ancestors.';
|
|
660 |
|
|
661 |
|
|
662 |
--
|
|
663 |
-- Name: COLUMN taxonconcept.species; Type: COMMENT; Schema: public; Owner: -
|
|
664 |
--
|
|
665 |
|
|
666 |
COMMENT ON COLUMN taxonconcept.species IS 'The species portion of the taxonomic name. This is a cached field for easy querying; the identifying version of this field is stored in the chain of parent_id ancestors.';
|
|
667 |
|
|
668 |
|
|
669 |
--
|
|
670 |
-- Name: taxonconcept_update_ancestors(taxonconcept, integer); Type: FUNCTION; Schema: public; Owner: -
|
|
671 |
--
|
|
672 |
|
|
673 |
CREATE FUNCTION taxonconcept_update_ancestors(new taxonconcept, old_parent_id integer DEFAULT NULL::integer) RETURNS void
|
493 |
674 |
LANGUAGE plpgsql
|
494 |
675 |
AS $$
|
495 |
676 |
DECLARE
|
... | ... | |
497 |
678 |
parent_id_ taxonconcept.taxonconcept_id%TYPE :=
|
498 |
679 |
COALESCE(new.matched_concept_id, new.parent_id);
|
499 |
680 |
BEGIN
|
500 |
|
-- Delete existing ancestors
|
501 |
|
DELETE FROM taxonconcept_ancestor
|
502 |
|
WHERE taxonconcept_id = new.taxonconcept_id;
|
503 |
|
|
504 |
|
IF parent_id_ IS NOT NULL THEN
|
505 |
|
-- Copy parent's ancestors to this node's ancestors
|
506 |
|
INSERT
|
507 |
|
INTO taxonconcept_ancestor
|
508 |
|
(taxonconcept_id, ancestor_id)
|
509 |
|
SELECT
|
510 |
|
new.taxonconcept_id, ancestor_id
|
511 |
|
FROM taxonconcept_ancestor
|
512 |
|
WHERE taxonconcept_id = parent_id_
|
513 |
|
;
|
|
681 |
IF parent_id_ IS DISTINCT FROM old_parent_id THEN
|
|
682 |
DECLARE
|
|
683 |
-- These include the parent itself
|
|
684 |
old_ancestors integer[] := (
|
|
685 |
SELECT array_agg(ancestor_id) FROM taxonconcept_ancestor
|
|
686 |
WHERE taxonconcept_id = old_parent_id
|
|
687 |
);
|
|
688 |
new_ancestors integer[] := (
|
|
689 |
SELECT array_agg(ancestor_id) FROM taxonconcept_ancestor
|
|
690 |
WHERE taxonconcept_id = parent_id_
|
|
691 |
);
|
|
692 |
descendant_id integer;
|
|
693 |
BEGIN
|
|
694 |
FOR descendant_id IN -- also includes self
|
|
695 |
SELECT taxonconcept_id
|
|
696 |
FROM taxonconcept_ancestor
|
|
697 |
WHERE ancestor_id = new.taxonconcept_id
|
|
698 |
LOOP
|
|
699 |
-- Delete old parent's ancestors
|
|
700 |
DELETE FROM taxonconcept_ancestor
|
|
701 |
WHERE taxonconcept_id = descendant_id
|
|
702 |
AND ancestor_id = ANY (old_ancestors)
|
|
703 |
;
|
|
704 |
|
|
705 |
-- Add new parent's ancestors
|
|
706 |
INSERT INTO taxonconcept_ancestor
|
|
707 |
(taxonconcept_id, ancestor_id)
|
|
708 |
SELECT descendant_id, unnest(new_ancestors)
|
|
709 |
;
|
|
710 |
END LOOP;
|
|
711 |
END;
|
514 |
712 |
END IF;
|
515 |
713 |
|
516 |
|
-- Add "ancestor" for this node
|
517 |
|
/* This is useful for queries, because you don't have to separately test if
|
518 |
|
the leaf node is the one you're looking for, in addition to that leaf node's
|
519 |
|
ancestors. */
|
|
714 |
/* Note: We don't need an ON DELETE trigger to update the descendants'
|
|
715 |
ancestors when a node is deleted, because the taxonconcept.parent_id foreign
|
|
716 |
key is ON DELETE CASCADE, which just removes all the descendants anyway. */
|
|
717 |
END;
|
|
718 |
$$;
|
|
719 |
|
|
720 |
|
|
721 |
--
|
|
722 |
-- Name: taxonconcept_update_ancestors_on_insert(); Type: FUNCTION; Schema: public; Owner: -
|
|
723 |
--
|
|
724 |
|
|
725 |
CREATE FUNCTION taxonconcept_update_ancestors_on_insert() RETURNS trigger
|
|
726 |
LANGUAGE plpgsql
|
|
727 |
AS $$
|
|
728 |
BEGIN
|
|
729 |
/* Add "ancestor" for this node. This is useful for queries, because you
|
|
730 |
don't have to separately test if the leaf node is the one you're looking
|
|
731 |
for, in addition to that leaf node's ancestors. */
|
520 |
732 |
INSERT
|
521 |
733 |
INTO taxonconcept_ancestor
|
522 |
734 |
(taxonconcept_id, ancestor_id)
|
523 |
735 |
VALUES (new.taxonconcept_id, new.taxonconcept_id)
|
524 |
736 |
;
|
525 |
737 |
|
526 |
|
-- Tell immediate children to update their ancestors lists, which will
|
527 |
|
-- recursively tell all descendants
|
528 |
|
UPDATE taxonconcept
|
529 |
|
SET taxonconcept_id = taxonconcept_id -- need at least one SET statement
|
530 |
|
-- Add COALESCE() to enable using taxonconcept_unique index for lookup
|
531 |
|
WHERE COALESCE(parent_id, 2147483647) = new.taxonconcept_id
|
532 |
|
AND taxonconcept_id != new.taxonconcept_id -- avoid infinite recursion
|
533 |
|
;
|
|
738 |
PERFORM taxonconcept_update_ancestors(new);
|
534 |
739 |
|
535 |
|
/* Note: We don't need an ON DELETE trigger to update the descendants'
|
536 |
|
ancestors when a node is deleted, because the taxonconcept.parent_id foreign
|
537 |
|
key is ON DELETE CASCADE, which just removes all the descendants anyway. */
|
|
740 |
RETURN new;
|
|
741 |
END;
|
|
742 |
$$;
|
|
743 |
|
|
744 |
|
|
745 |
--
|
|
746 |
-- Name: taxonconcept_update_ancestors_on_update(); Type: FUNCTION; Schema: public; Owner: -
|
|
747 |
--
|
|
748 |
|
|
749 |
CREATE FUNCTION taxonconcept_update_ancestors_on_update() RETURNS trigger
|
|
750 |
LANGUAGE plpgsql
|
|
751 |
AS $$
|
|
752 |
BEGIN
|
|
753 |
PERFORM taxonconcept_update_ancestors(new,
|
|
754 |
COALESCE(old.matched_concept_id, old.parent_id));
|
538 |
755 |
|
539 |
756 |
RETURN new;
|
540 |
757 |
END;
|
... | ... | |
552 |
769 |
);
|
553 |
770 |
|
554 |
771 |
|
555 |
|
SET default_tablespace = '';
|
556 |
|
|
557 |
|
SET default_with_oids = false;
|
558 |
|
|
559 |
772 |
--
|
560 |
773 |
-- Name: address; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
561 |
774 |
--
|
... | ... | |
1204 |
1417 |
|
1205 |
1418 |
|
1206 |
1419 |
--
|
1207 |
|
-- Name: taxonconcept; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
1208 |
|
--
|
1209 |
|
|
1210 |
|
CREATE TABLE taxonconcept (
|
1211 |
|
taxonconcept_id integer NOT NULL,
|
1212 |
|
creator_id integer NOT NULL,
|
1213 |
|
sourceaccessioncode text,
|
1214 |
|
creationdate date,
|
1215 |
|
accepted_concept_id integer,
|
1216 |
|
matched_concept_id integer,
|
1217 |
|
matched_concept_fit_fraction double precision,
|
1218 |
|
parent_id integer,
|
1219 |
|
taxonname text,
|
1220 |
|
rank taxonrank,
|
1221 |
|
verbatimrank text,
|
1222 |
|
identifyingtaxonomicname text,
|
1223 |
|
taxonomicname text,
|
1224 |
|
author text,
|
1225 |
|
taxonomicnamewithauthor text,
|
1226 |
|
family text,
|
1227 |
|
genus text,
|
1228 |
|
species text,
|
1229 |
|
description text,
|
1230 |
|
accessioncode text,
|
1231 |
|
CONSTRAINT taxonconcept_matched_concept_fit_fraction_range CHECK (((matched_concept_fit_fraction >= (0)::double precision) AND (matched_concept_fit_fraction <= (1)::double precision))),
|
1232 |
|
CONSTRAINT taxonconcept_required_key CHECK (((((((sourceaccessioncode IS NOT NULL) OR (taxonname IS NOT NULL)) OR (identifyingtaxonomicname IS NOT NULL)) OR (taxonomicname IS NOT NULL)) OR (taxonomicnamewithauthor IS NOT NULL)) OR ((parent_id IS NOT NULL) AND ((creationdate IS NOT NULL) OR (author IS NOT NULL)))))
|
1233 |
|
);
|
1234 |
|
|
1235 |
|
|
1236 |
|
--
|
1237 |
|
-- Name: TABLE taxonconcept; Type: COMMENT; Schema: public; Owner: -
|
1238 |
|
--
|
1239 |
|
|
1240 |
|
COMMENT ON TABLE taxonconcept IS 'A taxon concept defined by an entity. Can be at any level in the taxonomic hierarchy. Can be either verbatim or accepted.
|
1241 |
|
|
1242 |
|
"A taxon (plural: taxa) is a group of one (or more) populations of organism(s), which a taxonomist adjudges to be a unit" (http://en.wikipedia.org/wiki/Taxon)
|
1243 |
|
|
1244 |
|
Note that taxonname stores only one rank (e.g. family) of the full taxonomic name. The higher-level ranks are stored in the taxon concept''s chain of parent_id ancestors.
|
1245 |
|
|
1246 |
|
To include a taxon name at a rank with no explicit column, create a parent taxonconcept for it and point to it using parent_id. To include multiple such names, chain the taxonconcepts together using parent_id. Note that lower-level taxa should point to higher-level taxa.
|
1247 |
|
|
1248 |
|
Equivalent to VegBank''s plantConcept and plantName tables, plus plantParent_ID and plantLevel from plantStatus.';
|
1249 |
|
|
1250 |
|
|
1251 |
|
--
|
1252 |
|
-- Name: COLUMN taxonconcept.creator_id; Type: COMMENT; Schema: public; Owner: -
|
1253 |
|
--
|
1254 |
|
|
1255 |
|
COMMENT ON COLUMN taxonconcept.creator_id IS 'The entity that created the taxon concept.';
|
1256 |
|
|
1257 |
|
|
1258 |
|
--
|
1259 |
|
-- Name: COLUMN taxonconcept.sourceaccessioncode; Type: COMMENT; Schema: public; Owner: -
|
1260 |
|
--
|
1261 |
|
|
1262 |
|
COMMENT ON COLUMN taxonconcept.sourceaccessioncode IS 'The datasource''s identifier for the taxonconcept.';
|
1263 |
|
|
1264 |
|
|
1265 |
|
--
|
1266 |
|
-- Name: COLUMN taxonconcept.creationdate; Type: COMMENT; Schema: public; Owner: -
|
1267 |
|
--
|
1268 |
|
|
1269 |
|
COMMENT ON COLUMN taxonconcept.creationdate IS 'The date the taxonconcept was created or defined. For a taxonconcept applied in a taxondetermination, this is the date the determination was made.';
|
1270 |
|
|
1271 |
|
|
1272 |
|
--
|
1273 |
|
-- Name: COLUMN taxonconcept.accepted_concept_id; Type: COMMENT; Schema: public; Owner: -
|
1274 |
|
--
|
1275 |
|
|
1276 |
|
COMMENT ON COLUMN taxonconcept.accepted_concept_id IS 'The accepted synonym of the taxonconcept.';
|
1277 |
|
|
1278 |
|
|
1279 |
|
--
|
1280 |
|
-- Name: COLUMN taxonconcept.matched_concept_id; Type: COMMENT; Schema: public; Owner: -
|
1281 |
|
--
|
1282 |
|
|
1283 |
|
COMMENT ON COLUMN taxonconcept.matched_concept_id IS 'The taxonconcept containing the closest match to this taxonconcept. taxonconcepts should be linked in a four-level hierarchy of datasource concept -> parsed concept -> matched concept -> accepted concept. A previously-accepted name''s concept should be further linked to the synonym that has replaced it.
|
1284 |
|
|
1285 |
|
To indicate a synonym between taxonconcepts of different sources, choose one taxonconcept to be authoritative and point the other taxonconcept to it using this field.
|
1286 |
|
|
1287 |
|
An accepted name should point to itself in this field. This will happen automatically by setting it to the special value 0.';
|
1288 |
|
|
1289 |
|
|
1290 |
|
--
|
1291 |
|
-- Name: COLUMN taxonconcept.matched_concept_fit_fraction; Type: COMMENT; Schema: public; Owner: -
|
1292 |
|
--
|
1293 |
|
|
1294 |
|
COMMENT ON COLUMN taxonconcept.matched_concept_fit_fraction IS 'The closeness of fit of the matched_concept.';
|
1295 |
|
|
1296 |
|
|
1297 |
|
--
|
1298 |
|
-- Name: COLUMN taxonconcept.parent_id; Type: COMMENT; Schema: public; Owner: -
|
1299 |
|
--
|
1300 |
|
|
1301 |
|
COMMENT ON COLUMN taxonconcept.parent_id IS 'The parent taxonconcept. Note that while a taxon *name* may have multiple parents, a taxon *concept* has only one, based on the creator''s opinion of where that taxonconcept goes in the taxonomic hierarchy.';
|
1302 |
|
|
1303 |
|
|
1304 |
|
--
|
1305 |
|
-- Name: COLUMN taxonconcept.taxonname; Type: COMMENT; Schema: public; Owner: -
|
1306 |
|
--
|
1307 |
|
|
1308 |
|
COMMENT ON COLUMN taxonconcept.taxonname IS 'The name of the taxon within its parent taxon. This is the lowest-rank portion of this taxonconcept''s full taxonomic name, if it has one.
|
1309 |
|
|
1310 |
|
The morphospecies suffix goes in this field.';
|
1311 |
|
|
1312 |
|
|
1313 |
|
--
|
1314 |
|
-- Name: COLUMN taxonconcept.rank; Type: COMMENT; Schema: public; Owner: -
|
1315 |
|
--
|
1316 |
|
|
1317 |
|
COMMENT ON COLUMN taxonconcept.rank IS 'The taxonconcept''s level in the taxonomic hierarchy, standardized to a closed list. Even if you specify a custom verbatimrank, you should also specify a closest-match rank from the taxonrank closed list.';
|
1318 |
|
|
1319 |
|
|
1320 |
|
--
|
1321 |
|
-- Name: COLUMN taxonconcept.verbatimrank; Type: COMMENT; Schema: public; Owner: -
|
1322 |
|
--
|
1323 |
|
|
1324 |
|
COMMENT ON COLUMN taxonconcept.verbatimrank IS 'The taxonconcept''s verbatim level in the taxonomic hierarchy. Does not need to be in the taxonrank closed list.';
|
1325 |
|
|
1326 |
|
|
1327 |
|
--
|
1328 |
|
-- Name: COLUMN taxonconcept.identifyingtaxonomicname; Type: COMMENT; Schema: public; Owner: -
|
1329 |
|
--
|
1330 |
|
|
1331 |
|
COMMENT ON COLUMN taxonconcept.identifyingtaxonomicname IS 'The taxonomic name that uniquely identifies this taxonconcept. If set, the other fields will not be used in duplicate elimination.';
|
1332 |
|
|
1333 |
|
|
1334 |
|
--
|
1335 |
|
-- Name: COLUMN taxonconcept.taxonomicname; Type: COMMENT; Schema: public; Owner: -
|
1336 |
|
--
|
1337 |
|
|
1338 |
|
COMMENT ON COLUMN taxonconcept.taxonomicname IS 'The concatenated taxonomic name which uniquely identifies this taxon. Does not include the author of the name.
|
1339 |
|
|
1340 |
|
Equivalent to Darwin Core''s scientificName.';
|
1341 |
|
|
1342 |
|
|
1343 |
|
--
|
1344 |
|
-- Name: COLUMN taxonconcept.author; Type: COMMENT; Schema: public; Owner: -
|
1345 |
|
--
|
1346 |
|
|
1347 |
|
COMMENT ON COLUMN taxonconcept.author IS 'The author of the taxonomic name.
|
1348 |
|
|
1349 |
|
Equivalent to Darwin Core''s scientificNameAuthorship.';
|
1350 |
|
|
1351 |
|
|
1352 |
|
--
|
1353 |
|
-- Name: COLUMN taxonconcept.taxonomicnamewithauthor; Type: COMMENT; Schema: public; Owner: -
|
1354 |
|
--
|
1355 |
|
|
1356 |
|
COMMENT ON COLUMN taxonconcept.taxonomicnamewithauthor IS 'The concatenated taxonomic name which uniquely identifies this taxon, plus the author of that name.
|
1357 |
|
|
1358 |
|
Equivalent to Darwin Core''s scientificName + scientificNameAuthorship.
|
1359 |
|
Equivalent to "Name sec. x".';
|
1360 |
|
|
1361 |
|
|
1362 |
|
--
|
1363 |
|
-- Name: COLUMN taxonconcept.family; Type: COMMENT; Schema: public; Owner: -
|
1364 |
|
--
|
1365 |
|
|
1366 |
|
COMMENT ON COLUMN taxonconcept.family IS 'The family of the taxonomic name. This is a cached field for easy querying; the identifying version of this field is stored in the chain of parent_id ancestors.';
|
1367 |
|
|
1368 |
|
|
1369 |
|
--
|
1370 |
|
-- Name: COLUMN taxonconcept.genus; Type: COMMENT; Schema: public; Owner: -
|
1371 |
|
--
|
1372 |
|
|
1373 |
|
COMMENT ON COLUMN taxonconcept.genus IS 'The genus portion of the taxonomic name. This is a cached field for easy querying; the identifying version of this field is stored in the chain of parent_id ancestors.';
|
1374 |
|
|
1375 |
|
|
1376 |
|
--
|
1377 |
|
-- Name: COLUMN taxonconcept.species; Type: COMMENT; Schema: public; Owner: -
|
1378 |
|
--
|
1379 |
|
|
1380 |
|
COMMENT ON COLUMN taxonconcept.species IS 'The species portion of the taxonomic name. This is a cached field for easy querying; the identifying version of this field is stored in the chain of parent_id ancestors.';
|
1381 |
|
|
1382 |
|
|
1383 |
|
--
|
1384 |
1420 |
-- Name: taxondetermination; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
1385 |
1421 |
--
|
1386 |
1422 |
|
... | ... | |
4836 |
4872 |
|
4837 |
4873 |
|
4838 |
4874 |
--
|
4839 |
|
-- Name: taxonconcept_update_ancestors; Type: TRIGGER; Schema: public; Owner: -
|
|
4875 |
-- Name: taxonconcept_update_ancestors_on_insert; Type: TRIGGER; Schema: public; Owner: -
|
4840 |
4876 |
--
|
4841 |
4877 |
|
4842 |
|
CREATE CONSTRAINT TRIGGER taxonconcept_update_ancestors AFTER INSERT OR UPDATE ON taxonconcept DEFERRABLE INITIALLY DEFERRED FOR EACH ROW EXECUTE PROCEDURE taxonconcept_update_ancestors();
|
|
4878 |
CREATE TRIGGER taxonconcept_update_ancestors_on_insert AFTER INSERT ON taxonconcept FOR EACH ROW EXECUTE PROCEDURE taxonconcept_update_ancestors_on_insert();
|
4843 |
4879 |
|
4844 |
4880 |
|
4845 |
4881 |
--
|
|
4882 |
-- Name: taxonconcept_update_ancestors_on_update; Type: TRIGGER; Schema: public; Owner: -
|
|
4883 |
--
|
|
4884 |
|
|
4885 |
CREATE TRIGGER taxonconcept_update_ancestors_on_update AFTER UPDATE ON taxonconcept FOR EACH ROW EXECUTE PROCEDURE taxonconcept_update_ancestors_on_update();
|
|
4886 |
|
|
4887 |
|
|
4888 |
--
|
4846 |
4889 |
-- Name: address_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
4847 |
4890 |
--
|
4848 |
4891 |
|
schemas/vegbien.sql: taxonconcept: Rewrote taxonconcept() trigger to avoid completely reinserting the taxonconcept_ancestor entries of all descendants every time taxonconcept changes or using trigger recursion to find descendants. Instead, just delete the old parent's ancestors from and add the new parent's ancestors to each descendant, using taxonconcept_ancestor itself (with the new taxonconcept_ancestor_descendants index) to find all descendants. As an additional optimization, only update taxonconcept_ancestor if the parent_id or matched_concept_id has actually changed. This fixes a bug in NCBI where inserting taxonconcepts out of dependency order caused taxonconcept_ancestor entries to be repeatedly regenerated, slowing the import down to a crawl.