Revision 4717
Added by Aaron Marcuse-Kubitza about 12 years ago
schemas/vegbien.my.sql | ||
---|---|---|
103 | 103 |
|
104 | 104 |
|
105 | 105 |
-- |
106 |
-- Name: plantname_update_ancestors(); Type: FUNCTION; Schema: public; Owner: -
|
|
106 |
-- Name: plantobservation_aggregateoccurrence_count_1(); Type: FUNCTION; Schema: public; Owner: -
|
|
107 | 107 |
-- |
108 | 108 |
|
109 | 109 |
|
110 | 110 |
|
111 | 111 |
|
112 | 112 |
-- |
113 |
-- Name: plantobservation_aggregateoccurrence_count_1(); Type: FUNCTION; Schema: public; Owner: -
|
|
113 |
-- Name: taxon_update_ancestors(); Type: FUNCTION; Schema: public; Owner: -
|
|
114 | 114 |
-- |
115 | 115 |
|
116 | 116 |
|
... | ... | |
670 | 670 |
plantconcept_id int(11) NOT NULL, |
671 | 671 |
datasource_id int(11) NOT NULL, |
672 | 672 |
plantcode text, |
673 |
plantname_id int(11),
|
|
673 |
taxon_id int(11),
|
|
674 | 674 |
scientificname text, |
675 | 675 |
scientificnameauthor text, |
676 | 676 |
scientificnamewithauthor text, |
... | ... | |
1667 | 1667 |
|
1668 | 1668 |
|
1669 | 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 |
taxonname text NOT NULL, |
|
1680 |
authority text, |
|
1681 |
description text, |
|
1682 |
accessioncode text |
|
1683 |
); |
|
1684 |
|
|
1685 |
|
|
1686 |
-- |
|
1687 |
-- Name: TABLE plantname; Type: COMMENT; Schema: public; Owner: - |
|
1688 |
-- |
|
1689 |
|
|
1690 |
|
|
1691 |
|
|
1692 |
|
|
1693 |
-- |
|
1694 |
-- Name: COLUMN plantname.rank; Type: COMMENT; Schema: public; Owner: - |
|
1695 |
-- |
|
1696 |
|
|
1697 |
|
|
1698 |
|
|
1699 |
|
|
1700 |
-- |
|
1701 |
-- Name: plantname_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
1702 |
-- |
|
1703 |
|
|
1704 |
CREATE TABLE plantname_ancestor ( |
|
1705 |
plantname_id int(11) NOT NULL, |
|
1706 |
ancestor_id int(11) NOT NULL |
|
1707 |
); |
|
1708 |
|
|
1709 |
|
|
1710 |
-- |
|
1711 |
-- Name: plantname_plantname_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
|
1712 |
-- |
|
1713 |
|
|
1714 |
|
|
1715 |
|
|
1716 |
|
|
1717 |
-- |
|
1718 |
-- Name: plantname_plantname_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - |
|
1719 |
-- |
|
1720 |
|
|
1721 |
|
|
1722 |
|
|
1723 |
|
|
1724 |
-- |
|
1725 |
-- Name: plantnamescope; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
1726 |
-- |
|
1727 |
|
|
1728 |
CREATE TABLE plantnamescope ( |
|
1729 |
plantnamescope_id int(11) NOT NULL, |
|
1730 |
locationevent_id int(11), |
|
1731 |
project_id int(11), |
|
1732 |
namedplace_id int(11) |
|
1733 |
); |
|
1734 |
|
|
1735 |
|
|
1736 |
-- |
|
1737 |
-- Name: plantnamescope_plantnamescope_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
|
1738 |
-- |
|
1739 |
|
|
1740 |
|
|
1741 |
|
|
1742 |
|
|
1743 |
-- |
|
1744 |
-- Name: plantnamescope_plantnamescope_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - |
|
1745 |
-- |
|
1746 |
|
|
1747 |
|
|
1748 |
|
|
1749 |
|
|
1750 |
-- |
|
1751 | 1670 |
-- Name: plantobservation_plantobservation_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
1752 | 1671 |
-- |
1753 | 1672 |
|
... | ... | |
1798 | 1717 |
|
1799 | 1718 |
CREATE TABLE plantusage ( |
1800 | 1719 |
plantusage_id int(11) NOT NULL, |
1801 |
plantname_id int(11) NOT NULL,
|
|
1720 |
taxon_id int(11) NOT NULL,
|
|
1802 | 1721 |
plantconcept_id int(11), |
1803 |
plantnamestatus text,
|
|
1804 |
plantname text,
|
|
1722 |
taxonstatus text,
|
|
1723 |
taxon text,
|
|
1805 | 1724 |
classsystem text, |
1806 | 1725 |
acceptedsynonym text, |
1807 | 1726 |
party_id int(11), |
... | ... | |
2395 | 2314 |
|
2396 | 2315 |
|
2397 | 2316 |
-- |
2317 |
-- Name: taxon; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2318 |
-- |
|
2319 |
|
|
2320 |
CREATE TABLE taxon ( |
|
2321 |
taxon_id int(11) NOT NULL, |
|
2322 |
parent_id int(11), |
|
2323 |
scope_id int(11), |
|
2324 |
rank text NOT NULL, |
|
2325 |
verbatimrank text, |
|
2326 |
taxonname text NOT NULL, |
|
2327 |
authority text, |
|
2328 |
description text, |
|
2329 |
accessioncode text |
|
2330 |
); |
|
2331 |
|
|
2332 |
|
|
2333 |
-- |
|
2334 |
-- Name: TABLE taxon; Type: COMMENT; Schema: public; Owner: - |
|
2335 |
-- |
|
2336 |
|
|
2337 |
|
|
2338 |
|
|
2339 |
|
|
2340 |
-- |
|
2341 |
-- Name: COLUMN taxon.rank; Type: COMMENT; Schema: public; Owner: - |
|
2342 |
-- |
|
2343 |
|
|
2344 |
|
|
2345 |
|
|
2346 |
|
|
2347 |
-- |
|
2348 |
-- Name: taxon_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2349 |
-- |
|
2350 |
|
|
2351 |
CREATE TABLE taxon_ancestor ( |
|
2352 |
taxon_id int(11) NOT NULL, |
|
2353 |
ancestor_id int(11) NOT NULL |
|
2354 |
); |
|
2355 |
|
|
2356 |
|
|
2357 |
-- |
|
2358 |
-- Name: taxon_taxon_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
|
2359 |
-- |
|
2360 |
|
|
2361 |
|
|
2362 |
|
|
2363 |
|
|
2364 |
-- |
|
2365 |
-- Name: taxon_taxon_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - |
|
2366 |
-- |
|
2367 |
|
|
2368 |
|
|
2369 |
|
|
2370 |
|
|
2371 |
-- |
|
2398 | 2372 |
-- Name: taxonalt; Type: TABLE; Schema: public; Owner: -; Tablespace: |
2399 | 2373 |
-- |
2400 | 2374 |
|
... | ... | |
2451 | 2425 |
|
2452 | 2426 |
|
2453 | 2427 |
-- |
2428 |
-- Name: taxonscope; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2429 |
-- |
|
2430 |
|
|
2431 |
CREATE TABLE taxonscope ( |
|
2432 |
taxonscope_id int(11) NOT NULL, |
|
2433 |
locationevent_id int(11), |
|
2434 |
project_id int(11), |
|
2435 |
namedplace_id int(11) |
|
2436 |
); |
|
2437 |
|
|
2438 |
|
|
2439 |
-- |
|
2440 |
-- Name: taxonscope_taxonscope_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
|
2441 |
-- |
|
2442 |
|
|
2443 |
|
|
2444 |
|
|
2445 |
|
|
2446 |
-- |
|
2447 |
-- Name: taxonscope_taxonscope_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - |
|
2448 |
-- |
|
2449 |
|
|
2450 |
|
|
2451 |
|
|
2452 |
|
|
2453 |
-- |
|
2454 | 2454 |
-- Name: telephone; Type: TABLE; Schema: public; Owner: -; Tablespace: |
2455 | 2455 |
-- |
2456 | 2456 |
|
... | ... | |
2789 | 2789 |
|
2790 | 2790 |
|
2791 | 2791 |
-- |
2792 |
-- Name: plantname_id; Type: DEFAULT; Schema: public; Owner: - |
|
2793 |
-- |
|
2794 |
|
|
2795 |
|
|
2796 |
|
|
2797 |
|
|
2798 |
-- |
|
2799 |
-- Name: plantnamescope_id; Type: DEFAULT; Schema: public; Owner: - |
|
2800 |
-- |
|
2801 |
|
|
2802 |
|
|
2803 |
|
|
2804 |
|
|
2805 |
-- |
|
2806 | 2792 |
-- Name: plantobservation_id; Type: DEFAULT; Schema: public; Owner: - |
2807 | 2793 |
-- |
2808 | 2794 |
|
... | ... | |
2929 | 2915 |
|
2930 | 2916 |
|
2931 | 2917 |
-- |
2918 |
-- Name: taxon_id; Type: DEFAULT; Schema: public; Owner: - |
|
2919 |
-- |
|
2920 |
|
|
2921 |
|
|
2922 |
|
|
2923 |
|
|
2924 |
-- |
|
2932 | 2925 |
-- Name: taxonalt_id; Type: DEFAULT; Schema: public; Owner: - |
2933 | 2926 |
-- |
2934 | 2927 |
|
... | ... | |
2950 | 2943 |
|
2951 | 2944 |
|
2952 | 2945 |
-- |
2946 |
-- Name: taxonscope_id; Type: DEFAULT; Schema: public; Owner: - |
|
2947 |
-- |
|
2948 |
|
|
2949 |
|
|
2950 |
|
|
2951 |
|
|
2952 |
-- |
|
2953 | 2953 |
-- Name: telephone_id; Type: DEFAULT; Schema: public; Owner: - |
2954 | 2954 |
-- |
2955 | 2955 |
|
... | ... | |
3306 | 3306 |
|
3307 | 3307 |
|
3308 | 3308 |
-- |
3309 |
-- Name: plantname_ancestor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3310 |
-- |
|
3311 |
|
|
3312 |
ALTER TABLE plantname_ancestor |
|
3313 |
ADD CONSTRAINT plantname_ancestor_pkey PRIMARY KEY (plantname_id, ancestor_id); |
|
3314 |
|
|
3315 |
|
|
3316 |
-- |
|
3317 |
-- Name: plantname_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3318 |
-- |
|
3319 |
|
|
3320 |
ALTER TABLE plantname |
|
3321 |
ADD CONSTRAINT plantname_pkey PRIMARY KEY (plantname_id); |
|
3322 |
|
|
3323 |
|
|
3324 |
-- |
|
3325 |
-- Name: plantnamescope_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3326 |
-- |
|
3327 |
|
|
3328 |
ALTER TABLE plantnamescope |
|
3329 |
ADD CONSTRAINT plantnamescope_pkey PRIMARY KEY (plantnamescope_id); |
|
3330 |
|
|
3331 |
|
|
3332 |
-- |
|
3333 | 3309 |
-- Name: plantobservation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
3334 | 3310 |
-- |
3335 | 3311 |
|
... | ... | |
3514 | 3490 |
|
3515 | 3491 |
|
3516 | 3492 |
-- |
3493 |
-- Name: taxon_ancestor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3494 |
-- |
|
3495 |
|
|
3496 |
ALTER TABLE taxon_ancestor |
|
3497 |
ADD CONSTRAINT taxon_ancestor_pkey PRIMARY KEY (taxon_id, ancestor_id); |
|
3498 |
|
|
3499 |
|
|
3500 |
-- |
|
3501 |
-- Name: taxon_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3502 |
-- |
|
3503 |
|
|
3504 |
ALTER TABLE taxon |
|
3505 |
ADD CONSTRAINT taxon_pkey PRIMARY KEY (taxon_id); |
|
3506 |
|
|
3507 |
|
|
3508 |
-- |
|
3517 | 3509 |
-- Name: taxonalt_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
3518 | 3510 |
-- |
3519 | 3511 |
|
... | ... | |
3538 | 3530 |
|
3539 | 3531 |
|
3540 | 3532 |
-- |
3533 |
-- Name: taxonscope_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3534 |
-- |
|
3535 |
|
|
3536 |
ALTER TABLE taxonscope |
|
3537 |
ADD CONSTRAINT taxonscope_pkey PRIMARY KEY (taxonscope_id); |
|
3538 |
|
|
3539 |
|
|
3540 |
-- |
|
3541 | 3541 |
-- Name: telephone_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
3542 | 3542 |
-- |
3543 | 3543 |
|
... | ... | |
3789 | 3789 |
|
3790 | 3790 |
|
3791 | 3791 |
-- |
3792 |
-- Name: plantname_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: |
|
3793 |
-- |
|
3794 |
|
|
3795 |
|
|
3796 |
|
|
3797 |
|
|
3798 |
-- |
|
3799 |
-- Name: plantnamescope_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: |
|
3800 |
-- |
|
3801 |
|
|
3802 |
|
|
3803 |
|
|
3804 |
|
|
3805 |
-- |
|
3806 | 3792 |
-- Name: plantobservation_aggregateoccurrence_1_to_1; Type: INDEX; Schema: public; Owner: -; Tablespace: |
3807 | 3793 |
-- |
3808 | 3794 |
|
... | ... | |
3915 | 3901 |
|
3916 | 3902 |
|
3917 | 3903 |
-- |
3904 |
-- Name: taxon_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: |
|
3905 |
-- |
|
3906 |
|
|
3907 |
|
|
3908 |
|
|
3909 |
|
|
3910 |
-- |
|
3918 | 3911 |
-- Name: taxondetermination_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: |
3919 | 3912 |
-- |
3920 | 3913 |
|
... | ... | |
3950 | 3943 |
|
3951 | 3944 |
|
3952 | 3945 |
-- |
3946 |
-- Name: taxonscope_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: |
|
3947 |
-- |
|
3948 |
|
|
3949 |
|
|
3950 |
|
|
3951 |
|
|
3952 |
-- |
|
3953 | 3953 |
-- Name: userdefined_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: |
3954 | 3954 |
-- |
3955 | 3955 |
|
... | ... | |
3964 | 3964 |
|
3965 | 3965 |
|
3966 | 3966 |
-- |
3967 |
-- Name: plantname_update_ancestors; Type: TRIGGER; Schema: public; Owner: -
|
|
3967 |
-- Name: plantobservation_aggregateoccurrence_count_1; Type: TRIGGER; Schema: public; Owner: -
|
|
3968 | 3968 |
-- |
3969 | 3969 |
|
3970 | 3970 |
|
3971 | 3971 |
|
3972 | 3972 |
|
3973 | 3973 |
-- |
3974 |
-- Name: plantobservation_aggregateoccurrence_count_1; Type: TRIGGER; Schema: public; Owner: -
|
|
3974 |
-- Name: taxon_update_ancestors; Type: TRIGGER; Schema: public; Owner: -
|
|
3975 | 3975 |
-- |
3976 | 3976 |
|
3977 | 3977 |
|
... | ... | |
4500 | 4500 |
|
4501 | 4501 |
|
4502 | 4502 |
-- |
4503 |
-- Name: plantconcept_plantname_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
4503 |
-- Name: plantconcept_taxon_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
4504 | 4504 |
-- |
4505 | 4505 |
|
4506 | 4506 |
ALTER TABLE plantconcept |
4507 |
ADD CONSTRAINT plantconcept_plantname_id_fkey FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
4507 |
ADD CONSTRAINT plantconcept_taxon_id_fkey FOREIGN KEY (taxon_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
4508 | 4508 |
|
4509 | 4509 |
|
4510 | 4510 |
-- |
... | ... | |
4539 | 4539 |
|
4540 | 4540 |
|
4541 | 4541 |
-- |
4542 |
-- Name: plantname_ancestor_ancestor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4543 |
-- |
|
4544 |
|
|
4545 |
ALTER TABLE plantname_ancestor |
|
4546 |
ADD CONSTRAINT plantname_ancestor_ancestor_id_fkey FOREIGN KEY (ancestor_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4547 |
|
|
4548 |
|
|
4549 |
-- |
|
4550 |
-- Name: plantname_ancestor_plantname_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4551 |
-- |
|
4552 |
|
|
4553 |
ALTER TABLE plantname_ancestor |
|
4554 |
ADD CONSTRAINT plantname_ancestor_plantname_id_fkey FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4555 |
|
|
4556 |
|
|
4557 |
-- |
|
4558 |
-- Name: plantname_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4559 |
-- |
|
4560 |
|
|
4561 |
ALTER TABLE plantname |
|
4562 |
ADD CONSTRAINT plantname_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4563 |
|
|
4564 |
|
|
4565 |
-- |
|
4566 |
-- Name: plantname_scope_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4567 |
-- |
|
4568 |
|
|
4569 |
ALTER TABLE plantname |
|
4570 |
ADD CONSTRAINT plantname_scope_id_fkey FOREIGN KEY (scope_id) REFERENCES plantnamescope(plantnamescope_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4571 |
|
|
4572 |
|
|
4573 |
-- |
|
4574 |
-- Name: plantnamescope_locationevent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4575 |
-- |
|
4576 |
|
|
4577 |
|
|
4578 |
|
|
4579 |
|
|
4580 |
-- |
|
4581 |
-- Name: plantnamescope_namedplace_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4582 |
-- |
|
4583 |
|
|
4584 |
|
|
4585 |
|
|
4586 |
|
|
4587 |
-- |
|
4588 |
-- Name: plantnamescope_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4589 |
-- |
|
4590 |
|
|
4591 |
|
|
4592 |
|
|
4593 |
|
|
4594 |
-- |
|
4595 | 4542 |
-- Name: plantobservation_aggregateoccurrence_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
4596 | 4543 |
-- |
4597 | 4544 |
|
... | ... | |
4650 | 4597 |
|
4651 | 4598 |
|
4652 | 4599 |
-- |
4653 |
-- Name: plantusage_plantname_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
4600 |
-- Name: plantusage_plantstatus_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
4654 | 4601 |
-- |
4655 | 4602 |
|
4656 | 4603 |
ALTER TABLE plantusage |
4657 |
ADD CONSTRAINT plantusage_plantname_id_fkey FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
4604 |
ADD CONSTRAINT plantusage_plantstatus_id_fkey FOREIGN KEY (plantstatus_id) REFERENCES plantstatus(plantstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
4658 | 4605 |
|
4659 | 4606 |
|
4660 | 4607 |
-- |
4661 |
-- Name: plantusage_plantstatus_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
4608 |
-- Name: plantusage_taxon_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
4662 | 4609 |
-- |
4663 | 4610 |
|
4664 | 4611 |
ALTER TABLE plantusage |
4665 |
ADD CONSTRAINT plantusage_plantstatus_id_fkey FOREIGN KEY (plantstatus_id) REFERENCES plantstatus(plantstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
4612 |
ADD CONSTRAINT plantusage_taxon_id_fkey FOREIGN KEY (taxon_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
4666 | 4613 |
|
4667 | 4614 |
|
4668 | 4615 |
-- |
... | ... | |
4820 | 4767 |
|
4821 | 4768 |
|
4822 | 4769 |
-- |
4770 |
-- Name: taxon_ancestor_ancestor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4771 |
-- |
|
4772 |
|
|
4773 |
ALTER TABLE taxon_ancestor |
|
4774 |
ADD CONSTRAINT taxon_ancestor_ancestor_id_fkey FOREIGN KEY (ancestor_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4775 |
|
|
4776 |
|
|
4777 |
-- |
|
4778 |
-- Name: taxon_ancestor_taxon_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4779 |
-- |
|
4780 |
|
|
4781 |
ALTER TABLE taxon_ancestor |
|
4782 |
ADD CONSTRAINT taxon_ancestor_taxon_id_fkey FOREIGN KEY (taxon_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4783 |
|
|
4784 |
|
|
4785 |
-- |
|
4786 |
-- Name: taxon_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4787 |
-- |
|
4788 |
|
|
4789 |
ALTER TABLE taxon |
|
4790 |
ADD CONSTRAINT taxon_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4791 |
|
|
4792 |
|
|
4793 |
-- |
|
4794 |
-- Name: taxon_scope_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4795 |
-- |
|
4796 |
|
|
4797 |
ALTER TABLE taxon |
|
4798 |
ADD CONSTRAINT taxon_scope_id_fkey FOREIGN KEY (scope_id) REFERENCES taxonscope(taxonscope_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
4799 |
|
|
4800 |
|
|
4801 |
-- |
|
4823 | 4802 |
-- Name: taxonalt_plantconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
4824 | 4803 |
-- |
4825 | 4804 |
|
... | ... | |
4881 | 4860 |
|
4882 | 4861 |
|
4883 | 4862 |
-- |
4863 |
-- Name: taxonscope_locationevent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4864 |
-- |
|
4865 |
|
|
4866 |
|
|
4867 |
|
|
4868 |
|
|
4869 |
-- |
|
4870 |
-- Name: taxonscope_namedplace_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4871 |
-- |
|
4872 |
|
|
4873 |
|
|
4874 |
|
|
4875 |
|
|
4876 |
-- |
|
4877 |
-- Name: taxonscope_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
4878 |
-- |
|
4879 |
|
|
4880 |
|
|
4881 |
|
|
4882 |
|
|
4883 |
-- |
|
4884 | 4884 |
-- Name: telephone_party_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
4885 | 4885 |
-- |
4886 | 4886 |
|
schemas/filter_ERD.csv | ||
---|---|---|
1 | 1 |
"PostgreSQL","MySQL","Comments" |
2 | 2 |
,,"fkeys to heavily-linked tables" |
3 |
"^ALTER TABLE (?:commclass|plantnamescope)\b[^;]*\bFOREIGN KEY\b[^;]*\bREFERENCES \b[^;]*;",,outward
|
|
4 |
"^ALTER TABLE (?:plant\w+)\b[^;]*\bFOREIGN KEY\b[^;]*\bREFERENCES plantconcept\b[^;]*;",,inward |
|
3 |
"^ALTER TABLE (?:commclass|taxonscope)\b[^;]*\bFOREIGN KEY\b[^;]*\bREFERENCES \b[^;]*;",,outward
|
|
4 |
"^ALTER TABLE (?:taxon|plant\w+)\b[^;]*\bFOREIGN KEY\b[^;]*\bREFERENCES plantconcept\b[^;]*;",,inward
|
|
5 | 5 |
"^ALTER TABLE \b[^;]*\bFOREIGN KEY\b[^;]*\bREFERENCES coverindex\b[^;]*;",,inward |
6 | 6 |
"^ALTER TABLE (?!method)\b[^;]*\bFOREIGN KEY\b[^;]*\bREFERENCES method\b[^;]*;",,inward |
7 | 7 |
"^ALTER TABLE (?!party|address|telephone)\b[^;]*\bFOREIGN KEY\b[^;]*\bREFERENCES party\b[^;]*;",,inward |
schemas/vegbien.sql | ||
---|---|---|
287 | 287 |
|
288 | 288 |
|
289 | 289 |
-- |
290 |
-- Name: plantname_update_ancestors(); Type: FUNCTION; Schema: public; Owner: -
|
|
290 |
-- Name: plantobservation_aggregateoccurrence_count_1(); Type: FUNCTION; Schema: public; Owner: -
|
|
291 | 291 |
-- |
292 | 292 |
|
293 |
CREATE FUNCTION plantname_update_ancestors() RETURNS trigger
|
|
293 |
CREATE FUNCTION plantobservation_aggregateoccurrence_count_1() RETURNS trigger
|
|
294 | 294 |
LANGUAGE plpgsql |
295 | 295 |
AS $$ |
296 | 296 |
BEGIN |
297 |
UPDATE aggregateoccurrence |
|
298 |
SET count = GREATEST(COALESCE(count, 0), 1) -- at least 1 |
|
299 |
WHERE aggregateoccurrence_id = new.aggregateoccurrence_id |
|
300 |
; |
|
301 |
RETURN new; |
|
302 |
END; |
|
303 |
$$; |
|
304 |
|
|
305 |
|
|
306 |
-- |
|
307 |
-- Name: taxon_update_ancestors(); Type: FUNCTION; Schema: public; Owner: - |
|
308 |
-- |
|
309 |
|
|
310 |
CREATE FUNCTION taxon_update_ancestors() RETURNS trigger |
|
311 |
LANGUAGE plpgsql |
|
312 |
AS $$ |
|
313 |
BEGIN |
|
297 | 314 |
-- Delete existing ancestors |
298 |
DELETE FROM plantname_ancestor WHERE plantname_id = new.plantname_id;
|
|
315 |
DELETE FROM taxon_ancestor WHERE taxon_id = new.taxon_id;
|
|
299 | 316 |
|
300 | 317 |
IF new.parent_id IS NOT NULL THEN |
301 | 318 |
-- Copy parent's ancestors to this node's ancestors |
302 | 319 |
INSERT |
303 |
INTO plantname_ancestor
|
|
304 |
(plantname_id, ancestor_id)
|
|
320 |
INTO taxon_ancestor
|
|
321 |
(taxon_id, ancestor_id)
|
|
305 | 322 |
SELECT |
306 |
new.plantname_id, ancestor_id
|
|
307 |
FROM plantname_ancestor
|
|
308 |
WHERE plantname_id = new.parent_id
|
|
323 |
new.taxon_id, ancestor_id
|
|
324 |
FROM taxon_ancestor
|
|
325 |
WHERE taxon_id = new.parent_id
|
|
309 | 326 |
; |
310 | 327 |
END IF; |
311 | 328 |
|
... | ... | |
314 | 331 |
the leaf node is the one you're looking for, in addition to that leaf node's |
315 | 332 |
ancestors. */ |
316 | 333 |
INSERT |
317 |
INTO plantname_ancestor
|
|
318 |
(plantname_id, ancestor_id)
|
|
319 |
VALUES (new.plantname_id, new.plantname_id)
|
|
334 |
INTO taxon_ancestor
|
|
335 |
(taxon_id, ancestor_id)
|
|
336 |
VALUES (new.taxon_id, new.taxon_id)
|
|
320 | 337 |
; |
321 | 338 |
|
322 | 339 |
-- Tell immediate children to update their ancestors lists, which will |
323 | 340 |
-- recursively tell all descendants |
324 |
UPDATE plantname
|
|
325 |
SET plantname_id = plantname_id -- need at least one SET statement
|
|
326 |
-- Add COALESCE() to enable using plantname_unique index for lookup
|
|
327 |
WHERE COALESCE(parent_id, 2147483647) = new.plantname_id
|
|
341 |
UPDATE taxon
|
|
342 |
SET taxon_id = taxon_id -- need at least one SET statement
|
|
343 |
-- Add COALESCE() to enable using taxon_unique index for lookup
|
|
344 |
WHERE COALESCE(parent_id, 2147483647) = new.taxon_id
|
|
328 | 345 |
; |
329 | 346 |
|
330 | 347 |
/* Note: We don't need an ON DELETE trigger to update the descendants' |
331 |
ancestors when a node is deleted, because the plantname.plantname_parent_id
|
|
348 |
ancestors when a node is deleted, because the taxon.taxon_parent_id
|
|
332 | 349 |
foreign key is set to ON DELETE CASCADE, which just removes all the |
333 | 350 |
descendants anyway. */ |
334 | 351 |
|
... | ... | |
338 | 355 |
|
339 | 356 |
|
340 | 357 |
-- |
341 |
-- Name: plantobservation_aggregateoccurrence_count_1(); Type: FUNCTION; Schema: public; Owner: - |
|
342 |
-- |
|
343 |
|
|
344 |
CREATE FUNCTION plantobservation_aggregateoccurrence_count_1() RETURNS trigger |
|
345 |
LANGUAGE plpgsql |
|
346 |
AS $$ |
|
347 |
BEGIN |
|
348 |
UPDATE aggregateoccurrence |
|
349 |
SET count = GREATEST(COALESCE(count, 0), 1) -- at least 1 |
|
350 |
WHERE aggregateoccurrence_id = new.aggregateoccurrence_id |
|
351 |
; |
|
352 |
RETURN new; |
|
353 |
END; |
|
354 |
$$; |
|
355 |
|
|
356 |
|
|
357 |
-- |
|
358 | 358 |
-- Name: concat(text); Type: AGGREGATE; Schema: public; Owner: - |
359 | 359 |
-- |
360 | 360 |
|
... | ... | |
949 | 949 |
plantconcept_id integer NOT NULL, |
950 | 950 |
datasource_id integer NOT NULL, |
951 | 951 |
plantcode text, |
952 |
plantname_id integer,
|
|
952 |
taxon_id integer,
|
|
953 | 953 |
scientificname text, |
954 | 954 |
scientificnameauthor text, |
955 | 955 |
scientificnamewithauthor text, |
... | ... | |
2119 | 2119 |
|
2120 | 2120 |
|
2121 | 2121 |
-- |
2122 |
-- Name: plantname; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2123 |
-- |
|
2124 |
|
|
2125 |
CREATE TABLE plantname ( |
|
2126 |
plantname_id integer NOT NULL, |
|
2127 |
parent_id integer, |
|
2128 |
scope_id integer, |
|
2129 |
rank taxonrank NOT NULL, |
|
2130 |
verbatimrank text, |
|
2131 |
taxonname text NOT NULL, |
|
2132 |
authority text, |
|
2133 |
description text, |
|
2134 |
accessioncode text |
|
2135 |
); |
|
2136 |
|
|
2137 |
|
|
2138 |
-- |
|
2139 |
-- Name: TABLE plantname; Type: COMMENT; Schema: public; Owner: - |
|
2140 |
-- |
|
2141 |
|
|
2142 |
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.'; |
|
2143 |
|
|
2144 |
|
|
2145 |
-- |
|
2146 |
-- Name: COLUMN plantname.rank; Type: COMMENT; Schema: public; Owner: - |
|
2147 |
-- |
|
2148 |
|
|
2149 |
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.'; |
|
2150 |
|
|
2151 |
|
|
2152 |
-- |
|
2153 |
-- Name: plantname_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2154 |
-- |
|
2155 |
|
|
2156 |
CREATE TABLE plantname_ancestor ( |
|
2157 |
plantname_id integer NOT NULL, |
|
2158 |
ancestor_id integer NOT NULL |
|
2159 |
); |
|
2160 |
|
|
2161 |
|
|
2162 |
-- |
|
2163 |
-- Name: plantname_plantname_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
|
2164 |
-- |
|
2165 |
|
|
2166 |
CREATE SEQUENCE plantname_plantname_id_seq |
|
2167 |
START WITH 1 |
|
2168 |
INCREMENT BY 1 |
|
2169 |
NO MINVALUE |
|
2170 |
NO MAXVALUE |
|
2171 |
CACHE 1; |
|
2172 |
|
|
2173 |
|
|
2174 |
-- |
|
2175 |
-- Name: plantname_plantname_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - |
|
2176 |
-- |
|
2177 |
|
|
2178 |
ALTER SEQUENCE plantname_plantname_id_seq OWNED BY plantname.plantname_id; |
|
2179 |
|
|
2180 |
|
|
2181 |
-- |
|
2182 |
-- Name: plantnamescope; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2183 |
-- |
|
2184 |
|
|
2185 |
CREATE TABLE plantnamescope ( |
|
2186 |
plantnamescope_id integer NOT NULL, |
|
2187 |
locationevent_id integer, |
|
2188 |
project_id integer, |
|
2189 |
namedplace_id integer, |
|
2190 |
CONSTRAINT plantnamescope_required_key CHECK ((((locationevent_id IS NOT NULL) OR (project_id IS NOT NULL)) OR (namedplace_id IS NOT NULL))) |
|
2191 |
); |
|
2192 |
|
|
2193 |
|
|
2194 |
-- |
|
2195 |
-- Name: plantnamescope_plantnamescope_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
|
2196 |
-- |
|
2197 |
|
|
2198 |
CREATE SEQUENCE plantnamescope_plantnamescope_id_seq |
|
2199 |
START WITH 1 |
|
2200 |
INCREMENT BY 1 |
|
2201 |
NO MINVALUE |
|
2202 |
NO MAXVALUE |
|
2203 |
CACHE 1; |
|
2204 |
|
|
2205 |
|
|
2206 |
-- |
|
2207 |
-- Name: plantnamescope_plantnamescope_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - |
|
2208 |
-- |
|
2209 |
|
|
2210 |
ALTER SEQUENCE plantnamescope_plantnamescope_id_seq OWNED BY plantnamescope.plantnamescope_id; |
|
2211 |
|
|
2212 |
|
|
2213 |
-- |
|
2214 | 2122 |
-- Name: plantobservation_plantobservation_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
2215 | 2123 |
-- |
2216 | 2124 |
|
... | ... | |
2271 | 2179 |
|
2272 | 2180 |
CREATE TABLE plantusage ( |
2273 | 2181 |
plantusage_id integer NOT NULL, |
2274 |
plantname_id integer NOT NULL,
|
|
2182 |
taxon_id integer NOT NULL,
|
|
2275 | 2183 |
plantconcept_id integer, |
2276 |
plantnamestatus text,
|
|
2277 |
plantname text,
|
|
2184 |
taxonstatus text,
|
|
2185 |
taxon text,
|
|
2278 | 2186 |
classsystem text, |
2279 | 2187 |
acceptedsynonym text, |
2280 | 2188 |
party_id integer, |
... | ... | |
2949 | 2857 |
|
2950 | 2858 |
|
2951 | 2859 |
-- |
2860 |
-- Name: taxon; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2861 |
-- |
|
2862 |
|
|
2863 |
CREATE TABLE taxon ( |
|
2864 |
taxon_id integer NOT NULL, |
|
2865 |
parent_id integer, |
|
2866 |
scope_id integer, |
|
2867 |
rank taxonrank NOT NULL, |
|
2868 |
verbatimrank text, |
|
2869 |
taxonname text NOT NULL, |
|
2870 |
authority text, |
|
2871 |
description text, |
|
2872 |
accessioncode text |
|
2873 |
); |
|
2874 |
|
|
2875 |
|
|
2876 |
-- |
|
2877 |
-- Name: TABLE taxon; Type: COMMENT; Schema: public; Owner: - |
|
2878 |
-- |
|
2879 |
|
|
2880 |
COMMENT ON TABLE taxon IS 'To include a taxon name at a rank with no explicit column, create a taxon for it and point to it using taxon_id. To include multiple such names, chain the taxons together using parent_id, as a form of ordered linked list. Note that lower-level taxa should point to higher-level taxa.'; |
|
2881 |
|
|
2882 |
|
|
2883 |
-- |
|
2884 |
-- Name: COLUMN taxon.rank; Type: COMMENT; Schema: public; Owner: - |
|
2885 |
-- |
|
2886 |
|
|
2887 |
COMMENT ON COLUMN taxon.rank IS 'Even if you specify a custom verbatimrank, you must also specify a closest-match rank from the taxonrank closed list.'; |
|
2888 |
|
|
2889 |
|
|
2890 |
-- |
|
2891 |
-- Name: taxon_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2892 |
-- |
|
2893 |
|
|
2894 |
CREATE TABLE taxon_ancestor ( |
|
2895 |
taxon_id integer NOT NULL, |
|
2896 |
ancestor_id integer NOT NULL |
|
2897 |
); |
|
2898 |
|
|
2899 |
|
|
2900 |
-- |
|
2901 |
-- Name: taxon_taxon_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
|
2902 |
-- |
|
2903 |
|
|
2904 |
CREATE SEQUENCE taxon_taxon_id_seq |
|
2905 |
START WITH 1 |
|
2906 |
INCREMENT BY 1 |
|
2907 |
NO MINVALUE |
|
2908 |
NO MAXVALUE |
|
2909 |
CACHE 1; |
|
2910 |
|
|
2911 |
|
|
2912 |
-- |
|
2913 |
-- Name: taxon_taxon_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - |
|
2914 |
-- |
|
2915 |
|
|
2916 |
ALTER SEQUENCE taxon_taxon_id_seq OWNED BY taxon.taxon_id; |
|
2917 |
|
|
2918 |
|
|
2919 |
-- |
|
2952 | 2920 |
-- Name: taxonalt; Type: TABLE; Schema: public; Owner: -; Tablespace: |
2953 | 2921 |
-- |
2954 | 2922 |
|
... | ... | |
3020 | 2988 |
|
3021 | 2989 |
|
3022 | 2990 |
-- |
2991 |
-- Name: taxonscope; Type: TABLE; Schema: public; Owner: -; Tablespace: |
|
2992 |
-- |
|
2993 |
|
|
2994 |
CREATE TABLE taxonscope ( |
|
2995 |
taxonscope_id integer NOT NULL, |
|
2996 |
locationevent_id integer, |
|
2997 |
project_id integer, |
|
2998 |
namedplace_id integer, |
|
2999 |
CONSTRAINT taxonscope_required_key CHECK ((((locationevent_id IS NOT NULL) OR (project_id IS NOT NULL)) OR (namedplace_id IS NOT NULL))) |
|
3000 |
); |
|
3001 |
|
|
3002 |
|
|
3003 |
-- |
|
3004 |
-- Name: taxonscope_taxonscope_id_seq; Type: SEQUENCE; Schema: public; Owner: - |
|
3005 |
-- |
|
3006 |
|
|
3007 |
CREATE SEQUENCE taxonscope_taxonscope_id_seq |
|
3008 |
START WITH 1 |
|
3009 |
INCREMENT BY 1 |
|
3010 |
NO MINVALUE |
|
3011 |
NO MAXVALUE |
|
3012 |
CACHE 1; |
|
3013 |
|
|
3014 |
|
|
3015 |
-- |
|
3016 |
-- Name: taxonscope_taxonscope_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - |
|
3017 |
-- |
|
3018 |
|
|
3019 |
ALTER SEQUENCE taxonscope_taxonscope_id_seq OWNED BY taxonscope.taxonscope_id; |
|
3020 |
|
|
3021 |
|
|
3022 |
-- |
|
3023 | 3023 |
-- Name: telephone; Type: TABLE; Schema: public; Owner: -; Tablespace: |
3024 | 3024 |
-- |
3025 | 3025 |
|
... | ... | |
3378 | 3378 |
|
3379 | 3379 |
|
3380 | 3380 |
-- |
3381 |
-- Name: plantname_id; Type: DEFAULT; Schema: public; Owner: - |
|
3382 |
-- |
|
3383 |
|
|
3384 |
ALTER TABLE plantname ALTER COLUMN plantname_id SET DEFAULT nextval('plantname_plantname_id_seq'::regclass); |
|
3385 |
|
|
3386 |
|
|
3387 |
-- |
|
3388 |
-- Name: plantnamescope_id; Type: DEFAULT; Schema: public; Owner: - |
|
3389 |
-- |
|
3390 |
|
|
3391 |
ALTER TABLE plantnamescope ALTER COLUMN plantnamescope_id SET DEFAULT nextval('plantnamescope_plantnamescope_id_seq'::regclass); |
|
3392 |
|
|
3393 |
|
|
3394 |
-- |
|
3395 | 3381 |
-- Name: plantobservation_id; Type: DEFAULT; Schema: public; Owner: - |
3396 | 3382 |
-- |
3397 | 3383 |
|
... | ... | |
3518 | 3504 |
|
3519 | 3505 |
|
3520 | 3506 |
-- |
3507 |
-- Name: taxon_id; Type: DEFAULT; Schema: public; Owner: - |
|
3508 |
-- |
|
3509 |
|
|
3510 |
ALTER TABLE taxon ALTER COLUMN taxon_id SET DEFAULT nextval('taxon_taxon_id_seq'::regclass); |
|
3511 |
|
|
3512 |
|
|
3513 |
-- |
|
3521 | 3514 |
-- Name: taxonalt_id; Type: DEFAULT; Schema: public; Owner: - |
3522 | 3515 |
-- |
3523 | 3516 |
|
... | ... | |
3539 | 3532 |
|
3540 | 3533 |
|
3541 | 3534 |
-- |
3535 |
-- Name: taxonscope_id; Type: DEFAULT; Schema: public; Owner: - |
|
3536 |
-- |
|
3537 |
|
|
3538 |
ALTER TABLE taxonscope ALTER COLUMN taxonscope_id SET DEFAULT nextval('taxonscope_taxonscope_id_seq'::regclass); |
|
3539 |
|
|
3540 |
|
|
3541 |
-- |
|
3542 | 3542 |
-- Name: telephone_id; Type: DEFAULT; Schema: public; Owner: - |
3543 | 3543 |
-- |
3544 | 3544 |
|
... | ... | |
3895 | 3895 |
|
3896 | 3896 |
|
3897 | 3897 |
-- |
3898 |
-- Name: plantname_ancestor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3899 |
-- |
|
3900 |
|
|
3901 |
ALTER TABLE ONLY plantname_ancestor |
|
3902 |
ADD CONSTRAINT plantname_ancestor_pkey PRIMARY KEY (plantname_id, ancestor_id); |
|
3903 |
|
|
3904 |
|
|
3905 |
-- |
|
3906 |
-- Name: plantname_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3907 |
-- |
|
3908 |
|
|
3909 |
ALTER TABLE ONLY plantname |
|
3910 |
ADD CONSTRAINT plantname_pkey PRIMARY KEY (plantname_id); |
|
3911 |
|
|
3912 |
|
|
3913 |
-- |
|
3914 |
-- Name: plantnamescope_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
3915 |
-- |
|
3916 |
|
|
3917 |
ALTER TABLE ONLY plantnamescope |
|
3918 |
ADD CONSTRAINT plantnamescope_pkey PRIMARY KEY (plantnamescope_id); |
|
3919 |
|
|
3920 |
|
|
3921 |
-- |
|
3922 | 3898 |
-- Name: plantobservation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
3923 | 3899 |
-- |
3924 | 3900 |
|
... | ... | |
4103 | 4079 |
|
4104 | 4080 |
|
4105 | 4081 |
-- |
4082 |
-- Name: taxon_ancestor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
4083 |
-- |
|
4084 |
|
|
4085 |
ALTER TABLE ONLY taxon_ancestor |
|
4086 |
ADD CONSTRAINT taxon_ancestor_pkey PRIMARY KEY (taxon_id, ancestor_id); |
|
4087 |
|
|
4088 |
|
|
4089 |
-- |
|
4090 |
-- Name: taxon_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
4091 |
-- |
|
4092 |
|
|
4093 |
ALTER TABLE ONLY taxon |
|
4094 |
ADD CONSTRAINT taxon_pkey PRIMARY KEY (taxon_id); |
|
4095 |
|
|
4096 |
|
|
4097 |
-- |
|
4106 | 4098 |
-- Name: taxonalt_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
4107 | 4099 |
-- |
4108 | 4100 |
|
... | ... | |
4127 | 4119 |
|
4128 | 4120 |
|
4129 | 4121 |
-- |
4122 |
-- Name: taxonscope_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
|
4123 |
-- |
|
4124 |
|
|
4125 |
ALTER TABLE ONLY taxonscope |
|
4126 |
ADD CONSTRAINT taxonscope_pkey PRIMARY KEY (taxonscope_id); |
|
4127 |
|
|
4128 |
|
|
4129 |
-- |
|
4130 | 4130 |
-- Name: telephone_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: |
4131 | 4131 |
-- |
4132 | 4132 |
|
... | ... | |
4374 | 4374 |
-- Name: plantconcept_unique_within_datasource_by_name; Type: INDEX; Schema: public; Owner: -; Tablespace: |
4375 | 4375 |
-- |
4376 | 4376 |
|
4377 |
CREATE UNIQUE INDEX plantconcept_unique_within_datasource_by_name ON plantconcept USING btree (datasource_id, (COALESCE(plantname_id, 2147483647)), (COALESCE(scientificname, '\\N'::text)), (COALESCE(scientificnameauthor, '\\N'::text)), (COALESCE(scientificnamewithauthor, '\\N'::text)), (COALESCE(domain, '\\N'::text)), (COALESCE(kingdom, '\\N'::text)), (COALESCE(phylum, '\\N'::text)), (COALESCE(class, '\\N'::text)), (COALESCE("order", '\\N'::text)), (COALESCE(family, '\\N'::text)), (COALESCE(genus, '\\N'::text)), (COALESCE(species, '\\N'::text)), (COALESCE(subspecies, '\\N'::text)), (COALESCE(variety, '\\N'::text)), (COALESCE(forma, '\\N'::text)), (COALESCE(cultivar, '\\N'::text))) WHERE (plantcode IS NULL);
|
|
4377 |
CREATE UNIQUE INDEX plantconcept_unique_within_datasource_by_name ON plantconcept USING btree (datasource_id, (COALESCE(taxon_id, 2147483647)), (COALESCE(scientificname, '\\N'::text)), (COALESCE(scientificnameauthor, '\\N'::text)), (COALESCE(scientificnamewithauthor, '\\N'::text)), (COALESCE(domain, '\\N'::text)), (COALESCE(kingdom, '\\N'::text)), (COALESCE(phylum, '\\N'::text)), (COALESCE(class, '\\N'::text)), (COALESCE("order", '\\N'::text)), (COALESCE(family, '\\N'::text)), (COALESCE(genus, '\\N'::text)), (COALESCE(species, '\\N'::text)), (COALESCE(subspecies, '\\N'::text)), (COALESCE(variety, '\\N'::text)), (COALESCE(forma, '\\N'::text)), (COALESCE(cultivar, '\\N'::text))) WHERE (plantcode IS NULL);
|
|
4378 | 4378 |
|
4379 | 4379 |
|
4380 | 4380 |
-- |
4381 |
-- Name: plantname_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: |
|
4382 |
-- |
|
4383 |
|
|
4384 |
CREATE UNIQUE INDEX plantname_unique ON plantname USING btree ((COALESCE(parent_id, 2147483647)), taxonname, rank, (COALESCE(scope_id, 2147483647)), (COALESCE(authority, '\\N'::text))); |
|
4385 |
|
|
4386 |
|
|
4387 |
-- |
|
4388 |
-- Name: plantnamescope_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: |
|
4389 |
-- |
|
4390 |
|
|
4391 |
CREATE UNIQUE INDEX plantnamescope_unique ON plantnamescope USING btree ((COALESCE(locationevent_id, 2147483647)), (COALESCE(project_id, 2147483647)), (COALESCE(namedplace_id, 2147483647))); |
|
4392 |
|
|
4393 |
|
|
4394 |
-- |
|
4395 | 4381 |
-- Name: plantobservation_aggregateoccurrence_1_to_1; Type: INDEX; Schema: public; Owner: -; Tablespace: |
4396 | 4382 |
-- |
4397 | 4383 |
|
... | ... | |
4504 | 4490 |
|
4505 | 4491 |
|
4506 | 4492 |
-- |
4493 |
-- Name: taxon_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: |
|
4494 |
-- |
|
4495 |
|
|
4496 |
CREATE UNIQUE INDEX taxon_unique ON taxon USING btree ((COALESCE(parent_id, 2147483647)), taxonname, rank, (COALESCE(scope_id, 2147483647)), (COALESCE(authority, '\\N'::text))); |
|
4497 |
|
|
4498 |
|
|
4499 |
-- |
|
4507 | 4500 |
-- Name: taxondetermination_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: |
4508 | 4501 |
-- |
4509 | 4502 |
|
... | ... | |
4539 | 4532 |
|
4540 | 4533 |
|
4541 | 4534 |
-- |
4535 |
-- Name: taxonscope_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: |
|
4536 |
-- |
|
4537 |
|
|
4538 |
CREATE UNIQUE INDEX taxonscope_unique ON taxonscope USING btree ((COALESCE(locationevent_id, 2147483647)), (COALESCE(project_id, 2147483647)), (COALESCE(namedplace_id, 2147483647))); |
|
4539 |
|
|
4540 |
|
|
4541 |
-- |
|
4542 | 4542 |
-- Name: userdefined_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: |
4543 | 4543 |
-- |
4544 | 4544 |
|
... | ... | |
4553 | 4553 |
|
4554 | 4554 |
|
4555 | 4555 |
-- |
4556 |
-- Name: plantname_update_ancestors; Type: TRIGGER; Schema: public; Owner: -
|
|
4556 |
-- Name: plantobservation_aggregateoccurrence_count_1; Type: TRIGGER; Schema: public; Owner: -
|
|
4557 | 4557 |
-- |
4558 | 4558 |
|
4559 |
CREATE TRIGGER plantname_update_ancestors AFTER INSERT OR UPDATE ON plantname FOR EACH ROW EXECUTE PROCEDURE plantname_update_ancestors();
|
|
4559 |
CREATE TRIGGER plantobservation_aggregateoccurrence_count_1 AFTER INSERT OR UPDATE ON plantobservation FOR EACH ROW EXECUTE PROCEDURE plantobservation_aggregateoccurrence_count_1();
|
|
4560 | 4560 |
|
4561 | 4561 |
|
4562 | 4562 |
-- |
4563 |
-- Name: plantobservation_aggregateoccurrence_count_1; Type: TRIGGER; Schema: public; Owner: -
|
|
4563 |
-- Name: taxon_update_ancestors; Type: TRIGGER; Schema: public; Owner: -
|
|
4564 | 4564 |
-- |
4565 | 4565 |
|
4566 |
CREATE TRIGGER plantobservation_aggregateoccurrence_count_1 AFTER INSERT OR UPDATE ON plantobservation FOR EACH ROW EXECUTE PROCEDURE plantobservation_aggregateoccurrence_count_1();
|
|
4566 |
CREATE TRIGGER taxon_update_ancestors AFTER INSERT OR UPDATE ON taxon FOR EACH ROW EXECUTE PROCEDURE taxon_update_ancestors();
|
|
4567 | 4567 |
|
4568 | 4568 |
|
4569 | 4569 |
-- |
... | ... | |
5111 | 5111 |
|
5112 | 5112 |
|
5113 | 5113 |
-- |
5114 |
-- Name: plantconcept_plantname_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
5114 |
-- Name: plantconcept_taxon_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
5115 | 5115 |
-- |
5116 | 5116 |
|
5117 | 5117 |
ALTER TABLE ONLY plantconcept |
5118 |
ADD CONSTRAINT plantconcept_plantname_id_fkey FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
5118 |
ADD CONSTRAINT plantconcept_taxon_id_fkey FOREIGN KEY (taxon_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
5119 | 5119 |
|
5120 | 5120 |
|
5121 | 5121 |
-- |
... | ... | |
5151 | 5151 |
|
5152 | 5152 |
|
5153 | 5153 |
-- |
5154 |
-- Name: plantname_ancestor_ancestor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5155 |
-- |
|
5156 |
|
|
5157 |
ALTER TABLE ONLY plantname_ancestor |
|
5158 |
ADD CONSTRAINT plantname_ancestor_ancestor_id_fkey FOREIGN KEY (ancestor_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5159 |
|
|
5160 |
|
|
5161 |
-- |
|
5162 |
-- Name: plantname_ancestor_plantname_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5163 |
-- |
|
5164 |
|
|
5165 |
ALTER TABLE ONLY plantname_ancestor |
|
5166 |
ADD CONSTRAINT plantname_ancestor_plantname_id_fkey FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5167 |
|
|
5168 |
|
|
5169 |
-- |
|
5170 |
-- Name: plantname_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5171 |
-- |
|
5172 |
|
|
5173 |
ALTER TABLE ONLY plantname |
|
5174 |
ADD CONSTRAINT plantname_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5175 |
|
|
5176 |
|
|
5177 |
-- |
|
5178 |
-- Name: plantname_scope_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5179 |
-- |
|
5180 |
|
|
5181 |
ALTER TABLE ONLY plantname |
|
5182 |
ADD CONSTRAINT plantname_scope_id_fkey FOREIGN KEY (scope_id) REFERENCES plantnamescope(plantnamescope_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5183 |
|
|
5184 |
|
|
5185 |
-- |
|
5186 |
-- Name: plantnamescope_locationevent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5187 |
-- |
|
5188 |
|
|
5189 |
ALTER TABLE ONLY plantnamescope |
|
5190 |
ADD CONSTRAINT plantnamescope_locationevent_id_fkey FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5191 |
|
|
5192 |
|
|
5193 |
-- |
|
5194 |
-- Name: plantnamescope_namedplace_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5195 |
-- |
|
5196 |
|
|
5197 |
ALTER TABLE ONLY plantnamescope |
|
5198 |
ADD CONSTRAINT plantnamescope_namedplace_id_fkey FOREIGN KEY (namedplace_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5199 |
|
|
5200 |
|
|
5201 |
-- |
|
5202 |
-- Name: plantnamescope_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5203 |
-- |
|
5204 |
|
|
5205 |
ALTER TABLE ONLY plantnamescope |
|
5206 |
ADD CONSTRAINT plantnamescope_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(project_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5207 |
|
|
5208 |
|
|
5209 |
-- |
|
5210 | 5154 |
-- Name: plantobservation_aggregateoccurrence_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
5211 | 5155 |
-- |
5212 | 5156 |
|
... | ... | |
5271 | 5215 |
|
5272 | 5216 |
|
5273 | 5217 |
-- |
5274 |
-- Name: plantusage_plantname_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
5218 |
-- Name: plantusage_plantstatus_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
5275 | 5219 |
-- |
5276 | 5220 |
|
5277 | 5221 |
ALTER TABLE ONLY plantusage |
5278 |
ADD CONSTRAINT plantusage_plantname_id_fkey FOREIGN KEY (plantname_id) REFERENCES plantname(plantname_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
5222 |
ADD CONSTRAINT plantusage_plantstatus_id_fkey FOREIGN KEY (plantstatus_id) REFERENCES plantstatus(plantstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
5279 | 5223 |
|
5280 | 5224 |
|
5281 | 5225 |
-- |
5282 |
-- Name: plantusage_plantstatus_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
5226 |
-- Name: plantusage_taxon_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
5283 | 5227 |
-- |
5284 | 5228 |
|
5285 | 5229 |
ALTER TABLE ONLY plantusage |
5286 |
ADD CONSTRAINT plantusage_plantstatus_id_fkey FOREIGN KEY (plantstatus_id) REFERENCES plantstatus(plantstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
5230 |
ADD CONSTRAINT plantusage_taxon_id_fkey FOREIGN KEY (taxon_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE;
|
|
5287 | 5231 |
|
5288 | 5232 |
|
5289 | 5233 |
-- |
... | ... | |
5447 | 5391 |
|
5448 | 5392 |
|
5449 | 5393 |
-- |
5394 |
-- Name: taxon_ancestor_ancestor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5395 |
-- |
|
5396 |
|
|
5397 |
ALTER TABLE ONLY taxon_ancestor |
|
5398 |
ADD CONSTRAINT taxon_ancestor_ancestor_id_fkey FOREIGN KEY (ancestor_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5399 |
|
|
5400 |
|
|
5401 |
-- |
|
5402 |
-- Name: taxon_ancestor_taxon_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5403 |
-- |
|
5404 |
|
|
5405 |
ALTER TABLE ONLY taxon_ancestor |
|
5406 |
ADD CONSTRAINT taxon_ancestor_taxon_id_fkey FOREIGN KEY (taxon_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5407 |
|
|
5408 |
|
|
5409 |
-- |
|
5410 |
-- Name: taxon_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5411 |
-- |
|
5412 |
|
|
5413 |
ALTER TABLE ONLY taxon |
|
5414 |
ADD CONSTRAINT taxon_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES taxon(taxon_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5415 |
|
|
5416 |
|
|
5417 |
-- |
|
5418 |
-- Name: taxon_scope_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5419 |
-- |
|
5420 |
|
|
5421 |
ALTER TABLE ONLY taxon |
|
5422 |
ADD CONSTRAINT taxon_scope_id_fkey FOREIGN KEY (scope_id) REFERENCES taxonscope(taxonscope_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5423 |
|
|
5424 |
|
|
5425 |
-- |
|
5450 | 5426 |
-- Name: taxonalt_plantconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
5451 | 5427 |
-- |
5452 | 5428 |
|
... | ... | |
5511 | 5487 |
|
5512 | 5488 |
|
5513 | 5489 |
-- |
5490 |
-- Name: taxonscope_locationevent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5491 |
-- |
|
5492 |
|
|
5493 |
ALTER TABLE ONLY taxonscope |
|
5494 |
ADD CONSTRAINT taxonscope_locationevent_id_fkey FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5495 |
|
|
5496 |
|
|
5497 |
-- |
|
5498 |
-- Name: taxonscope_namedplace_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5499 |
-- |
|
5500 |
|
|
5501 |
ALTER TABLE ONLY taxonscope |
|
5502 |
ADD CONSTRAINT taxonscope_namedplace_id_fkey FOREIGN KEY (namedplace_id) REFERENCES namedplace(namedplace_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5503 |
|
|
5504 |
|
|
5505 |
-- |
|
5506 |
-- Name: taxonscope_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
|
5507 |
-- |
|
5508 |
|
|
5509 |
ALTER TABLE ONLY taxonscope |
|
5510 |
ADD CONSTRAINT taxonscope_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(project_id) ON UPDATE CASCADE ON DELETE CASCADE; |
|
5511 |
|
|
5512 |
|
|
5513 |
-- |
|
5514 | 5514 |
-- Name: telephone_party_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: - |
5515 | 5515 |
-- |
5516 | 5516 |
|
Also available in: Unified diff
schemas/vegbien.sql: Renamed plantname to taxon for consistency with DwC's Taxon category