Project

General

Profile

« Previous | Next » 

Revision 9493

inputs/.TNRS/schema.sql, data.sql: updated for new TNRS CSV columns (see bug at https://pods.iplantcollaborative.org/jira/browse/TNRS-183). note that these columns may eventually change back (comment by Naim at https://pods.iplantcollaborative.org/jira/browse/TNRS-183#comment-34444).

View differences:

inputs/test_taxonomic_names/_scrub/TNRS.sql
4 4

  
5 5
SET statement_timeout = 0;
6 6
SET client_encoding = 'UTF8';
7
SET standard_conforming_strings = off;
7
SET standard_conforming_strings = on;
8 8
SET check_function_bodies = false;
9 9
SET client_min_messages = warning;
10
SET escape_string_warning = off;
11 10

  
12 11
--
13 12
-- Name: TNRS; Type: SCHEMA; Schema: -; Owner: bien
......
21 20
SET search_path = "TNRS", pg_catalog;
22 21

  
23 22
--
24
-- Name: array_to_string(anyarray, text); Type: FUNCTION; Schema: TNRS; Owner: bien
23
-- Name: score_ok(double precision); Type: FUNCTION; Schema: TNRS; Owner: bien
25 24
--
26 25

  
27
CREATE FUNCTION array_to_string(anyarray, text) RETURNS text
28
    LANGUAGE sql IMMUTABLE STRICT
26
CREATE FUNCTION score_ok(score double precision) RETURNS boolean
27
    LANGUAGE sql
29 28
    AS $_$
30
SELECT pg_catalog.array_to_string($1, $2)
29
SELECT $1 >= 0.8
31 30
$_$;
32 31

  
33 32

  
34
ALTER FUNCTION "TNRS".array_to_string(anyarray, text) OWNER TO bien;
33
ALTER FUNCTION "TNRS".score_ok(score double precision) OWNER TO bien;
35 34

  
35
--
36
-- Name: tnrs_populate_derived_fields(); Type: FUNCTION; Schema: TNRS; Owner: bien
37
--
38

  
39
CREATE FUNCTION tnrs_populate_derived_fields() RETURNS trigger
40
    LANGUAGE plpgsql
41
    AS $$
42
BEGIN
43
    new."Accepted_scientific_name" = NULLIF(concat_ws(' '
44
        , NULLIF(NULLIF(new."Accepted_family", 'Unknown'), new."Accepted_name")
45
        , new."Accepted_name"
46
        , new."Accepted_name_author"
47
    ), '');
48
    new."Max_score" = GREATEST(
49
          new."Overall_score"::double precision
50
        , new."Family_score"::double precision
51
        , new."Genus_score"::double precision
52
        , new."Specific_epithet_score"::double precision
53
    );
54
    
55
    RETURN new;
56
END;
57
$$;
58

  
59

  
60
ALTER FUNCTION "TNRS".tnrs_populate_derived_fields() OWNER TO bien;
61

  
36 62
SET default_tablespace = '';
37 63

  
38 64
SET default_with_oids = false;
......
55 81
    "Author_score" text,
56 82
    "Family_matched" text,
57 83
    "Family_score" text,
58
    "Name_matched_accepted_family" text,
59 84
    "Genus_matched" text,
60 85
    "Genus_score" text,
61 86
    "Specific_epithet_matched" text,
......
73 98
    "Accepted_name_author" text,
74 99
    "Accepted_name_rank" text,
75 100
    "Accepted_name_url" text,
76
    "Accepted_name_species" text,
77
    "Accepted_name_family" text,
101
    "Accepted_species" text,
102
    "Accepted_family" text,
78 103
    "Selected" text,
79 104
    "Source" text,
80 105
    "Warnings" text,
81
    "Accepted_name_lsid" text
106
    "Accepted_name_lsid" text,
107
    "Accepted_scientific_name" text,
108
    "Max_score" double precision
82 109
);
83 110

  
84 111

  
85 112
ALTER TABLE "TNRS".tnrs OWNER TO bien;
86 113

  
87 114
--
88
-- Name: tnrs_accepted; Type: TABLE; Schema: TNRS; Owner: bien; Tablespace: 
115
-- Name: AcceptedTaxon; Type: VIEW; Schema: TNRS; Owner: bien
89 116
--
90 117

  
91
CREATE TABLE tnrs_accepted (
92
    "Time_submitted" timestamp with time zone,
93
    "Name_number" text,
94
    "Name_submitted" text NOT NULL,
95
    "Overall_score" text,
96
    "Name_matched" text,
97
    "Name_matched_rank" text,
98
    "Name_score" text,
99
    "Name_matched_author" text,
100
    "Name_matched_url" text,
101
    "Author_matched" text,
102
    "Author_score" text,
103
    "Family_matched" text,
104
    "Family_score" text,
105
    "Name_matched_accepted_family" text,
106
    "Genus_matched" text,
107
    "Genus_score" text,
108
    "Specific_epithet_matched" text,
109
    "Specific_epithet_score" text,
110
    "Infraspecific_rank" text,
111
    "Infraspecific_epithet_matched" text,
112
    "Infraspecific_epithet_score" text,
113
    "Infraspecific_rank_2" text,
114
    "Infraspecific_epithet_2_matched" text,
115
    "Infraspecific_epithet_2_score" text,
116
    "Annotations" text,
117
    "Unmatched_terms" text,
118
    "Taxonomic_status" text,
119
    "Accepted_name" text,
120
    "Accepted_name_author" text,
121
    "Accepted_name_rank" text,
122
    "Accepted_name_url" text,
123
    "Accepted_name_species" text,
124
    "Accepted_name_family" text,
125
    "Selected" text,
126
    "Source" text,
127
    "Warnings" text,
128
    "Accepted_name_lsid" text
129
);
118
CREATE VIEW "AcceptedTaxon" AS
119
    SELECT tnrs."Time_submitted" AS "*Accepted_name.Time_submitted", tnrs."Name_submitted" AS "acceptedScientificName", tnrs."Genus_matched" AS "acceptedGenus", tnrs."Specific_epithet_matched" AS "acceptedSpecificEpithet", tnrs."Infraspecific_epithet_matched" AS "acceptedInfraspecificEpithet", tnrs."Annotations" AS "*Accepted_name.Annotations", tnrs."Taxonomic_status" AS "acceptedTaxonomicStatus", tnrs."Selected" AS "*Accepted_name.Selected", tnrs."Source" AS "*Accepted_name.Source", tnrs."Warnings" AS "*Accepted_name.Warnings", tnrs."Accepted_name_lsid" AS "*Accepted_name.Accepted_name_lsid" FROM tnrs;
130 120

  
131 121

  
132
ALTER TABLE "TNRS".tnrs_accepted OWNER TO bien;
122
ALTER TABLE "TNRS"."AcceptedTaxon" OWNER TO bien;
133 123

  
134 124
--
135
-- Name: tnrs_other; Type: TABLE; Schema: TNRS; Owner: bien; Tablespace: 
125
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: bien
136 126
--
137 127

  
138
CREATE TABLE tnrs_other (
139
    "Time_submitted" timestamp with time zone,
140
    "Name_number" text,
141
    "Name_submitted" text NOT NULL,
142
    "Overall_score" text,
143
    "Name_matched" text,
144
    "Name_matched_rank" text,
145
    "Name_score" text,
146
    "Name_matched_author" text,
147
    "Name_matched_url" text,
148
    "Author_matched" text,
149
    "Author_score" text,
150
    "Family_matched" text,
151
    "Family_score" text,
152
    "Name_matched_accepted_family" text,
153
    "Genus_matched" text,
154
    "Genus_score" text,
155
    "Specific_epithet_matched" text,
156
    "Specific_epithet_score" text,
157
    "Infraspecific_rank" text,
158
    "Infraspecific_epithet_matched" text,
159
    "Infraspecific_epithet_score" text,
160
    "Infraspecific_rank_2" text,
161
    "Infraspecific_epithet_2_matched" text,
162
    "Infraspecific_epithet_2_score" text,
163
    "Annotations" text,
164
    "Unmatched_terms" text,
165
    "Taxonomic_status" text,
166
    "Accepted_name" text,
167
    "Accepted_name_author" text,
168
    "Accepted_name_rank" text,
169
    "Accepted_name_url" text,
170
    "Accepted_name_species" text,
171
    "Accepted_name_family" text,
172
    "Selected" text,
173
    "Source" text,
174
    "Warnings" text,
175
    "Accepted_name_lsid" text
176
);
128
CREATE VIEW "MatchedTaxon" AS
129
    SELECT tnrs."Time_submitted" AS "*Name_matched.Time_submitted", tnrs."Name_submitted" AS "concatenatedScientificName", tnrs."Name_matched" AS "matchedTaxonName", tnrs."Name_matched_rank" AS "matchedTaxonRank", tnrs."Name_score" AS "*Name_matched.Name_score", tnrs."Name_matched_author" AS "matchedScientificNameAuthorship", tnrs."Name_matched_url" AS "matchedScientificNameID", tnrs."Author_score" AS "*Name_matched.Author_score", tnrs."Family_score" AS "matchedFamilyConfidence_fraction", tnrs."Genus_matched" AS "matchedGenus", tnrs."Genus_score" AS "matchedGenusConfidence_fraction", tnrs."Specific_epithet_matched" AS "matchedSpecificEpithet", tnrs."Specific_epithet_score" AS "matchedSpeciesConfidence_fraction", tnrs."Infraspecific_epithet_matched" AS "matchedInfraspecificEpithet", tnrs."Infraspecific_epithet_score" AS "*Name_matched.Infraspecific_epithet_score", tnrs."Annotations" AS "identificationQualifier", tnrs."Unmatched_terms" AS "morphospeciesSuffix", tnrs."Taxonomic_status" AS "taxonomicStatus", tnrs."Accepted_name" AS "acceptedTaxonName", tnrs."Accepted_name_author" AS "acceptedScientificNameAuthorship", tnrs."Accepted_name_rank" AS "acceptedTaxonRank", tnrs."Accepted_name_url" AS "acceptedScientificNameID", tnrs."Accepted_species" AS "*Name_matched.Accepted_species", tnrs."Accepted_family" AS "acceptedFamily", tnrs."Selected" AS "*Name_matched.Selected", tnrs."Source" AS "*Name_matched.Source", tnrs."Warnings" AS "*Name_matched.Warnings", tnrs."Accepted_name_lsid" AS "*Name_matched.Accepted_name_lsid", tnrs."Accepted_scientific_name" AS "acceptedScientificName", tnrs."Max_score" AS "matchedTaxonConfidence_fraction" FROM tnrs;
177 130

  
178 131

  
179
ALTER TABLE "TNRS".tnrs_other OWNER TO bien;
132
ALTER TABLE "TNRS"."MatchedTaxon" OWNER TO bien;
180 133

  
181 134
--
182
-- Data for Name: tnrs; Type: TABLE DATA; Schema: TNRS; Owner: bien
135
-- Name: ScrubbedTaxon; Type: VIEW; Schema: TNRS; Owner: bien
183 136
--
184 137

  
185
COPY tnrs ("Time_submitted", "Name_number", "Name_submitted", "Overall_score", "Name_matched", "Name_matched_rank", "Name_score", "Name_matched_author", "Name_matched_url", "Author_matched", "Author_score", "Family_matched", "Family_score", "Name_matched_accepted_family", "Genus_matched", "Genus_score", "Specific_epithet_matched", "Specific_epithet_score", "Infraspecific_rank", "Infraspecific_epithet_matched", "Infraspecific_epithet_score", "Infraspecific_rank_2", "Infraspecific_epithet_2_matched", "Infraspecific_epithet_2_score", "Annotations", "Unmatched_terms", "Taxonomic_status", "Accepted_name", "Accepted_name_author", "Accepted_name_rank", "Accepted_name_url", "Accepted_name_species", "Accepted_name_family", "Selected", "Source", "Warnings", "Accepted_name_lsid") FROM stdin;
186
2012-11-01 05:10:40.128415-07	0	Compositae indet. sp.1	0.9	Compositae	family	1	Giseke	http://www.tropicos.org/Name/50255940	\N	\N	Compositae	1	Compositae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	indet. sp.1	Synonym	Asteraceae	Bercht. & J. Presl	family	http://www.tropicos.org/Name/50307371	\N	Asteraceae	true	tropicos	 	\N
187
2012-11-01 05:10:40.128415-07	1	Fabaceae Boyle#6500	0.9	Fabaceae	family	1	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	Fabaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Boyle#6500	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	 	\N
188
2012-11-01 05:10:40.128415-07	2	Fabaceae Inga "fuzzy leaf"	0.9	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	\N	\N	Fabaceae	1	Fabaceae	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	"fuzzy leaf"	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	 	\N
189
2012-11-01 05:10:40.128415-07	3	Fabaceae Inga sp.3	0.9	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	\N	\N	Fabaceae	1	Fabaceae	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	sp.3	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	 	\N
190
2012-11-01 05:10:40.128415-07	4	Fabaceae unknown #2	0.9	Fabaceae	family	1	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	Fabaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	unknown #2	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	 	\N
191
2012-11-01 05:10:40.128415-07	5	Fam_indet. Boyle#6501	0	No suitable matches found.	\N	0	\N	\N	\N	0	\N	0	\N	\N	0	\N	0	\N	\N	0	\N	\N	0	\N	\N	\N	\N	\N	\N	\N	\N	\N	true	\N	 	\N
192
2012-11-01 05:10:40.128415-07	6	Poa annua	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	 	\N
193
2012-11-01 05:10:40.128415-07	7	Poa annua L.	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881	L.	1	\N	\N	Poaceae	Poa	1	annua	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	 	\N
194
2012-11-01 05:10:40.128415-07	8	Poa annua fo. lanuginosa	1	Poa annua fo. lanuginosa	forma	1	Sennen	http://www.tropicos.org/Name/50267771	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	fo.	lanuginosa	1	\N	\N	\N	\N	\N	Synonym	Poa annua var. annua	\N	variety	http://www.tropicos.org/Name/25517736	Poa annua	Poaceae	true	tropicos	 	\N
195
2012-11-01 05:10:40.128415-07	9	Poa annua ssp. exilis	0.4	Poa	genus	0.4	L.	http://www.tropicos.org/Name/40012319	\N	\N	\N	\N	Poaceae	Poa	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	annua ssp. exilis	Accepted	Poa	L.	genus	http://www.tropicos.org/Name/40012319	\N	Poaceae	true	tropicos	 [Partial match] 	\N
196
2012-11-01 05:10:40.128415-07	10	Poa annua subsp. exilis	1	Poa annua subsp. exilis	subspecies	1	(Tomm. ex Freyn) Asch. & Graebn.	http://www.tropicos.org/Name/50063800	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	subsp.	exilis	1	\N	\N	\N	\N	\N	Synonym	Poa infirma	Kunth	species	http://www.tropicos.org/Name/25514158	Poa infirma	Poaceae	true	tropicos	 	\N
197
2012-11-01 05:10:40.128415-07	11	Poa annua subvar. minima	1	Poa annua subvar. minima	subvariety	1	(Schur) Asch. & Graebn.	http://www.tropicos.org/Name/50158097	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	subvar.	minima	1	\N	\N	\N	\N	\N	Accepted	Poa annua subvar. minima	(Schur) Asch. & Graebn.	subvariety	http://www.tropicos.org/Name/50158097	Poa annua	Poaceae	true	tropicos	 	\N
198
2012-11-01 05:10:40.128415-07	12	Poa annua var. eriolepis	1	Poa annua var. eriolepis	variety	1	E. Desv.	http://www.tropicos.org/Name/50119145	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	var.	eriolepis	1	\N	\N	\N	\N	\N	Synonym	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	 	\N
199
2012-11-01 05:10:40.128415-07	13	Silene scouleri Hook. subsp. pringlei (S. Watson) C.L. Hitchc. & Maguire var. grisea C.L. Hitchc. & Maguire	0.77	Silene scouleri subsp. pringlei	subspecies	0.77	(S. Watson) C.L. Hitchc. & Maguire	http://www.tropicos.org/Name/6303627	\N	\N	\N	\N	Caryophyllaceae	Silene	1	scouleri	1	subsp.	pringlei	1	\N	\N	\N	\N	var. grisea	Accepted	Silene scouleri subsp. pringlei	(S. Watson) C.L. Hitchc. & Maguire	subspecies	http://www.tropicos.org/Name/6303627	Silene scouleri	Caryophyllaceae	true	tropicos	 [Partial match] 	\N
200
2012-11-01 05:10:40.128415-07	14	Silene scouleri subsp. pringlei var. grisea C.L. Hitchc. & Maguire	0.77	Silene scouleri subsp. pringlei	subspecies	0.77	(S. Watson) C.L. Hitchc. & Maguire	http://www.tropicos.org/Name/6303627	\N	\N	\N	\N	Caryophyllaceae	Silene	1	scouleri	1	subsp.	pringlei	1	\N	\N	\N	\N	var. grisea	Accepted	Silene scouleri subsp. pringlei	(S. Watson) C.L. Hitchc. & Maguire	subspecies	http://www.tropicos.org/Name/6303627	Silene scouleri	Caryophyllaceae	true	tropicos	 [Partial match] 	\N
201
2012-11-01 05:10:55.49172-07	0	Asteraceae Asteraceae Bercht. & J. Presl	0.4	Asteraceae	family	0.5	Bercht. & J. Presl	http://www.tropicos.org/Name/50307371	\N	\N	Asteraceae	1	Asteraceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Asteraceae Bercht. & J. Presl	Accepted	Asteraceae	Bercht. & J. Presl	family	http://www.tropicos.org/Name/50307371	\N	Asteraceae	true	tropicos	 [Partial match] 	\N
202
2012-11-01 05:10:55.49172-07	1	Caryophyllaceae	1	Caryophyllaceae	family	1	Juss.	http://www.tropicos.org/Name/42000077	\N	\N	Caryophyllaceae	1	Caryophyllaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Caryophyllaceae	Juss.	family	http://www.tropicos.org/Name/42000077	\N	Caryophyllaceae	true	tropicos	 	\N
203
2012-11-01 05:10:55.49172-07	2	Compositae	1	Compositae	family	1	Giseke	http://www.tropicos.org/Name/50255940	\N	\N	Compositae	1	Compositae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Synonym	Asteraceae	Bercht. & J. Presl	family	http://www.tropicos.org/Name/50307371	\N	Asteraceae	true	tropicos	 	\N
204
2012-11-01 05:10:55.49172-07	3	Fabaceae	1	Fabaceae	family	1	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	Fabaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	 	\N
205
2012-11-01 05:10:55.49172-07	4	Inga	1	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	\N	\N	\N	\N	Fabaceae	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	 	\N
206
2012-11-01 05:10:55.49172-07	5	Poa	1	Poa	genus	1	L.	http://www.tropicos.org/Name/40012319	\N	\N	\N	\N	Poaceae	Poa	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa	L.	genus	http://www.tropicos.org/Name/40012319	\N	Poaceae	true	tropicos	 	\N
207
2012-11-01 05:10:55.49172-07	6	Poaceae	1	Poaceae	family	1	Barnhart	http://www.tropicos.org/Name/42000357	\N	\N	Poaceae	1	Poaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poaceae	Barnhart	family	http://www.tropicos.org/Name/42000357	\N	Poaceae	true	tropicos	 	\N
208
2012-11-01 05:10:55.49172-07	7	Poaceae Poa annua var. annua	1	Poa annua var. annua	variety	1	\N	http://www.tropicos.org/Name/25517736	\N	\N	Poaceae	1	Poaceae	Poa	1	annua	1	var.	annua	1	\N	\N	\N	\N	\N	Accepted	Poa annua var. annua	\N	variety	http://www.tropicos.org/Name/25517736	Poa annua	Poaceae	true	tropicos	 	\N
209
2012-11-01 05:10:55.49172-07	8	Poaceae Poa infirma Kunth	1	Poa infirma	species	1	Kunth	http://www.tropicos.org/Name/25514158	Kunth	1	Poaceae	1	Poaceae	Poa	1	infirma	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa infirma	Kunth	species	http://www.tropicos.org/Name/25514158	Poa infirma	Poaceae	true	tropicos	 	\N
210
2012-11-01 05:10:55.49172-07	9	Silene	1	Silene	genus	1	L.	http://www.tropicos.org/Name/40000236	\N	\N	\N	\N	Caryophyllaceae	Silene	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Silene	L.	genus	http://www.tropicos.org/Name/40000236	\N	Caryophyllaceae	true	tropicos	 	\N
211
\.
138
CREATE VIEW "ScrubbedTaxon" AS
139
    SELECT "MatchedTaxon"."acceptedScientificName", "MatchedTaxon"."*Name_matched.Time_submitted", "MatchedTaxon"."concatenatedScientificName", "MatchedTaxon"."matchedTaxonName", "MatchedTaxon"."matchedTaxonRank", "MatchedTaxon"."*Name_matched.Name_score", "MatchedTaxon"."matchedScientificNameAuthorship", "MatchedTaxon"."matchedScientificNameID", "MatchedTaxon"."*Name_matched.Author_score", "MatchedTaxon"."matchedFamilyConfidence_fraction", "MatchedTaxon"."matchedGenus", "MatchedTaxon"."matchedGenusConfidence_fraction", "MatchedTaxon"."matchedSpecificEpithet", "MatchedTaxon"."matchedSpeciesConfidence_fraction", "MatchedTaxon"."matchedInfraspecificEpithet", "MatchedTaxon"."*Name_matched.Infraspecific_epithet_score", "MatchedTaxon"."identificationQualifier", "MatchedTaxon"."morphospeciesSuffix", "MatchedTaxon"."taxonomicStatus", "MatchedTaxon"."acceptedTaxonName", "MatchedTaxon"."acceptedScientificNameAuthorship", "MatchedTaxon"."acceptedTaxonRank", "MatchedTaxon"."acceptedScientificNameID", "MatchedTaxon"."*Name_matched.Accepted_species", "MatchedTaxon"."acceptedFamily", "MatchedTaxon"."*Name_matched.Selected", "MatchedTaxon"."*Name_matched.Source", "MatchedTaxon"."*Name_matched.Warnings", "MatchedTaxon"."*Name_matched.Accepted_name_lsid", "MatchedTaxon"."matchedTaxonConfidence_fraction", "AcceptedTaxon"."*Accepted_name.Time_submitted", "AcceptedTaxon"."acceptedGenus", "AcceptedTaxon"."acceptedSpecificEpithet", "AcceptedTaxon"."acceptedInfraspecificEpithet", "AcceptedTaxon"."*Accepted_name.Annotations", "AcceptedTaxon"."acceptedTaxonomicStatus", "AcceptedTaxon"."*Accepted_name.Selected", "AcceptedTaxon"."*Accepted_name.Source", "AcceptedTaxon"."*Accepted_name.Warnings", "AcceptedTaxon"."*Accepted_name.Accepted_name_lsid" FROM ("MatchedTaxon" NATURAL LEFT JOIN "AcceptedTaxon") WHERE score_ok("MatchedTaxon"."matchedTaxonConfidence_fraction");
212 140

  
213 141

  
214
--
215
-- Data for Name: tnrs_accepted; Type: TABLE DATA; Schema: TNRS; Owner: bien
216
--
142
ALTER TABLE "TNRS"."ScrubbedTaxon" OWNER TO bien;
217 143

  
218
COPY tnrs_accepted ("Time_submitted", "Name_number", "Name_submitted", "Overall_score", "Name_matched", "Name_matched_rank", "Name_score", "Name_matched_author", "Name_matched_url", "Author_matched", "Author_score", "Family_matched", "Family_score", "Name_matched_accepted_family", "Genus_matched", "Genus_score", "Specific_epithet_matched", "Specific_epithet_score", "Infraspecific_rank", "Infraspecific_epithet_matched", "Infraspecific_epithet_score", "Infraspecific_rank_2", "Infraspecific_epithet_2_matched", "Infraspecific_epithet_2_score", "Annotations", "Unmatched_terms", "Taxonomic_status", "Accepted_name", "Accepted_name_author", "Accepted_name_rank", "Accepted_name_url", "Accepted_name_species", "Accepted_name_family", "Selected", "Source", "Warnings", "Accepted_name_lsid") FROM stdin;
219
2012-11-01 05:10:55.49172-07	0	Asteraceae Asteraceae Bercht. & J. Presl	0.4	Asteraceae	family	0.5	Bercht. & J. Presl	http://www.tropicos.org/Name/50307371	\N	\N	Asteraceae	1	Asteraceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Asteraceae Bercht. & J. Presl	Accepted	Asteraceae	Bercht. & J. Presl	family	http://www.tropicos.org/Name/50307371	\N	Asteraceae	true	tropicos	[Partial match]	\N
220
2012-11-01 05:10:55.49172-07	7	Poaceae Poa annua var. annua	1	Poa annua var. annua	variety	1	\N	http://www.tropicos.org/Name/25517736	\N	\N	Poaceae	1	Poaceae	Poa	1	annua	1	var.	annua	1	\N	\N	\N	\N	\N	Accepted	Poa annua var. annua	\N	variety	http://www.tropicos.org/Name/25517736	Poa annua	Poaceae	true	tropicos	\N	\N
221
2012-11-01 05:10:55.49172-07	8	Poaceae Poa infirma Kunth	1	Poa infirma	species	1	Kunth	http://www.tropicos.org/Name/25514158	Kunth	1	Poaceae	1	Poaceae	Poa	1	infirma	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa infirma	Kunth	species	http://www.tropicos.org/Name/25514158	Poa infirma	Poaceae	true	tropicos	\N	\N
222
\.
223

  
224

  
225 144
--
226
-- Data for Name: tnrs_other; Type: TABLE DATA; Schema: TNRS; Owner: bien
145
-- Data for Name: tnrs; Type: TABLE DATA; Schema: TNRS; Owner: bien
227 146
--
228 147

  
229
COPY tnrs_other ("Time_submitted", "Name_number", "Name_submitted", "Overall_score", "Name_matched", "Name_matched_rank", "Name_score", "Name_matched_author", "Name_matched_url", "Author_matched", "Author_score", "Family_matched", "Family_score", "Name_matched_accepted_family", "Genus_matched", "Genus_score", "Specific_epithet_matched", "Specific_epithet_score", "Infraspecific_rank", "Infraspecific_epithet_matched", "Infraspecific_epithet_score", "Infraspecific_rank_2", "Infraspecific_epithet_2_matched", "Infraspecific_epithet_2_score", "Annotations", "Unmatched_terms", "Taxonomic_status", "Accepted_name", "Accepted_name_author", "Accepted_name_rank", "Accepted_name_url", "Accepted_name_species", "Accepted_name_family", "Selected", "Source", "Warnings", "Accepted_name_lsid") FROM stdin;
230
2012-11-01 05:10:55.49172-07	1	Caryophyllaceae	1	Caryophyllaceae	family	1	Juss.	http://www.tropicos.org/Name/42000077	\N	\N	Caryophyllaceae	1	Caryophyllaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Caryophyllaceae	Juss.	family	http://www.tropicos.org/Name/42000077	\N	Caryophyllaceae	true	tropicos	\N	\N
231
2012-11-01 05:10:55.49172-07	2	Compositae	1	Compositae	family	1	Giseke	http://www.tropicos.org/Name/50255940	\N	\N	Compositae	1	Compositae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Synonym	Asteraceae	Bercht. & J. Presl	family	http://www.tropicos.org/Name/50307371	\N	Asteraceae	true	tropicos	\N	\N
232
2012-11-01 05:10:40.128415-07	0	Compositae indet. sp.1	0.9	Compositae	family	1	Giseke	http://www.tropicos.org/Name/50255940	\N	\N	Compositae	1	Compositae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	indet. sp.1	Synonym	Asteraceae	Bercht. & J. Presl	family	http://www.tropicos.org/Name/50307371	\N	Asteraceae	true	tropicos	\N	\N
233
2012-11-01 05:10:55.49172-07	3	Fabaceae	1	Fabaceae	family	1	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	Fabaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	\N	\N
234
2012-11-01 05:10:40.128415-07	1	Fabaceae Boyle#6500	0.9	Fabaceae	family	1	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	Fabaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Boyle#6500	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	\N	\N
235
2012-11-01 05:10:40.128415-07	2	Fabaceae Inga "fuzzy leaf"	0.9	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	\N	\N	Fabaceae	1	Fabaceae	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	"fuzzy leaf"	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	\N	\N
236
2012-11-01 05:10:40.128415-07	3	Fabaceae Inga sp.3	0.9	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	\N	\N	Fabaceae	1	Fabaceae	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	sp.3	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	\N	\N
237
2012-11-01 05:10:40.128415-07	4	Fabaceae unknown #2	0.9	Fabaceae	family	1	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	Fabaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	unknown #2	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	\N	\N
238
2012-11-01 05:10:55.49172-07	4	Inga	1	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	\N	\N	\N	\N	Fabaceae	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	\N	\N
239
2012-11-01 05:10:55.49172-07	5	Poa	1	Poa	genus	1	L.	http://www.tropicos.org/Name/40012319	\N	\N	\N	\N	Poaceae	Poa	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa	L.	genus	http://www.tropicos.org/Name/40012319	\N	Poaceae	true	tropicos	\N	\N
240
2012-11-01 05:10:40.128415-07	6	Poa annua	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	\N	\N
241
2012-11-01 05:10:40.128415-07	7	Poa annua L.	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881	L.	1	\N	\N	Poaceae	Poa	1	annua	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	\N	\N
242
2012-11-01 05:10:40.128415-07	8	Poa annua fo. lanuginosa	1	Poa annua fo. lanuginosa	forma	1	Sennen	http://www.tropicos.org/Name/50267771	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	fo.	lanuginosa	1	\N	\N	\N	\N	\N	Synonym	Poa annua var. annua	\N	variety	http://www.tropicos.org/Name/25517736	Poa annua	Poaceae	true	tropicos	\N	\N
243
2012-11-01 05:10:40.128415-07	9	Poa annua ssp. exilis	0.4	Poa	genus	0.4	L.	http://www.tropicos.org/Name/40012319	\N	\N	\N	\N	Poaceae	Poa	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	annua ssp. exilis	Accepted	Poa	L.	genus	http://www.tropicos.org/Name/40012319	\N	Poaceae	true	tropicos	[Partial match]	\N
244
2012-11-01 05:10:40.128415-07	10	Poa annua subsp. exilis	1	Poa annua subsp. exilis	subspecies	1	(Tomm. ex Freyn) Asch. & Graebn.	http://www.tropicos.org/Name/50063800	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	subsp.	exilis	1	\N	\N	\N	\N	\N	Synonym	Poa infirma	Kunth	species	http://www.tropicos.org/Name/25514158	Poa infirma	Poaceae	true	tropicos	\N	\N
245
2012-11-01 05:10:40.128415-07	11	Poa annua subvar. minima	1	Poa annua subvar. minima	subvariety	1	(Schur) Asch. & Graebn.	http://www.tropicos.org/Name/50158097	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	subvar.	minima	1	\N	\N	\N	\N	\N	Accepted	Poa annua subvar. minima	(Schur) Asch. & Graebn.	subvariety	http://www.tropicos.org/Name/50158097	Poa annua	Poaceae	true	tropicos	\N	\N
246
2012-11-01 05:10:40.128415-07	12	Poa annua var. eriolepis	1	Poa annua var. eriolepis	variety	1	E. Desv.	http://www.tropicos.org/Name/50119145	\N	\N	\N	\N	Poaceae	Poa	1	annua	1	var.	eriolepis	1	\N	\N	\N	\N	\N	Synonym	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	\N	\N
247
2012-11-01 05:10:55.49172-07	6	Poaceae	1	Poaceae	family	1	Barnhart	http://www.tropicos.org/Name/42000357	\N	\N	Poaceae	1	Poaceae	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poaceae	Barnhart	family	http://www.tropicos.org/Name/42000357	\N	Poaceae	true	tropicos	\N	\N
248
2012-11-01 05:10:55.49172-07	9	Silene	1	Silene	genus	1	L.	http://www.tropicos.org/Name/40000236	\N	\N	\N	\N	Caryophyllaceae	Silene	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Silene	L.	genus	http://www.tropicos.org/Name/40000236	\N	Caryophyllaceae	true	tropicos	\N	\N
249
2012-11-01 05:10:40.128415-07	13	Silene scouleri Hook. subsp. pringlei (S. Watson) C.L. Hitchc. & Maguire var. grisea C.L. Hitchc. & Maguire	0.77	Silene scouleri subsp. pringlei	subspecies	0.77	(S. Watson) C.L. Hitchc. & Maguire	http://www.tropicos.org/Name/6303627	\N	\N	\N	\N	Caryophyllaceae	Silene	1	scouleri	1	subsp.	pringlei	1	\N	\N	\N	\N	var. grisea	Accepted	Silene scouleri subsp. pringlei	(S. Watson) C.L. Hitchc. & Maguire	subspecies	http://www.tropicos.org/Name/6303627	Silene scouleri	Caryophyllaceae	true	tropicos	[Partial match]	\N
250
2012-11-01 05:10:40.128415-07	14	Silene scouleri subsp. pringlei var. grisea C.L. Hitchc. & Maguire	0.77	Silene scouleri subsp. pringlei	subspecies	0.77	(S. Watson) C.L. Hitchc. & Maguire	http://www.tropicos.org/Name/6303627	\N	\N	\N	\N	Caryophyllaceae	Silene	1	scouleri	1	subsp.	pringlei	1	\N	\N	\N	\N	var. grisea	Accepted	Silene scouleri subsp. pringlei	(S. Watson) C.L. Hitchc. & Maguire	subspecies	http://www.tropicos.org/Name/6303627	Silene scouleri	Caryophyllaceae	true	tropicos	[Partial match]	\N
148
COPY tnrs ("Time_submitted", "Name_number", "Name_submitted", "Overall_score", "Name_matched", "Name_matched_rank", "Name_score", "Name_matched_author", "Name_matched_url", "Author_matched", "Author_score", "Family_matched", "Family_score", "Genus_matched", "Genus_score", "Specific_epithet_matched", "Specific_epithet_score", "Infraspecific_rank", "Infraspecific_epithet_matched", "Infraspecific_epithet_score", "Infraspecific_rank_2", "Infraspecific_epithet_2_matched", "Infraspecific_epithet_2_score", "Annotations", "Unmatched_terms", "Taxonomic_status", "Accepted_name", "Accepted_name_author", "Accepted_name_rank", "Accepted_name_url", "Accepted_species", "Accepted_family", "Selected", "Source", "Warnings", "Accepted_name_lsid", "Accepted_scientific_name", "Max_score") FROM stdin;
149
2013-05-21 19:23:15.278517-07	0	Fam_indet. Boyle#6501	0	No suitable matches found.	\N	0	\N	\N	\N	0	\N	0	\N	0	\N	0	\N	\N	0	\N	\N	0	\N	\N	\N	\N	\N	\N	\N	\N	\N	true	\N	 	\N	\N	0
150
2013-05-21 19:23:15.278517-07	1	Poa annua var. eriolepis	1	Poa annua var. eriolepis	variety	1	E. Desv.	http://www.tropicos.org/Name/50119145	\N	\N	\N	\N	Poa	1	annua	1	var.	eriolepis	1	\N	\N	\N	\N	\N	Synonym	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	 	\N	Poaceae Poa annua L.	1
151
2013-05-21 19:23:15.278517-07	2	Poa annua	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881	\N	\N	\N	\N	Poa	1	annua	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	 	\N	Poaceae Poa annua L.	1
152
2013-05-21 19:23:15.278517-07	3	Silene scouleri Hook. subsp. pringlei (S. Watson) C.L. Hitchc. & Maguire var. grisea C.L. Hitchc. & Maguire	0.77	Silene scouleri subsp. pringlei	subspecies	0.77	(S. Watson) C.L. Hitchc. & Maguire	http://www.tropicos.org/Name/6303627	\N	\N	\N	\N	Silene	1	scouleri	1	subsp.	pringlei	1	\N	\N	\N	\N	var. grisea	Accepted	Silene scouleri subsp. pringlei	(S. Watson) C.L. Hitchc. & Maguire	subspecies	http://www.tropicos.org/Name/6303627	Silene scouleri	Caryophyllaceae	true	tropicos	 [Partial match] 	\N	Caryophyllaceae Silene scouleri subsp. pringlei (S. Watson) C.L. Hitchc. & Maguire	1
153
2013-05-21 19:23:15.278517-07	4	Fabaceae Boyle#6500	0.9	Fabaceae	family	1	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Boyle#6500	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	 	\N	Fabaceae Lindl.	1
154
2013-05-21 19:23:15.278517-07	5	Poa annua subsp. exilis	1	Poa annua subsp. exilis	subspecies	1	(Tomm. ex Freyn) Asch. & Graebn.	http://www.tropicos.org/Name/50063800	\N	\N	\N	\N	Poa	1	annua	1	subsp.	exilis	1	\N	\N	\N	\N	\N	Synonym	Poa infirma	Kunth	species	http://www.tropicos.org/Name/25514158	Poa infirma	Poaceae	true	tropicos	 	\N	Poaceae Poa infirma Kunth	1
155
2013-05-21 19:23:15.278517-07	6	Poa annua ssp. exilis	1	Poa annua subsp. exilis	subspecies	1	(Tomm. ex Freyn) Asch. & Graebn.	http://www.tropicos.org/Name/50063800	\N	\N	\N	\N	Poa	1	annua	1	subsp.	exilis	1	\N	\N	\N	\N	\N	Synonym	Poa infirma	Kunth	species	http://www.tropicos.org/Name/25514158	Poa infirma	Poaceae	true	tropicos	 	\N	Poaceae Poa infirma Kunth	1
156
2013-05-21 19:23:15.278517-07	7	Poa annua subvar. minima	1	Poa annua subvar. minima	subvariety	1	(Schur) Asch. & Graebn.	http://www.tropicos.org/Name/50158097	\N	\N	\N	\N	Poa	1	annua	1	subvar.	minima	1	\N	\N	\N	\N	\N	Accepted	Poa annua subvar. minima	(Schur) Asch. & Graebn.	subvariety	http://www.tropicos.org/Name/50158097	Poa annua	Poaceae	true	tropicos	 	\N	Poaceae Poa annua subvar. minima (Schur) Asch. & Graebn.	1
157
2013-05-21 19:23:15.278517-07	8	Poa annua L.	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881	L.	1	\N	\N	Poa	1	annua	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	 	\N	Poaceae Poa annua L.	1
158
2013-05-21 19:23:15.278517-07	9	Compositae indet. sp.1	0.9	Compositae	family	1	Giseke	http://www.tropicos.org/Name/50255940	\N	\N	Compositae	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	indet. sp.1	Synonym	Asteraceae	Bercht. & J. Presl	family	http://www.tropicos.org/Name/50307371	\N	Asteraceae	true	tropicos	 	\N	Asteraceae Bercht. & J. Presl	1
159
2013-05-21 19:23:15.278517-07	10	Poa annua fo. lanuginosa	1	Poa annua fo. lanuginosa	forma	1	Sennen	http://www.tropicos.org/Name/50267771	\N	\N	\N	\N	Poa	1	annua	1	fo.	lanuginosa	1	\N	\N	\N	\N	\N	Synonym	Poa annua var. annua	\N	variety	http://www.tropicos.org/Name/25517736	Poa annua	Poaceae	true	tropicos	 	\N	Poaceae Poa annua var. annua	1
160
2013-05-21 19:23:15.278517-07	11	Silene scouleri subsp. pringlei var. grisea C.L. Hitchc. & Maguire	0.77	Silene scouleri subsp. pringlei	subspecies	0.77	(S. Watson) C.L. Hitchc. & Maguire	http://www.tropicos.org/Name/6303627	\N	\N	\N	\N	Silene	1	scouleri	1	subsp.	pringlei	1	\N	\N	\N	\N	var. grisea	Accepted	Silene scouleri subsp. pringlei	(S. Watson) C.L. Hitchc. & Maguire	subspecies	http://www.tropicos.org/Name/6303627	Silene scouleri	Caryophyllaceae	true	tropicos	 [Partial match] 	\N	Caryophyllaceae Silene scouleri subsp. pringlei (S. Watson) C.L. Hitchc. & Maguire	1
161
2013-05-21 19:23:15.278517-07	12	Fabaceae Inga "fuzzy leaf"	0.9	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	\N	\N	Fabaceae	1	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	"fuzzy leaf"	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	 	\N	Fabaceae Inga Mill.	1
162
2013-05-21 19:23:15.278517-07	13	Fabaceae Inga sp.3	0.9	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	\N	\N	Fabaceae	1	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	sp.3	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	 	\N	Fabaceae Inga Mill.	1
163
2013-05-21 19:23:15.278517-07	14	Fabaceae unknown #2	0.9	Fabaceae	family	1	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	unknown #2	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	 	\N	Fabaceae Lindl.	1
164
2013-05-21 19:23:19.089938-07	0	Poaceae Poa infirma Kunth	1	Poa infirma	species	1	Kunth	http://www.tropicos.org/Name/25514158	Kunth	1	Poaceae	1	Poa	1	infirma	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa infirma	Kunth	species	http://www.tropicos.org/Name/25514158	Poa infirma	Poaceae	true	tropicos	 	\N	Poaceae Poa infirma Kunth	1
165
2013-05-21 19:23:19.089938-07	1	Fabaceae Lindl.	0.5	Fabaceae	family	0.5	Lindl.	http://www.tropicos.org/Name/42000184	\N	\N	Fabaceae	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Lindl.	Accepted	Fabaceae	Lindl.	family	http://www.tropicos.org/Name/42000184	\N	Fabaceae	true	tropicos	 [Partial match] 	\N	Fabaceae Lindl.	1
166
2013-05-21 19:23:19.089938-07	2	Poaceae Poa annua subvar. minima (Schur) Asch. & Graebn.	1	Poa annua subvar. minima	subvariety	1	(Schur) Asch. & Graebn.	http://www.tropicos.org/Name/50158097	(Schur) Asch. & Graebn.	1	Poaceae	1	Poa	1	annua	1	subvar.	minima	1	\N	\N	\N	\N	\N	Accepted	Poa annua subvar. minima	(Schur) Asch. & Graebn.	subvariety	http://www.tropicos.org/Name/50158097	Poa annua	Poaceae	true	tropicos	 	\N	Poaceae Poa annua subvar. minima (Schur) Asch. & Graebn.	1
167
2013-05-21 19:23:19.089938-07	3	Fabaceae Inga Mill.	1	Inga	genus	1	Mill.	http://www.tropicos.org/Name/40031040	Mill.	1	Fabaceae	1	Inga	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Inga	Mill.	genus	http://www.tropicos.org/Name/40031040	\N	Fabaceae	true	tropicos	 	\N	Fabaceae Inga Mill.	1
168
2013-05-21 19:23:19.089938-07	4	Caryophyllaceae Silene scouleri subsp. pringlei (S. Watson) C.L. Hitchc. & Maguire	1	Silene scouleri subsp. pringlei	subspecies	1	(S. Watson) C.L. Hitchc. & Maguire	http://www.tropicos.org/Name/6303627	(S. Watson) C.L. Hitchc. & Maguire	1	Caryophyllaceae	1	Silene	1	scouleri	1	subsp.	pringlei	1	\N	\N	\N	\N	\N	Accepted	Silene scouleri subsp. pringlei	(S. Watson) C.L. Hitchc. & Maguire	subspecies	http://www.tropicos.org/Name/6303627	Silene scouleri	Caryophyllaceae	true	tropicos	 	\N	Caryophyllaceae Silene scouleri subsp. pringlei (S. Watson) C.L. Hitchc. & Maguire	1
169
2013-05-21 19:23:19.089938-07	5	Poaceae Poa annua L.	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881	L.	1	Poaceae	1	Poa	1	annua	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa annua	L.	species	http://www.tropicos.org/Name/25509881	Poa annua	Poaceae	true	tropicos	 	\N	Poaceae Poa annua L.	1
170
2013-05-21 19:23:19.089938-07	6	Asteraceae Bercht. & J. Presl	0.4	Asteraceae	family	0.5	Bercht. & J. Presl	http://www.tropicos.org/Name/50307371	\N	\N	Asteraceae	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Bercht. & J. Presl	Accepted	Asteraceae	Bercht. & J. Presl	family	http://www.tropicos.org/Name/50307371	\N	Asteraceae	true	tropicos	 [Partial match] 	\N	Asteraceae Bercht. & J. Presl	1
171
2013-05-21 19:23:19.089938-07	7	Poaceae Poa annua var. annua	1	Poa annua var. annua	variety	1	\N	http://www.tropicos.org/Name/25517736	\N	\N	Poaceae	1	Poa	1	annua	1	var.	annua	1	\N	\N	\N	\N	\N	Accepted	Poa annua var. annua	\N	variety	http://www.tropicos.org/Name/25517736	Poa annua	Poaceae	true	tropicos	 	\N	Poaceae Poa annua var. annua	1
251 172
\.
252 173

  
253 174

  
254 175
--
255
-- Name: tnrs_accepted_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: bien; Tablespace: 
176
-- Name: tnrs_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: bien; Tablespace: 
256 177
--
257 178

  
258
ALTER TABLE ONLY tnrs_accepted
259
    ADD CONSTRAINT tnrs_accepted_pkey PRIMARY KEY ("Name_submitted");
179
ALTER TABLE ONLY tnrs
180
    ADD CONSTRAINT tnrs_pkey PRIMARY KEY ("Name_submitted");
260 181

  
261 182

  
262 183
--
263
-- Name: tnrs_other_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: bien; Tablespace: 
184
-- Name: tnrs_score_ok; Type: INDEX; Schema: TNRS; Owner: bien; Tablespace: 
264 185
--
265 186

  
266
ALTER TABLE ONLY tnrs_other
267
    ADD CONSTRAINT tnrs_other_pkey PRIMARY KEY ("Name_submitted");
187
CREATE UNIQUE INDEX tnrs_score_ok ON tnrs USING btree ("Name_submitted") WHERE score_ok("Max_score");
268 188

  
269 189

  
270 190
--
271
-- Name: tnrs_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: bien; Tablespace: 
191
-- Name: tnrs_populate_derived_fields; Type: TRIGGER; Schema: TNRS; Owner: bien
272 192
--
273 193

  
274
ALTER TABLE ONLY tnrs
275
    ADD CONSTRAINT tnrs_pkey PRIMARY KEY ("Name_submitted");
194
CREATE TRIGGER tnrs_populate_derived_fields BEFORE INSERT OR UPDATE ON tnrs FOR EACH ROW EXECUTE PROCEDURE tnrs_populate_derived_fields();
276 195

  
277 196

  
278 197
--
inputs/test_taxonomic_names/_scrub/public.test_taxonomic_names.sql
4 4

  
5 5
SET statement_timeout = 0;
6 6
SET client_encoding = 'UTF8';
7
SET standard_conforming_strings = off;
7
SET standard_conforming_strings = on;
8 8
SET check_function_bodies = false;
9 9
SET client_min_messages = warning;
10
SET escape_string_warning = off;
11 10

  
12 11
--
13 12
-- Name: public.test_taxonomic_names; Type: SCHEMA; Schema: -; Owner: bien
......
18 17

  
19 18
ALTER SCHEMA "public.test_taxonomic_names" OWNER TO bien;
20 19

  
20
--
21
-- Name: SCHEMA "public.test_taxonomic_names"; Type: COMMENT; Schema: -; Owner: bien
22
--
23

  
24
COMMENT ON SCHEMA "public.test_taxonomic_names" IS 'Version: public (2013-5-21 19:23:27 PDT)';
25

  
26

  
21 27
SET search_path = "public.test_taxonomic_names", pg_catalog;
22 28

  
23 29
--
30
-- Name: accesslevel; Type: TYPE; Schema: public.test_taxonomic_names; Owner: bien
31
--
32

  
33
CREATE TYPE accesslevel AS ENUM (
34
    'private',
35
    'metadata only',
36
    'data by request',
37
    'public'
38
);
39

  
40

  
41
ALTER TYPE "public.test_taxonomic_names".accesslevel OWNER TO bien;
42

  
43
--
44
-- Name: coordinatesource; Type: TYPE; Schema: public.test_taxonomic_names; Owner: bien
45
--
46

  
47
CREATE TYPE coordinatesource AS ENUM (
48
    'source data',
49
    'GPS',
50
    'georeferencing'
51
);
52

  
53

  
54
ALTER TYPE "public.test_taxonomic_names".coordinatesource OWNER TO bien;
55

  
56
--
57
-- Name: TYPE coordinatesource; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
58
--
59

  
60
COMMENT ON TYPE coordinatesource IS 'From <https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore_data_dictionary#coordinateSource>';
61

  
62

  
63
--
24 64
-- Name: establishmentmeans_dwc; Type: TYPE; Schema: public.test_taxonomic_names; Owner: bien
25 65
--
26 66

  
......
68 108
ALTER TYPE "public.test_taxonomic_names".growthform OWNER TO bien;
69 109

  
70 110
--
111
-- Name: higher_plant_group; Type: TYPE; Schema: public.test_taxonomic_names; Owner: bien
112
--
113

  
114
CREATE TYPE higher_plant_group AS ENUM (
115
    'all',
116
    'bryophytes',
117
    'ferns and allies',
118
    'flowering plants',
119
    'gymnosperms (conifers)',
120
    'gymnosperms (non-conifer)'
121
);
122

  
123

  
124
ALTER TYPE "public.test_taxonomic_names".higher_plant_group OWNER TO bien;
125

  
126
--
127
-- Name: observationtype; Type: TYPE; Schema: public.test_taxonomic_names; Owner: bien
128
--
129

  
130
CREATE TYPE observationtype AS ENUM (
131
    'plot',
132
    'specimen'
133
);
134

  
135

  
136
ALTER TYPE "public.test_taxonomic_names".observationtype OWNER TO bien;
137

  
138
--
71 139
-- Name: occurrencestatus_dwc; Type: TYPE; Schema: public.test_taxonomic_names; Owner: bien
72 140
--
73 141

  
......
250 318

  
251 319
CREATE TYPE role AS ENUM (
252 320
    'unknown',
321
    'advisor',
322
    'author',
323
    'co-principal investigator',
253 324
    'collector',
325
    'computer',
326
    'contact',
327
    'contributor',
328
    'custodian/steward',
329
    'editor',
254 330
    'identifier',
255
    'computer',
256
    'contributor'
331
    'originator',
332
    'performer',
333
    'principal investigator',
334
    'recipient',
335
    'reviewer',
336
    'technician'
257 337
);
258 338

  
259 339

  
260 340
ALTER TYPE "public.test_taxonomic_names".role OWNER TO bien;
261 341

  
262 342
--
343
-- Name: TYPE role; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
344
--
345

  
346
COMMENT ON TYPE role IS 'From <http://vegbank.org/vegbank/views/dba_fielddescription_detail.jsp?view=detail&wparam=1331&entity=dba_fielddescription&params=1331>, <http://vegbank.org/vegbank/views/dba_tabledescription_detail.jsp?view=detail&wparam=projectcontributor&entity=dba_tabledescription&where=where_tablename#ROLE_ID>, and misc terms.';
347

  
348

  
349
--
350
-- Name: sourcetype; Type: TYPE; Schema: public.test_taxonomic_names; Owner: bien
351
--
352

  
353
CREATE TYPE sourcetype AS ENUM (
354
    'herbarium',
355
    'primary database',
356
    'aggregator',
357
    'book',
358
    'article',
359
    'chapter',
360
    'conference proceedings',
361
    'dissertation',
362
    'edited book',
363
    'generic',
364
    'journal',
365
    'manuscript',
366
    'personal communication',
367
    'presentation',
368
    'report',
369
    'thesis',
370
    'website'
371
);
372

  
373

  
374
ALTER TYPE "public.test_taxonomic_names".sourcetype OWNER TO bien;
375

  
376
--
377
-- Name: TYPE sourcetype; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
378
--
379

  
380
COMMENT ON TYPE sourcetype IS 'From <https://projects.nceas.ucsb.edu/nceas/attachments/download/428/bien_web_datasource_schema.sql>, <http://vegbank.org/vegbank/views/dba_fielddescription_detail.jsp?view=detail&wparam=1300&entity=dba_fielddescription&params=1300>, <http://vegbiendev.nceas.ucsb.edu/phppgadmin/display.php?server=localhost%3A5432%3Aallow&database=vegbien&schema=VegBank&table=source&subject=table#sourcetype>';
381

  
382

  
383
--
263 384
-- Name: taxonclass; Type: TYPE; Schema: public.test_taxonomic_names; Owner: bien
264 385
--
265 386

  
......
400 521
ALTER FUNCTION "public.test_taxonomic_names"._in_to_m(value double precision) OWNER TO bien;
401 522

  
402 523
--
524
-- Name: _km_to_m(double precision); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
525
--
526

  
527
CREATE FUNCTION _km_to_m(value double precision) RETURNS double precision
528
    LANGUAGE sql IMMUTABLE STRICT
529
    AS $_$
530
SELECT $1*1000.
531
$_$;
532

  
533

  
534
ALTER FUNCTION "public.test_taxonomic_names"._km_to_m(value double precision) OWNER TO bien;
535

  
536
--
537
-- Name: _locationnarrative_is_cultivated(text); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
538
--
539

  
540
CREATE FUNCTION _locationnarrative_is_cultivated(locationnarrative text) RETURNS boolean
541
    LANGUAGE sql IMMUTABLE STRICT
542
    AS $_$
543
SELECT bool_or(value)
544
FROM
545
(VALUES
546
      (NULLIF($1 LIKE '%cultivated%', false))
547
    , (NULLIF($1 LIKE '%cultivad%', false))
548
    , (NULLIF($1 LIKE '%ornamental%', false))
549
    , (NULLIF($1 LIKE '%garden%', false))
550
    , (NULLIF($1 LIKE '%jardin%', false))
551
    , (NULLIF($1 LIKE '%jard?n%', false))
552
    , (NULLIF($1 LIKE '%jardim%', false))
553
    , (NULLIF($1 LIKE '%plantation%', false))
554
    , (NULLIF($1 LIKE '%plantacion%', false))
555
    , (NULLIF($1 LIKE '%plantaci?n%', false))
556
    , (NULLIF($1 LIKE '%universit%', false))
557
    , (NULLIF($1 LIKE '%universidad%', false))
558
    , (NULLIF($1 LIKE '%campus%' , false))
559
    , (NULLIF($1 LIKE '%urban%', false))
560
    , (NULLIF($1 LIKE '%greenhouse%', false))
561
    , (NULLIF($1 LIKE '%arboretum%', false))
562
    , (NULLIF($1 LIKE '%farm%', false))
563
    , (NULLIF($1 LIKE '%weed%', false))
564
    , (NULLIF($1 LIKE '%corn field%', false))
565
)
566
AS v (value)
567
$_$;
568

  
569

  
570
ALTER FUNCTION "public.test_taxonomic_names"._locationnarrative_is_cultivated(locationnarrative text) OWNER TO bien;
571

  
572
--
403 573
-- Name: _m2_to_ha(double precision); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
404 574
--
405 575

  
......
426 596
ALTER FUNCTION "public.test_taxonomic_names"._m_to_cm(value double precision) OWNER TO bien;
427 597

  
428 598
--
599
-- Name: _m_to_km(double precision); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
600
--
601

  
602
CREATE FUNCTION _m_to_km(value double precision) RETURNS double precision
603
    LANGUAGE sql IMMUTABLE STRICT
604
    AS $_$
605
SELECT $1/1000.
606
$_$;
607

  
608

  
609
ALTER FUNCTION "public.test_taxonomic_names"._m_to_km(value double precision) OWNER TO bien;
610

  
611
--
612
-- Name: _mm_to_m(double precision); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
613
--
614

  
615
CREATE FUNCTION _mm_to_m(value double precision) RETURNS double precision
616
    LANGUAGE sql IMMUTABLE STRICT
617
    AS $_$
618
SELECT $1/1000.
619
$_$;
620

  
621

  
622
ALTER FUNCTION "public.test_taxonomic_names"._mm_to_m(value double precision) OWNER TO bien;
623

  
624
--
625
-- Name: _or(boolean, boolean, boolean, boolean, boolean); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
626
--
627

  
628
CREATE FUNCTION _or("0" boolean DEFAULT NULL::boolean, "1" boolean DEFAULT NULL::boolean, "2" boolean DEFAULT NULL::boolean, "3" boolean DEFAULT NULL::boolean, "4" boolean DEFAULT NULL::boolean) RETURNS boolean
629
    LANGUAGE sql IMMUTABLE
630
    AS $_$
631
SELECT bool_or(value)
632
FROM
633
(VALUES
634
      ($1)
635
    , ($2)
636
    , ($3)
637
    , ($4)
638
    , ($5)
639
)
640
AS v (value)
641
$_$;
642

  
643

  
644
ALTER FUNCTION "public.test_taxonomic_names"._or("0" boolean, "1" boolean, "2" boolean, "3" boolean, "4" boolean) OWNER TO bien;
645

  
646
--
647
-- Name: FUNCTION _or("0" boolean, "1" boolean, "2" boolean, "3" boolean, "4" boolean); Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
648
--
649

  
650
COMMENT ON FUNCTION _or("0" boolean, "1" boolean, "2" boolean, "3" boolean, "4" boolean) IS '_or() ignores NULL values, while OR combines them with the other values to potentially convert false to NULL. OR should be used with required fields, and _or() with optional fields.';
651

  
652

  
653
--
429 654
-- Name: _percent_to_fraction(double precision); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
430 655
--
431 656

  
......
445 670
CREATE FUNCTION _taxon_family_require_std(family text) RETURNS text
446 671
    LANGUAGE sql IMMUTABLE STRICT
447 672
    AS $_$
448
SELECT (CASE WHEN $1 LIKE '%aceae' THEN $1 ELSE NULL END)
673
SELECT (CASE WHEN
674
    lower($1) LIKE '%aceae'
675
    OR lower($1) IN (
676
        'compositae',
677
        'cruciferae',
678
        'gramineae',
679
        'labiatae',
680
        'leguminosae',
681
        'palmae',
682
        'umbelliferae'
683
    )
684
THEN $1 ELSE NULL END)
449 685
$_$;
450 686

  
451 687

  
......
510 746
ALTER FUNCTION "public.test_taxonomic_names"._taxonomic_name_is_epithet(rank taxonrank) OWNER TO bien;
511 747

  
512 748
--
513
-- Name: make_analytical_stem(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
749
-- Name: delete_scrubbed_taxondeterminations(text); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
514 750
--
515 751

  
516
CREATE FUNCTION make_analytical_stem() RETURNS void
752
CREATE FUNCTION delete_scrubbed_taxondeterminations(datasource text) RETURNS void
517 753
    LANGUAGE sql
754
    AS $_$
755
DELETE FROM taxondetermination
756
USING taxonoccurrence
757
WHERE
758
    taxonoccurrence.source_id = source_by_shortname($1)
759
AND taxondetermination.taxonoccurrence_id = taxonoccurrence.taxonoccurrence_id
760
AND taxondetermination.source_id = source_by_shortname('TNRS')
761
$_$;
762

  
763

  
764
ALTER FUNCTION "public.test_taxonomic_names".delete_scrubbed_taxondeterminations(datasource text) OWNER TO bien;
765

  
766
--
767
-- Name: make_family_higher_plant_group(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
768
--
769

  
770
CREATE FUNCTION make_family_higher_plant_group() RETURNS void
771
    LANGUAGE plpgsql
518 772
    AS $$
519
INSERT INTO analytical_stem SELECT * FROM analytical_stem_view;
520
INSERT INTO analytical_aggregate SELECT * FROM analytical_aggregate_view;
773
DECLARE
774
    source_id_ integer :=
775
        (SELECT source_id FROM source WHERE shortname = 'NCBI');
776
    row_ higher_plant_group_nodes%ROWTYPE;
777
BEGIN
778
    TRUNCATE family_higher_plant_group;
779
    
780
    FOR row_ IN
781
        SELECT * FROM higher_plant_group_nodes
782
        ORDER BY higher_plant_group, node_name
783
    LOOP
784
        DECLARE
785
            higher_plant_group_id integer := (
786
                SELECT taxonlabel_id FROM taxonlabel
787
                WHERE source_id = source_id_
788
                AND taxonomicname = row_.node_name
789
            );
790
            family text;
791
        BEGIN
792
            FOR family IN
793
                SELECT taxonepithet
794
                FROM taxonlabel_relationship
795
                JOIN taxonlabel ON taxonlabel_id = descendant_id
796
                WHERE ancestor_id = higher_plant_group_id
797
                AND rank = 'family'
798
                AND source_id = source_id_
799
                AND taxonepithet IS NOT NULL
800
            LOOP
801
                BEGIN
802
                    INSERT INTO family_higher_plant_group
803
                    VALUES (family, row_.higher_plant_group)
804
                    ;
805
                EXCEPTION
806
                    WHEN unique_violation THEN NULL;
807
                END;
808
            END LOOP;
809
        END;
810
    END LOOP;
811
END;
521 812
$$;
522 813

  
523 814

  
524
ALTER FUNCTION "public.test_taxonomic_names".make_analytical_stem() OWNER TO bien;
815
ALTER FUNCTION "public.test_taxonomic_names".make_family_higher_plant_group() OWNER TO bien;
525 816

  
526 817
--
527
-- Name: party_creator_id_self_ref(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
818
-- Name: party_source_id_self_ref(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
528 819
--
529 820

  
530
CREATE FUNCTION party_creator_id_self_ref() RETURNS trigger
821
CREATE FUNCTION party_source_id_self_ref() RETURNS trigger
531 822
    LANGUAGE plpgsql
532 823
    AS $$
533 824
BEGIN
534 825
    IF new.party_id IS NULL THEN -- prepopulate party_id
535 826
        new.party_id = nextval('party_party_id_seq'::regclass);
536 827
    END IF;
537
    IF new.creator_id = 0 THEN -- make self-reference
538
        new.creator_id = new.party_id;
828
    IF new.source_id = 0 THEN -- make self-source
829
        new.source_id = new.party_id;
539 830
    END IF;
540 831
    RETURN new;
541 832
END;
542 833
$$;
543 834

  
544 835

  
545
ALTER FUNCTION "public.test_taxonomic_names".party_creator_id_self_ref() OWNER TO bien;
836
ALTER FUNCTION "public.test_taxonomic_names".party_source_id_self_ref() OWNER TO bien;
546 837

  
547 838
--
548 839
-- Name: place_matched_place_id_self_ref(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
......
555 846
    IF new.place_id IS NULL THEN -- prepopulate place_id
556 847
        new.place_id = nextval('place_place_id_seq'::regclass);
557 848
    END IF;
558
    IF new.matched_place_id = 0 THEN -- make self-reference
849
    IF new.matched_place_id = 0 THEN -- make self-source
559 850
        new.matched_place_id = new.place_id;
560 851
    END IF;
561 852
    RETURN new;
......
565 856

  
566 857
ALTER FUNCTION "public.test_taxonomic_names".place_matched_place_id_self_ref() OWNER TO bien;
567 858

  
859
SET default_tablespace = '';
860

  
861
SET default_with_oids = false;
862

  
568 863
--
864
-- Name: place; Type: TABLE; Schema: public.test_taxonomic_names; Owner: bien; Tablespace: 
865
--
866

  
867
CREATE TABLE place (
868
    place_id integer NOT NULL,
869
    source_id integer NOT NULL,
870
    canon_place_id integer,
871
    matched_place_id integer,
872
    coordinates_id integer,
873
    placename_id integer,
874
    continent text,
875
    country text,
876
    stateprovince text,
877
    county text,
878
    description text,
879
    geovalid boolean DEFAULT false NOT NULL,
880
    distance_to_country_m double precision,
881
    distance_to_state_m double precision,
882
    distance_to_county_m double precision,
883
    CONSTRAINT place_required_key CHECK ((((((coordinates_id IS NOT NULL) OR (continent IS NOT NULL)) OR (country IS NOT NULL)) OR (stateprovince IS NOT NULL)) OR (county IS NOT NULL)))
884
);
885

  
886

  
887
ALTER TABLE "public.test_taxonomic_names".place OWNER TO bien;
888

  
889
--
890
-- Name: TABLE place; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
891
--
892

  
893
COMMENT ON TABLE place IS 'The full path to a place. Can be either verbatim or accepted. For accepted names, points to the identified place.
894

  
895
To use a custom hierarchy of placenames with no explicit column, point to the lowest-rank placename in placename_id.';
896

  
897

  
898
--
899
-- Name: COLUMN place.matched_place_id; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
900
--
901

  
902
COMMENT ON COLUMN place.matched_place_id IS 'The closest match to this place. Places should be linked in a three-level hierarchy of datasource place -> verbatim place -> accepted place.
903

  
904
An accepted place should point to itself in this field. This will happen automatically by setting it to the special value 0.';
905

  
906

  
907
--
908
-- Name: place_set_canon_place_id(place, integer, boolean); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
909
--
910

  
911
CREATE FUNCTION place_set_canon_place_id(new place, old_matched_place_id integer DEFAULT NULL::integer, is_update boolean DEFAULT false) RETURNS place
912
    LANGUAGE plpgsql
913
    AS $$
914
BEGIN
915
    IF NOT is_update
916
        OR new.matched_place_id IS DISTINCT FROM old_matched_place_id THEN
917
        IF new.matched_place_id IS NOT NULL THEN
918
            IF new.matched_place_id = new.place_id THEN -- self-source
919
                new.canon_place_id := new.place_id; -- make self-source
920
            ELSE -- propagate from matched place
921
                new.canon_place_id := (
922
                    SELECT canon_place_id
923
                    FROM place
924
                    WHERE place_id = new.matched_place_id
925
                );
926
            END IF;
927
            
928
            IF is_update THEN
929
                -- Update canon_place_id on places that resolve to this place
930
                UPDATE place
931
                SET canon_place_id = new.canon_place_id
932
                WHERE matched_place_id = new.place_id
933
                AND place_id != new.place_id -- no infinite recursion
934
                ;
935
            END IF;
936
        ELSE -- no matched place
937
            new.canon_place_id := new.place_id; -- make self-source
938
        END IF;
939
    END IF;
940
    
941
    RETURN new;
942
END;
943
$$;
944

  
945

  
946
ALTER FUNCTION "public.test_taxonomic_names".place_set_canon_place_id(new place, old_matched_place_id integer, is_update boolean) OWNER TO bien;
947

  
948
--
949
-- Name: place_set_canon_place_id_on_insert(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
950
--
951

  
952
CREATE FUNCTION place_set_canon_place_id_on_insert() RETURNS trigger
953
    LANGUAGE plpgsql
954
    AS $$
955
BEGIN
956
    new := place_set_canon_place_id(new);
957
    
958
    RETURN new;
959
END;
960
$$;
961

  
962

  
963
ALTER FUNCTION "public.test_taxonomic_names".place_set_canon_place_id_on_insert() OWNER TO bien;
964

  
965
--
966
-- Name: place_set_canon_place_id_on_update(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
967
--
968

  
969
CREATE FUNCTION place_set_canon_place_id_on_update() RETURNS trigger
970
    LANGUAGE plpgsql
971
    AS $$
972
BEGIN
973
    new := place_set_canon_place_id(new, old.matched_place_id, true);
974
    
975
    RETURN new;
976
END;
977
$$;
978

  
979

  
980
ALTER FUNCTION "public.test_taxonomic_names".place_set_canon_place_id_on_update() OWNER TO bien;
981

  
982
--
569 983
-- Name: placename_update_ancestors(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
570 984
--
571 985

  
......
639 1053
ALTER FUNCTION "public.test_taxonomic_names".plantobservation_aggregateoccurrence_count_1() OWNER TO bien;
640 1054

  
641 1055
--
642
-- Name: sync_analytical_aggregate_to_view(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1056
-- Name: source_by_shortname(text); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
643 1057
--
644 1058

  
645
CREATE FUNCTION sync_analytical_aggregate_to_view() RETURNS void
646
    LANGUAGE sql
1059
CREATE FUNCTION source_by_shortname(shortname text) RETURNS integer
1060
    LANGUAGE sql STABLE STRICT
1061
    AS $_$
1062
SELECT source_id FROM source WHERE shortname = $1 LIMIT 1
1063
$_$;
1064

  
1065

  
1066
ALTER FUNCTION "public.test_taxonomic_names".source_by_shortname(shortname text) OWNER TO bien;
1067

  
1068
--
1069
-- Name: sourcename_set_matched_source_id(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1070
--
1071

  
1072
CREATE FUNCTION sourcename_set_matched_source_id() RETURNS trigger
1073
    LANGUAGE plpgsql
647 1074
    AS $$
648
DROP TABLE IF EXISTS analytical_aggregate;
649
CREATE TABLE analytical_aggregate AS SELECT * FROM analytical_aggregate_view;
1075
BEGIN
1076
    IF new.matched_source_id IS NULL THEN -- populate matched_source_id
1077
        new.matched_source_id :=
1078
            (SELECT source_id FROM source WHERE shortname = new.name);
1079
    END IF;
1080
    RETURN new;
1081
END;
650 1082
$$;
651 1083

  
652 1084

  
653
ALTER FUNCTION "public.test_taxonomic_names".sync_analytical_aggregate_to_view() OWNER TO bien;
1085
ALTER FUNCTION "public.test_taxonomic_names".sourcename_set_matched_source_id() OWNER TO bien;
654 1086

  
655 1087
--
656 1088
-- Name: sync_analytical_stem_to_view(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
657 1089
--
658 1090

  
659 1091
CREATE FUNCTION sync_analytical_stem_to_view() RETURNS void
660
    LANGUAGE sql
1092
    LANGUAGE plpgsql
661 1093
    AS $$
662
DROP TABLE IF EXISTS analytical_stem;
663
CREATE TABLE analytical_stem AS SELECT * FROM analytical_stem_view;
1094
DECLARE
1095
    analytical_plot_def text := NULL;
1096
    analytical_specimen_def text := NULL;
1097
    provider_count_view_def text := NULL;
1098
BEGIN
1099
    -- Save and drop dependent objects
1100
    BEGIN
1101
        analytical_plot_def :=
1102
            'CREATE OR REPLACE VIEW analytical_plot AS '
1103
            ||pg_get_viewdef('analytical_plot');
1104
        DROP VIEW analytical_plot;
1105
    EXCEPTION
1106
        WHEN undefined_table THEN NULL;
1107
    END;
1108
    BEGIN
1109
        analytical_specimen_def :=
1110
            'CREATE OR REPLACE VIEW analytical_specimen AS '
1111
            ||pg_get_viewdef('analytical_specimen');
1112
        DROP VIEW analytical_specimen;
1113
    EXCEPTION
1114
        WHEN undefined_table THEN NULL;
1115
    END;
1116
    BEGIN
1117
        provider_count_view_def :=
1118
            'CREATE OR REPLACE VIEW provider_count_view AS '
1119
            ||pg_get_viewdef('provider_count_view');
1120
        DROP VIEW provider_count_view;
1121
    EXCEPTION
1122
        WHEN undefined_table THEN NULL;
1123
    END;
1124
    
1125
    DROP TABLE IF EXISTS analytical_stem;
1126
    CREATE TABLE analytical_stem AS SELECT * FROM analytical_stem_view LIMIT 0;
1127
    
1128
    GRANT SELECT ON TABLE analytical_stem TO bien_read;
1129
    GRANT SELECT ON TABLE analytical_stem_view TO bien_read;
1130
    
1131
    ALTER TABLE analytical_stem ADD FOREIGN KEY (datasource) REFERENCES source (shortname) ON UPDATE CASCADE ON DELETE CASCADE;
1132
    
1133
    ALTER TABLE analytical_stem ALTER COLUMN "datasource" SET NOT NULL;
1134
    ALTER TABLE analytical_stem ALTER COLUMN "locationID" SET NOT NULL;
1135
    
1136
    CREATE INDEX ON analytical_stem ("datasource", "occurrenceID");
1137
    CREATE INDEX ON analytical_stem ("datasource", "institutionCode", "collectionCode", "catalogNumber");
1138
    CREATE INDEX ON analytical_stem ("datasource", "projectID", "locationID", "dateCollected");
1139
    
1140
    -- Re-create dependent objects
1141
    IF analytical_plot_def IS NOT NULL THEN
1142
        EXECUTE analytical_plot_def;
1143
        GRANT SELECT ON TABLE analytical_plot TO bien_read;
1144
    END IF;
1145
    IF analytical_specimen_def IS NOT NULL THEN
1146
        EXECUTE analytical_specimen_def;
1147
        GRANT SELECT ON TABLE analytical_specimen TO bien_read;
1148
    END IF;
1149
    IF provider_count_view_def IS NOT NULL THEN
1150
        EXECUTE provider_count_view_def;
1151
        GRANT SELECT ON TABLE provider_count_view TO bien_read;
1152
        GRANT SELECT ON TABLE provider_count_view TO public_;
1153
    END IF;
1154
END;
664 1155
$$;
665 1156

  
666 1157

  
667 1158
ALTER FUNCTION "public.test_taxonomic_names".sync_analytical_stem_to_view() OWNER TO bien;
668 1159

  
669 1160
--
670
-- Name: taxonlabel_0_matched_label_id_self_ref(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1161
-- Name: sync_geoscrub_input_to_view(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
671 1162
--
672 1163

  
673
CREATE FUNCTION taxonlabel_0_matched_label_id_self_ref() RETURNS trigger
1164
CREATE FUNCTION sync_geoscrub_input_to_view() RETURNS void
1165
    LANGUAGE sql
1166
    AS $$
1167
DROP TABLE IF EXISTS geoscrub_input;
1168
CREATE TABLE geoscrub_input AS SELECT * FROM geoscrub_input_view;
1169

  
1170
GRANT SELECT ON TABLE geoscrub_input TO bien_read;
1171
GRANT SELECT ON TABLE geoscrub_input_view TO bien_read;
1172
$$;
1173

  
1174

  
1175
ALTER FUNCTION "public.test_taxonomic_names".sync_geoscrub_input_to_view() OWNER TO bien;
1176

  
1177
--
1178
-- Name: sync_provider_count_to_view(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1179
--
1180

  
1181
CREATE FUNCTION sync_provider_count_to_view() RETURNS void
1182
    LANGUAGE sql
1183
    AS $$
1184
DROP TABLE IF EXISTS provider_count;
1185
CREATE TABLE provider_count AS SELECT * FROM provider_count_view LIMIT 0;
1186

  
1187
GRANT SELECT ON TABLE provider_count TO bien_read;
1188
GRANT SELECT ON TABLE provider_count TO public_;
1189
GRANT SELECT ON TABLE provider_count_view TO bien_read;
1190
GRANT SELECT ON TABLE provider_count_view TO public_;
1191

  
1192
ALTER TABLE provider_count ADD PRIMARY KEY (dataprovider, dataset);
1193
$$;
1194

  
1195

  
1196
ALTER FUNCTION "public.test_taxonomic_names".sync_provider_count_to_view() OWNER TO bien;
1197

  
1198
--
1199
-- Name: sync_taxon_trait_to_view(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1200
--
1201

  
1202
CREATE FUNCTION sync_taxon_trait_to_view() RETURNS void
1203
    LANGUAGE sql
1204
    AS $$
1205
DROP TABLE IF EXISTS taxon_trait;
1206
CREATE TABLE taxon_trait AS SELECT * FROM taxon_trait_view LIMIT 0;
1207

  
1208
GRANT SELECT ON TABLE taxon_trait TO bien_read;
1209
GRANT SELECT ON TABLE taxon_trait_view TO bien_read;
1210

  
1211
ALTER TABLE taxon_trait ALTER COLUMN "scientificName" SET NOT NULL;
1212
ALTER TABLE taxon_trait ALTER COLUMN "measurementType" SET NOT NULL;
1213

  
1214
CREATE INDEX ON taxon_trait ("scientificName", "measurementType" );
1215
$$;
1216

  
1217

  
1218
ALTER FUNCTION "public.test_taxonomic_names".sync_taxon_trait_to_view() OWNER TO bien;
1219

  
1220
--
1221
-- Name: taxondetermination_set_iscurrent(integer); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1222
--
1223

  
1224
CREATE FUNCTION taxondetermination_set_iscurrent(taxonoccurrence_id_ integer) RETURNS void
674 1225
    LANGUAGE plpgsql
675 1226
    AS $$
676 1227
BEGIN
677
    IF new.taxonlabel_id IS NULL THEN -- prepopulate taxonlabel_id
678
        new.taxonlabel_id = nextval('taxonlabel_taxonlabel_id_seq'::regclass);
679
    END IF;
680
    IF new.matched_label_id = 0 THEN -- make self-reference
681
        new.matched_label_id = new.taxonlabel_id;
682
    END IF;
1228
    UPDATE taxondetermination SET iscurrent = false
1229
    WHERE taxonoccurrence_id = taxonoccurrence_id_ AND iscurrent;
1230
    
1231
    UPDATE taxondetermination SET iscurrent = true
1232
    WHERE taxondetermination_id = (
1233
        SELECT taxondetermination_id FROM taxondetermination
1234
        WHERE taxonoccurrence_id = taxonoccurrence_id_
1235
        ORDER BY
1236
            -- Scrubbed determinations must come first for scrub.make to work
1237
              COALESCE(determinationtype = 'accepted', false) DESC/*true first*/
1238
            , COALESCE(determinationtype = 'matched', false) DESC/*true first*/
1239
            , isoriginal/*false first*/
1240
            , determinationdate DESC NULLS LAST
1241
        LIMIT 1
1242
    );
1243
    
1244
    UPDATE taxondetermination SET is_datasource_current = false
1245
    WHERE taxonoccurrence_id = taxonoccurrence_id_ AND is_datasource_current;
1246
    
1247
    UPDATE taxondetermination SET is_datasource_current = true
1248
    WHERE taxondetermination_id = (
1249
        SELECT taxondetermination_id FROM taxondetermination
1250
        WHERE taxonoccurrence_id = taxonoccurrence_id_
1251
        AND determinationtype IS NULL
1252
        ORDER BY
1253
            isoriginal/*false first*/
1254
            , determinationdate DESC NULLS LAST
1255
        LIMIT 1
1256
    );
1257
END;
1258
$$;
1259

  
1260

  
1261
ALTER FUNCTION "public.test_taxonomic_names".taxondetermination_set_iscurrent(taxonoccurrence_id_ integer) OWNER TO bien;
1262

  
1263
--
1264
-- Name: taxondetermination_set_iscurrent_on_delete(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1265
--
1266

  
1267
CREATE FUNCTION taxondetermination_set_iscurrent_on_delete() RETURNS trigger
1268
    LANGUAGE plpgsql
1269
    AS $$
1270
BEGIN
1271
    BEGIN
1272
        PERFORM taxondetermination_set_iscurrent(old.taxonoccurrence_id);
1273
    EXCEPTION
1274
        WHEN foreign_key_violation THEN NULL; -- cascading delete
1275
    END;
1276
    
1277
    RETURN old;
1278
END;
1279
$$;
1280

  
1281

  
1282
ALTER FUNCTION "public.test_taxonomic_names".taxondetermination_set_iscurrent_on_delete() OWNER TO bien;
1283

  
1284
--
1285
-- Name: taxondetermination_set_iscurrent_on_insert(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1286
--
1287

  
1288
CREATE FUNCTION taxondetermination_set_iscurrent_on_insert() RETURNS trigger
1289
    LANGUAGE plpgsql
1290
    AS $$
1291
BEGIN
1292
    PERFORM taxondetermination_set_iscurrent(new.taxonoccurrence_id);
683 1293
    RETURN new;
684 1294
END;
685 1295
$$;
686 1296

  
687 1297

  
688
ALTER FUNCTION "public.test_taxonomic_names".taxonlabel_0_matched_label_id_self_ref() OWNER TO bien;
1298
ALTER FUNCTION "public.test_taxonomic_names".taxondetermination_set_iscurrent_on_insert() OWNER TO bien;
689 1299

  
690 1300
--
691
-- Name: taxonlabel_1_matched_label_min_fit(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
1301
-- Name: taxonlabel_0_matched_label_id_self_ref(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
692 1302
--
693 1303

  
694
CREATE FUNCTION taxonlabel_1_matched_label_min_fit() RETURNS trigger
1304
CREATE FUNCTION taxonlabel_0_matched_label_id_self_ref() RETURNS trigger
695 1305
    LANGUAGE plpgsql
696 1306
    AS $$
697 1307
BEGIN
698
    IF new.matched_label_id IS NOT NULL
699
        AND new.matched_label_fit_fraction < 0.8 THEN -- insufficient match
700
        new.matched_label_id = NULL;
701
        new.matched_label_fit_fraction = NULL;
1308
    IF new.taxonlabel_id IS NULL THEN -- prepopulate taxonlabel_id
1309
        new.taxonlabel_id = nextval('taxonlabel_taxonlabel_id_seq'::regclass);
702 1310
    END IF;
1311
    IF new.matched_label_id = 0 THEN -- make self-source
1312
        new.matched_label_id = new.taxonlabel_id;
1313
    END IF;
703 1314
    RETURN new;
704 1315
END;
705 1316
$$;
706 1317

  
707 1318

  
708
ALTER FUNCTION "public.test_taxonomic_names".taxonlabel_1_matched_label_min_fit() OWNER TO bien;
1319
ALTER FUNCTION "public.test_taxonomic_names".taxonlabel_0_matched_label_id_self_ref() OWNER TO bien;
709 1320

  
710 1321
--
711 1322
-- Name: taxonlabel_2_set_canon_label_id_on_insert(); Type: FUNCTION; Schema: public.test_taxonomic_names; Owner: bien
......
757 1368

  
758 1369
ALTER FUNCTION "public.test_taxonomic_names".taxonlabel_3_parent_id_avoid_self_ref() OWNER TO bien;
759 1370

  
760
SET default_tablespace = '';
761

  
762
SET default_with_oids = false;
763

  
764 1371
--
765 1372
-- Name: taxonlabel; Type: TABLE; Schema: public.test_taxonomic_names; Owner: bien; Tablespace: 
766 1373
--
767 1374

  
768 1375
CREATE TABLE taxonlabel (
769 1376
    taxonlabel_id integer NOT NULL,
770
    creator_id integer NOT NULL,
1377
    source_id integer NOT NULL,
771 1378
    sourceaccessioncode text,
772
    creationdate date,
773 1379
    taxonstatus taxonomic_status,
774 1380
    canon_label_id integer,
775 1381
    matched_label_id integer,
776
    matched_label_fit_fraction double precision,
777 1382
    parent_id integer,
778 1383
    taxonepithet text,
779 1384
    rank taxonrank,
780 1385
    taxonomicname text,
781
    accessioncode text,
782
    CONSTRAINT taxonlabel_matched_label_fit_fraction_range CHECK (((matched_label_fit_fraction >= (0)::double precision) AND (matched_label_fit_fraction <= (1)::double precision))),
783 1386
    CONSTRAINT taxonlabel_required_key CHECK ((((sourceaccessioncode IS NOT NULL) OR (taxonepithet IS NOT NULL)) OR (taxonomicname IS NOT NULL)))
784 1387
);
785 1388

  
......
800 1403

  
801 1404

  
802 1405
--
803
-- Name: COLUMN taxonlabel.creator_id; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
1406
-- Name: COLUMN taxonlabel.source_id; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
804 1407
--
805 1408

  
806
COMMENT ON COLUMN taxonlabel.creator_id IS 'The entity that created the taxon label.';
1409
COMMENT ON COLUMN taxonlabel.source_id IS 'The entity that created the taxon label.';
807 1410

  
808 1411

  
809 1412
--
......
814 1417

  
815 1418

  
816 1419
--
817
-- Name: COLUMN taxonlabel.creationdate; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
818
--
819

  
820
COMMENT ON COLUMN taxonlabel.creationdate IS 'The date the taxonlabel was created or defined. For a taxonlabel applied in a taxondetermination, this is the date the determination was made.';
821

  
822

  
823
--
824 1420
-- Name: COLUMN taxonlabel.canon_label_id; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
825 1421
--
826 1422

  
......
839 1435

  
840 1436

  
841 1437
--
842
-- Name: COLUMN taxonlabel.matched_label_fit_fraction; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
843
--
844

  
845
COMMENT ON COLUMN taxonlabel.matched_label_fit_fraction IS 'The closeness of fit of the matched label.';
846

  
847

  
848
--
849 1438
-- Name: COLUMN taxonlabel.parent_id; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
850 1439
--
851 1440

  
......
870 1459
-- Name: COLUMN taxonlabel.taxonomicname; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
871 1460
--
872 1461

  
873
COMMENT ON COLUMN taxonlabel.taxonomicname IS 'The concatenated taxonomic name which uniquely identifies this taxon, including the author of that name. Must be unique within the datasource.
1462
COMMENT ON COLUMN taxonlabel.taxonomicname IS 'The concatenated taxonomic name which uniquely identifies this taxon, including the family and author of that name. Must be unique within the datasource.
874 1463

  
875 1464
Equivalent to Darwin Core''s scientificName.';
876 1465

  
......
883 1472
    LANGUAGE plpgsql
884 1473
    AS $$
885 1474
BEGIN
886
    IF new.matched_label_id IS DISTINCT FROM old_matched_label_id THEN
1475
    IF NOT is_update
1476
        OR new.matched_label_id IS DISTINCT FROM old_matched_label_id THEN
887 1477
        IF new.matched_label_id IS NOT NULL THEN
888
            IF new.matched_label_id = new.taxonlabel_id THEN -- self-reference
889
                new.canon_label_id := new.taxonlabel_id; -- make self-reference
1478
            IF new.matched_label_id = new.taxonlabel_id THEN -- self-source
1479
                new.canon_label_id := new.taxonlabel_id; -- make self-source
890 1480
            ELSE -- propagate from matched label
891 1481
                new.canon_label_id := (
892 1482
                    SELECT canon_label_id
......
904 1494
                ;
905 1495
            END IF;
906 1496
        ELSE -- no matched taxonlabel
907
            new.canon_label_id := new.taxonlabel_id; -- make self-reference
1497
            new.canon_label_id := new.taxonlabel_id; -- make self-source
908 1498
        END IF;
909 1499
    END IF;
910 1500
    
......
1046 1636
    organization_id integer,
1047 1637
    orgposition text,
1048 1638
    email text,
1049
    deliverypoint text,
1639
    street text,
1640
    street2 text,
1050 1641
    city text,
1051
    administrativearea text,
1642
    stateprovince text,
1052 1643
    postalcode text,
1053 1644
    country text,
1054 1645
    currentflag boolean,
......
1092 1683

  
1093 1684
CREATE TABLE aggregateoccurrence (
1094 1685
    aggregateoccurrence_id integer NOT NULL,
1095
    creator_id integer NOT NULL,
1686
    source_id integer NOT NULL,
1096 1687
    sourceaccessioncode text,
1097 1688
    taxonoccurrence_id integer,
1098 1689
    collectiondate date,
......
1107 1698
    occurrencestatus_dwc occurrencestatus_dwc DEFAULT 'present'::occurrencestatus_dwc NOT NULL,
1108 1699
    method_id integer,
1109 1700
    notes text,
1110
    accessioncode text,
1111 1701
    CONSTRAINT aggregateoccurrence_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (taxonoccurrence_id IS NOT NULL)))
1112 1702
);
1113 1703

  
......
1164 1754

  
1165 1755

  
1166 1756
--
1167
-- Name: analytical_aggregate; Type: TABLE; Schema: public.test_taxonomic_names; Owner: bien; Tablespace: 
1168
--
1169

  
1170
CREATE TABLE analytical_aggregate (
1171
    "institutionCode" text,
1172
    country text,
1173
    "stateProvince" text,
1174
    county text,
1175
    "decimalLatitude" double precision,
1176
    "decimalLongitude" double precision,
1177
    "plotName" text,
1178
    "elevationInMeters" double precision,
1179
    "plotArea_ha" double precision,
1180
    "samplingProtocol" text,
1181
    "dateCollected" date,
1182
    family text,
1183
    genus text,
1184
    "speciesBinomial" text,
1185
    "scientificName" text,
1186
    "scientificNameAuthorship" text,
1187
    "scientificNameWithMorphospecies" text,
1188
    "coverPercent" double precision,
1189
    "individualCount" bigint,
1190
    "individualCount_1cm_or_more" bigint,
1191
    "individualCount_2_5cm_or_more" bigint,
1192
    "individualCount_10cm_or_more" bigint
1193
);
1194

  
1195

  
1196
ALTER TABLE "public.test_taxonomic_names".analytical_aggregate OWNER TO bien;
1197

  
1198
--
1199 1757
-- Name: analytical_stem; Type: TABLE; Schema: public.test_taxonomic_names; Owner: bien; Tablespace: 
1200 1758
--
1201 1759

  
1202 1760
CREATE TABLE analytical_stem (
1761
    datasource text NOT NULL,
1203 1762
    "institutionCode" text,
1763
    "collectionCode" text,
1764
    "catalogNumber" text,
1765
    "occurrenceID" text,
1204 1766
    country text,
1205 1767
    "stateProvince" text,
1206 1768
    county text,
1769
    locality text,
1207 1770
    "decimalLatitude" double precision,
1208 1771
    "decimalLongitude" double precision,
1209
    "plotName" text,
1772
    "coordinateUncertaintyInMeters" double precision,
1773
    "coordinateSource_bien" coordinatesource,
1774
    "georeferenceProtocol_bien" text,
1775
    geovalid_bien integer,
1776
    "isNewWorld_bien" integer,
1777
    "projectID" text,
1778
    "locationID" text NOT NULL,
1779
    "locationName" text,
1780
    subplot text,
1781
    "individualCode" text,
1210 1782
    "elevationInMeters" double precision,
1211 1783
    "plotArea_ha" double precision,
1212 1784
    "samplingProtocol" text,
1785
    "temperature_C" double precision,
1786
    precipitation_m double precision,
1787
    "recordedBy" text,
1788
    "recordNumber" text,
1213 1789
    "dateCollected" date,
1790
    family_verbatim text,
1791
    "scientificName_verbatim" text,
1792
    "identifiedBy" text,
1793
    "dateIdentified" date,
1794
    "identificationRemarks" text,
1795
    family_matched text,
1796
    "taxonName_matched" text,
1797
    "scientificNameAuthorship_matched" text,
1798
    "higherPlantGroup_bien" higher_plant_group,
1214 1799
    family text,
1215 1800
    genus text,
1216
    "speciesBinomial" text,
1217
    "scientificName" text,
1801
    "speciesBinomialWithMorphospecies" text,
1802
    "taxonName" text,
1218 1803
    "scientificNameAuthorship" text,
1219
    "scientificNameWithMorphospecies" text,
1220
    "identifiedBy" text,
1221 1804
    "growthForm" growthform,
1222
    cultivated boolean,
1223
    "cultivatedBasis" text,
1805
    "reproductiveCondition" text,
1806
    threatened_bien integer,
1807
    cultivated_bien integer,
1808
    "cultivatedBasis_bien" text,
1809
    "occurrenceRemarks" text,
1224 1810
    "coverPercent" double precision,
1225 1811
    "diameterBreastHeight_cm" double precision,
1226 1812
    height_m double precision,
1227 1813
    tag text,
1228 1814
    "organismX_m" double precision,
1229 1815
    "organismY_m" double precision,
1230
    "recordedBy" text,
1231
    "recordNumber" text
1816
    "taxonOccurrenceID" text,
1817
    "authorTaxonCode" text,
1818
    "individualObservationID" text,
1819
    "authorStemCode" text
1232 1820
);
1233 1821

  
1234 1822

  
1235 1823
ALTER TABLE "public.test_taxonomic_names".analytical_stem OWNER TO bien;
1236 1824

  
1237 1825
--
1238
-- Name: analytical_aggregate_view; Type: VIEW; Schema: public.test_taxonomic_names; Owner: bien
1826
-- Name: analytical_plot; Type: VIEW; Schema: public.test_taxonomic_names; Owner: bien
1239 1827
--
1240 1828

  
1241
CREATE VIEW analytical_aggregate_view AS
1242
    SELECT analytical_stem."institutionCode", analytical_stem.country, analytical_stem."stateProvince", analytical_stem.county, analytical_stem."decimalLatitude", analytical_stem."decimalLongitude", analytical_stem."plotName", analytical_stem."elevationInMeters", analytical_stem."plotArea_ha", analytical_stem."samplingProtocol", analytical_stem."dateCollected", analytical_stem.family, analytical_stem.genus, analytical_stem."speciesBinomial", analytical_stem."scientificName", analytical_stem."scientificNameAuthorship", analytical_stem."scientificNameWithMorphospecies", sum(analytical_stem."coverPercent") AS "coverPercent", count(analytical_stem."diameterBreastHeight_cm") AS "individualCount", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((1)::double precision))) AS "individualCount_1cm_or_more", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((2.5)::double precision))) AS "individualCount_2_5cm_or_more", count((analytical_stem."diameterBreastHeight_cm" >= _cm_to_m((10)::double precision))) AS "individualCount_10cm_or_more" FROM analytical_stem GROUP BY analytical_stem."institutionCode", analytical_stem.country, analytical_stem."stateProvince", analytical_stem.county, analytical_stem."decimalLatitude", analytical_stem."decimalLongitude", analytical_stem."plotName", analytical_stem."elevationInMeters", analytical_stem."plotArea_ha", analytical_stem."samplingProtocol", analytical_stem."dateCollected", analytical_stem.family, analytical_stem.genus, analytical_stem."speciesBinomial", analytical_stem."scientificName", analytical_stem."scientificNameAuthorship", analytical_stem."scientificNameWithMorphospecies";
1829
CREATE VIEW analytical_plot AS
1830
    SELECT analytical_stem.datasource, analytical_stem.country, analytical_stem."stateProvince", analytical_stem.county, analytical_stem.locality, analytical_stem."decimalLatitude", analytical_stem."decimalLongitude", analytical_stem."coordinateUncertaintyInMeters", analytical_stem."coordinateSource_bien", analytical_stem."georeferenceProtocol_bien", analytical_stem.geovalid_bien, analytical_stem."isNewWorld_bien", analytical_stem."projectID", analytical_stem."locationID", analytical_stem."locationName", analytical_stem.subplot, analytical_stem."individualCode", analytical_stem."elevationInMeters", analytical_stem."plotArea_ha", analytical_stem."samplingProtocol", analytical_stem."recordedBy", analytical_stem."recordNumber", analytical_stem."dateCollected", analytical_stem.family_verbatim, analytical_stem."scientificName_verbatim", analytical_stem."identifiedBy", analytical_stem."dateIdentified", analytical_stem."identificationRemarks", analytical_stem.family_matched, analytical_stem."taxonName_matched", analytical_stem."scientificNameAuthorship_matched", analytical_stem."higherPlantGroup_bien", analytical_stem.family, analytical_stem.genus, analytical_stem."speciesBinomialWithMorphospecies", analytical_stem."taxonName", analytical_stem."scientificNameAuthorship", analytical_stem."growthForm", analytical_stem."reproductiveCondition", analytical_stem.threatened_bien, analytical_stem.cultivated_bien, analytical_stem."cultivatedBasis_bien", analytical_stem."occurrenceRemarks", analytical_stem."coverPercent", analytical_stem."diameterBreastHeight_cm", analytical_stem.height_m, analytical_stem.tag, analytical_stem."organismX_m", analytical_stem."organismY_m", analytical_stem."taxonOccurrenceID", analytical_stem."authorTaxonCode", analytical_stem."individualObservationID", analytical_stem."authorStemCode", analytical_stem."institutionCode", analytical_stem."collectionCode", analytical_stem."catalogNumber", analytical_stem."occurrenceID" FROM analytical_stem;
1243 1831

  
1244 1832

  
1245
ALTER TABLE "public.test_taxonomic_names".analytical_aggregate_view OWNER TO bien;
1833
ALTER TABLE "public.test_taxonomic_names".analytical_plot OWNER TO bien;
1246 1834

  
1247 1835
--
1836
-- Name: analytical_specimen; Type: VIEW; Schema: public.test_taxonomic_names; Owner: bien
1837
--
1838

  
1839
CREATE VIEW analytical_specimen AS
1840
    SELECT analytical_stem.datasource, analytical_stem."institutionCode", analytical_stem."collectionCode", analytical_stem."catalogNumber", analytical_stem."occurrenceID", analytical_stem.country, analytical_stem."stateProvince", analytical_stem.county, analytical_stem.locality, analytical_stem."decimalLatitude", analytical_stem."decimalLongitude", analytical_stem."coordinateUncertaintyInMeters", analytical_stem."coordinateSource_bien", analytical_stem."georeferenceProtocol_bien", analytical_stem.geovalid_bien, analytical_stem."isNewWorld_bien", analytical_stem."elevationInMeters", analytical_stem."recordedBy", analytical_stem."recordNumber", analytical_stem."dateCollected", analytical_stem.family_verbatim, analytical_stem."scientificName_verbatim", analytical_stem."identifiedBy", analytical_stem."dateIdentified", analytical_stem."identificationRemarks", analytical_stem.family_matched, analytical_stem."taxonName_matched", analytical_stem."scientificNameAuthorship_matched", analytical_stem."higherPlantGroup_bien", analytical_stem.family, analytical_stem.genus, analytical_stem."taxonName", analytical_stem."scientificNameAuthorship", analytical_stem."reproductiveCondition", analytical_stem.cultivated_bien, analytical_stem."cultivatedBasis_bien", analytical_stem."occurrenceRemarks" FROM analytical_stem;
1841

  
1842

  
1843
ALTER TABLE "public.test_taxonomic_names".analytical_specimen OWNER TO bien;
1844

  
1845
--
1248 1846
-- Name: coordinates; Type: TABLE; Schema: public.test_taxonomic_names; Owner: bien; Tablespace: 
1249 1847
--
1250 1848

  
1251 1849
CREATE TABLE coordinates (
1252 1850
    coordinates_id integer NOT NULL,
1253
    creator_id integer NOT NULL,
1851
    source_id integer NOT NULL,
1254 1852
    latitude_deg double precision NOT NULL,
1255 1853
    longitude_deg double precision NOT NULL,
1256 1854
    verbatimlatitude text,
1257 1855
    verbatimlongitude text,
1258 1856
    verbatimcoordinates text,
1259 1857
    footprintgeometry_dwc text,
1260
    coordsaccuracy_deg double precision
1858
    coordsaccuracy_m double precision
1261 1859
);
1262 1860

  
1263 1861

  
......
1271 1869

  
1272 1870

  
1273 1871
--
1274
-- Name: COLUMN coordinates.coordsaccuracy_deg; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
1872
-- Name: COLUMN coordinates.coordsaccuracy_m; Type: COMMENT; Schema: public.test_taxonomic_names; Owner: bien
1275 1873
--
1276 1874

  
1277
COMMENT ON COLUMN coordinates.coordsaccuracy_deg IS 'Accuracy of latitude/longitude or footprint geometry, in meters. This should generally be at least 1 m, which is the accuracy of the best GPSes.';
1875
COMMENT ON COLUMN coordinates.coordsaccuracy_m IS 'Accuracy of latitude/longitude or footprint geometry, in meters. This should generally be at least 1 m, which is the accuracy of the best GPSes.';
1278 1876

  
1279 1877

  
1280 1878
--
1879
-- Name: cultivated_family_locations; Type: TABLE; Schema: public.test_taxonomic_names; Owner: bien; Tablespace: 
1880
--
1881

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff