Project

General

Profile

« Previous | Next » 

Revision 5423

inputs/test_taxonomic_names/test_scrub: Also export the results to inputs/test_taxonomic_names/_scrub/

View differences:

inputs/test_taxonomic_names/test_scrub
6 6

  
7 7
cd "$selfDir/../.."
8 8

  
9
# Import names
9 10
make inputs/.TNRS/reinstall # asks user for confirmation
10 11
make schemas/public/reinstall # asks user for confirmation
11 12
make inputs/"$selfDirName"/import log=
......
16 17
    make inputs/.TNRS/import log=
17 18
    make inputs/"$selfDirName"/import log=
18 19
done
20

  
21
# Export results
22
# Don't overwrite TNRS.backup, which contains the full TNRS cache
23
make backups/TNRS.sql-remake
24
mv -f backups/TNRS.sql "$selfDir/_scrub"
25
make backups/public.sql-remake
26
mv -f backups/public.sql "$selfDir/_scrub"
inputs/test_taxonomic_names/_scrub/TNRS.sql
1
--
2
-- PostgreSQL database dump
3
--
4

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

  
12
--
13
-- Name: TNRS; Type: SCHEMA; Schema: -; Owner: bien
14
--
15

  
16
CREATE SCHEMA "TNRS";
17

  
18

  
19
ALTER SCHEMA "TNRS" OWNER TO bien;
20

  
21
SET search_path = "TNRS", pg_catalog;
22

  
23
SET default_tablespace = '';
24

  
25
SET default_with_oids = false;
26

  
27
--
28
-- Name: tnrs; Type: TABLE; Schema: TNRS; Owner: bien; Tablespace: 
29
--
30

  
31
CREATE TABLE tnrs (
32
    "Name_number" text,
33
    "Name_submitted" text NOT NULL,
34
    "Overall_score" text,
35
    "Name_matched" text,
36
    "Name_matched_rank" text,
37
    "Name_score" text,
38
    "Name_matched_author" text,
39
    "Name_matched_url" text,
40
    "Author_matched" text,
41
    "Author_score" text,
42
    "Family_matched" text,
43
    "Family_score" text,
44
    "Name_matched_accepted_family" text,
45
    "Genus_matched" text,
46
    "Genus_score" text,
47
    "Specific_epithet_matched" text,
48
    "Specific_epithet_score" text,
49
    "Infraspecific_rank" text,
50
    "Infraspecific_epithet_matched" text,
51
    "Infraspecific_epithet_score" text,
52
    "Infraspecific_rank_2" text,
53
    "Infraspecific_epithet_2_matched" text,
54
    "Infraspecific_epithet_2_score" text,
55
    "Annotations" text,
56
    "Unmatched_terms" text,
57
    "Taxonomic_status" text,
58
    "Accepted_name" text,
59
    "Accepted_name_author" text,
60
    "Accepted_name_rank" text,
61
    "Accepted_name_url" text,
62
    "Accepted_name_species" text,
63
    "Accepted_name_family" text,
64
    "Selected" text,
65
    "Source" text,
66
    "Warnings" text,
67
    "Accepted_name_lsid" text
68
);
69

  
70

  
71
ALTER TABLE "TNRS".tnrs OWNER TO bien;
72

  
73
--
74
-- Name: TABLE tnrs; Type: COMMENT; Schema: TNRS; Owner: bien
75
--
76

  
77
COMMENT ON TABLE tnrs IS 'tnrs_accepted_names sorts accepted names first (note that false sorts before true). Accepted names are defined as names that scrub to themselves.';
78

  
79

  
80
--
81
-- Data for Name: tnrs; Type: TABLE DATA; Schema: TNRS; Owner: bien
82
--
83

  
84
COPY tnrs ("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;
85
1	Poa annua L.	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881;http://plants.usda.gov/java/profile?symbol=POAN	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;http://plants.usda.gov/java/profile?symbol=POAN	Poa annua	Poaceae	true	tropicos;usda	\N	\N
86
1	Poa annua var. annua	1	Poa annua var. annua	variety	1	\N	http://www.tropicos.org/Name/25517736	\N	\N	\N	\N	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
87
2	Poa infirma Kunth	1	Poa infirma	species	1	Kunth	http://www.tropicos.org/Name/25514158;http://plants.usda.gov/java/profile?symbol=POIN30	Kunth	1	\N	\N	Poaceae	Poa	1	infirma	1	\N	\N	\N	\N	\N	\N	\N	\N	Accepted	Poa infirma	Kunth	species	http://www.tropicos.org/Name/25514158;http://plants.usda.gov/java/profile?symbol=POIN30	Poa infirma	Poaceae	true	tropicos;usda	\N	\N
88
0	Asteraceae Bercht. & J. Presl	0.4	Asteraceae	family	0.5	\N	http://compositae.landcareresearch.co.nz/default.aspx;http://plants.usda.gov/java/nameSearch	\N	\N	Asteraceae	1	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	\N	Bercht. & J. Presl	Accepted	Asteraceae	\N	family	http://compositae.landcareresearch.co.nz/default.aspx;http://plants.usda.gov/java/nameSearch	\N	\N	true	gcc;usda	[Partial match]	\N
89
14	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
90
12	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
91
10	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
92
9	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
93
11	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
94
0	Poa annua	1	Poa annua	species	1	L.	http://www.tropicos.org/Name/25509881;http://plants.usda.gov/java/profile?symbol=POAN	\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;http://plants.usda.gov/java/profile?symbol=POAN	Poa annua	Poaceae	true	tropicos;usda	\N	\N
95
6	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
96
4	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	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
97
3	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
98
5	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
99
2	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
100
8	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
101
7	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
102
13	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	\N
103
3	No suitable matches found.	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	\N
104
\.
105

  
106

  
107
--
108
-- Name: tnrs_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: bien; Tablespace: 
109
--
110

  
111
ALTER TABLE ONLY tnrs
112
    ADD CONSTRAINT tnrs_pkey PRIMARY KEY ("Name_submitted");
113

  
114

  
115
--
116
-- Name: tnrs_accepted_names; Type: INDEX; Schema: TNRS; Owner: bien; Tablespace: 
117
--
118

  
119
CREATE INDEX tnrs_accepted_names ON tnrs USING btree (((NOT ("Name_submitted" = ("Accepted_name" || COALESCE((' '::text || "Accepted_name_author"), ''::text))))), "Name_submitted");
120

  
121
ALTER TABLE tnrs CLUSTER ON tnrs_accepted_names;
122

  
123

  
124
--
125
-- PostgreSQL database dump complete
126
--
127

  
inputs/test_taxonomic_names/_scrub/public.sql
1
--
2
-- PostgreSQL database dump
3
--
4

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

  
12
SET search_path = public, pg_catalog;
13

  
14
--
15
-- Name: establishmentmeans_dwc; Type: TYPE; Schema: public; Owner: bien
16
--
17

  
18
CREATE TYPE establishmentmeans_dwc AS ENUM (
19
    'cultivated',
20
    'wild',
21
    'native',
22
    'exotic',
23
    'invasive',
24
    'escaped from captivity'
25
);
26

  
27

  
28
ALTER TYPE public.establishmentmeans_dwc OWNER TO bien;
29

  
30
--
31
-- Name: TYPE establishmentmeans_dwc; Type: COMMENT; Schema: public; Owner: bien
32
--
33

  
34
COMMENT ON TYPE establishmentmeans_dwc IS 'See http://rs.tdwg.org/dwc/terms/#establishmentMeans';
35

  
36

  
37
--
38
-- Name: growthform; Type: TYPE; Schema: public; Owner: bien
39
--
40

  
41
CREATE TYPE growthform AS ENUM (
42
    'tree',
43
    'shrub',
44
    'liana',
45
    'vine',
46
    'herb',
47
    'hemiepiphyte',
48
    'epiphyte',
49
    'grass',
50
    'forb',
51
    'moss',
52
    'lichen',
53
    'fungus',
54
    'floating aquatic',
55
    'submerged aquatic'
56
);
57

  
58

  
59
ALTER TYPE public.growthform OWNER TO bien;
60

  
61
--
62
-- Name: occurrencestatus_dwc; Type: TYPE; Schema: public; Owner: bien
63
--
64

  
65
CREATE TYPE occurrencestatus_dwc AS ENUM (
66
    'present',
67
    'absent',
68
    'common',
69
    'irregular',
70
    'rare',
71
    'doubtful'
72
);
73

  
74

  
75
ALTER TYPE public.occurrencestatus_dwc OWNER TO bien;
76

  
77
--
78
-- Name: placerank; Type: TYPE; Schema: public; Owner: bien
79
--
80

  
81
CREATE TYPE placerank AS ENUM (
82
    'continent',
83
    'country',
84
    'stateProvince',
85
    'county',
86
    'municipality',
87
    'village',
88
    'site',
89
    'territory',
90
    'region',
91
    'waterBody',
92
    'island',
93
    'islandGroup'
94
);
95

  
96

  
97
ALTER TYPE public.placerank OWNER TO bien;
98

  
99
--
100
-- Name: TYPE placerank; Type: COMMENT; Schema: public; Owner: bien
101
--
102

  
103
COMMENT ON TYPE placerank IS 'county = parish, canton
104
municipality = city
105
';
106

  
107

  
108
--
109
-- Name: rankedplacename; Type: TYPE; Schema: public; Owner: bien
110
--
111

  
112
CREATE TYPE rankedplacename AS (
113
	rank placerank,
114
	verbatimrank text,
115
	placename text
116
);
117

  
118

  
119
ALTER TYPE public.rankedplacename OWNER TO bien;
120

  
121
--
122
-- Name: taxonrank; Type: TYPE; Schema: public; Owner: bien
123
--
124

  
125
CREATE TYPE taxonrank AS ENUM (
126
    'unknown',
127
    'suprageneric',
128
    'domain',
129
    'superkingdom',
130
    'kingdom',
131
    'subkingdom',
132
    'infrakingdom',
133
    'superphylum',
134
    'phylum',
135
    'subphylum',
136
    'infraphylum',
137
    'superclass',
138
    'class',
139
    'subclass',
140
    'infraclass',
141
    'superorder',
142
    'order',
143
    'suborder',
144
    'infraorder',
145
    'family group',
146
    'superfamily',
147
    'family',
148
    'subfamily',
149
    'infrafamily',
150
    'family subdivision',
151
    'supertribe',
152
    'tribe',
153
    'subtribe',
154
    'infratribe',
155
    'genus group',
156
    'genus',
157
    'subgenus',
158
    'infragenus',
159
    'genus subdivision',
160
    'section',
161
    'subsection',
162
    'series',
163
    'subseries',
164
    'infrageneric',
165
    'species aggregate',
166
    'species group',
167
    'species',
168
    'subspecies',
169
    'subspecific aggregate',
170
    'below subspecies',
171
    'infraspecies',
172
    'biovariety',
173
    'pathovariety',
174
    'variety',
175
    'subvariety',
176
    'subsubvariety',
177
    'forma',
178
    'subforma',
179
    'subsubforma',
180
    'special forma',
181
    'infraspecific',
182
    'candidate',
183
    'cultivated plants',
184
    'cultivar',
185
    'convar',
186
    'grex',
187
    'cultivar group',
188
    'graft-chimaera',
189
    'denomination class'
190
);
191

  
192

  
193
ALTER TYPE public.taxonrank OWNER TO bien;
194

  
195
--
196
-- Name: TYPE taxonrank; Type: COMMENT; Schema: public; Owner: bien
197
--
198

  
199
COMMENT ON TYPE taxonrank IS 'From <http://vegbank.org/vegbank/views/dba_fielddescription_detail.jsp?view=detail&wparam=1263&entity=dba_fielddescription&params=1263>';
200

  
201

  
202
--
203
-- Name: rankedtaxonname; Type: TYPE; Schema: public; Owner: bien
204
--
205

  
206
CREATE TYPE rankedtaxonname AS (
207
	rank taxonrank,
208
	verbatimrank text,
209
	taxonname text
210
);
211

  
212

  
213
ALTER TYPE public.rankedtaxonname OWNER TO bien;
214

  
215
--
216
-- Name: role; Type: TYPE; Schema: public; Owner: bien
217
--
218

  
219
CREATE TYPE role AS ENUM (
220
    'unknown',
221
    'collector',
222
    'identifier',
223
    'computer',
224
    'contributor'
225
);
226

  
227

  
228
ALTER TYPE public.role OWNER TO bien;
229

  
230
--
231
-- Name: taxonclass; Type: TYPE; Schema: public; Owner: bien
232
--
233

  
234
CREATE TYPE taxonclass AS ENUM (
235
    'tree',
236
    'shrub',
237
    'liana',
238
    'vine',
239
    'herb',
240
    'hemiepiphyte',
241
    'epiphyte',
242
    'grass',
243
    'forb',
244
    'moss',
245
    'lichen',
246
    'fungus',
247
    'floating aquatic',
248
    'submerged aquatic',
249
    'cultivated',
250
    'wild',
251
    'native',
252
    'exotic',
253
    'invasive',
254
    'escaped from captivity',
255
    'dominant',
256
    'vascular',
257
    'woody'
258
);
259

  
260

  
261
ALTER TYPE public.taxonclass OWNER TO bien;
262

  
263
--
264
-- Name: TYPE taxonclass; Type: COMMENT; Schema: public; Owner: bien
265
--
266

  
267
COMMENT ON TYPE taxonclass IS '= growthform + establishmentmeans_dwc + some others';
268

  
269

  
270
--
271
-- Name: _set_canon_taxonconcept(integer, integer, double precision); Type: FUNCTION; Schema: public; Owner: bien
272
--
273

  
274
CREATE FUNCTION _set_canon_taxonconcept(taxonconcept_id integer, canon_concept_id integer, canon_concept_fit_fraction double precision DEFAULT NULL::double precision) RETURNS integer
275
    LANGUAGE sql
276
    AS $_$
277
UPDATE taxonconcept SET
278
  canon_concept_id = $2
279
, canon_concept_fit_fraction = $3
280
WHERE taxonconcept_id = $1
281
RETURNING taxonconcept_id
282
$_$;
283

  
284

  
285
ALTER FUNCTION public._set_canon_taxonconcept(taxonconcept_id integer, canon_concept_id integer, canon_concept_fit_fraction double precision) OWNER TO bien;
286

  
287
--
288
-- Name: make_analytical_db(); Type: FUNCTION; Schema: public; Owner: bien
289
--
290

  
291
CREATE FUNCTION make_analytical_db() RETURNS void
292
    LANGUAGE sql
293
    AS $$CREATE TABLE analytical_db AS SELECT * FROM analytical_db_view$$;
294

  
295

  
296
ALTER FUNCTION public.make_analytical_db() OWNER TO bien;
297

  
298
--
299
-- Name: party_creator_id_self_ref(); Type: FUNCTION; Schema: public; Owner: bien
300
--
301

  
302
CREATE FUNCTION party_creator_id_self_ref() RETURNS trigger
303
    LANGUAGE plpgsql
304
    AS $$
305
BEGIN
306
    IF new.party_id IS NULL THEN -- prepopulate party_id
307
        new.party_id = nextval('party_party_id_seq'::regclass);
308
    END IF;
309
    IF new.creator_id = 0 THEN -- make self-reference
310
        new.creator_id = new.party_id;
311
    END IF;
312
    RETURN new;
313
END;
314
$$;
315

  
316

  
317
ALTER FUNCTION public.party_creator_id_self_ref() OWNER TO bien;
318

  
319
--
320
-- Name: place_update_ancestors(); Type: FUNCTION; Schema: public; Owner: bien
321
--
322

  
323
CREATE FUNCTION place_update_ancestors() RETURNS trigger
324
    LANGUAGE plpgsql
325
    AS $$
326
BEGIN
327
    -- Delete existing ancestors
328
    DELETE FROM place_ancestor WHERE place_id = new.place_id;
329
    
330
    IF new.parent_id IS NOT NULL THEN
331
        -- Copy parent's ancestors to this node's ancestors
332
        INSERT
333
        INTO place_ancestor
334
        (place_id, ancestor_id)
335
        SELECT
336
            new.place_id, ancestor_id
337
        FROM place_ancestor
338
        WHERE place_id = new.parent_id
339
        ;
340
    END IF;
341
    
342
    -- Add "ancestor" for this node
343
    /* This is useful for queries, because you don't have to separately test if
344
    the leaf node is the one you're looking for, in addition to that leaf node's
345
    ancestors. */
346
    INSERT
347
    INTO place_ancestor
348
    (place_id, ancestor_id)
349
    VALUES (new.place_id, new.place_id)
350
    ;
351
    
352
    -- Tell immediate children to update their ancestors lists, which will
353
    -- recursively tell all descendants
354
    UPDATE place
355
    SET place_id = place_id -- need at least one SET statement
356
    -- Add COALESCE() to enable using place_unique index for lookup
357
    WHERE COALESCE(parent_id, 2147483647) = new.place_id
358
    ;
359
    
360
    /* Note: We don't need an ON DELETE trigger to update the descendants'
361
    ancestors when a node is deleted, because the place.place_parent_id
362
    foreign key is set to ON DELETE CASCADE, which just removes all the
363
    descendants anyway. */
364
    
365
    RETURN new;
366
END;
367
$$;
368

  
369

  
370
ALTER FUNCTION public.place_update_ancestors() OWNER TO bien;
371

  
372
--
373
-- Name: placepath_canon_placepath_id_self_ref(); Type: FUNCTION; Schema: public; Owner: bien
374
--
375

  
376
CREATE FUNCTION placepath_canon_placepath_id_self_ref() RETURNS trigger
377
    LANGUAGE plpgsql
378
    AS $$
379
BEGIN
380
    IF new.placepath_id IS NULL THEN -- prepopulate placepath_id
381
        new.placepath_id = nextval('placepath_placepath_id_seq'::regclass);
382
    END IF;
383
    IF new.canon_placepath_id = 0 THEN -- make self-reference
384
        new.canon_placepath_id = new.placepath_id;
385
    END IF;
386
    RETURN new;
387
END;
388
$$;
389

  
390

  
391
ALTER FUNCTION public.placepath_canon_placepath_id_self_ref() OWNER TO bien;
392

  
393
--
394
-- Name: plantobservation_aggregateoccurrence_count_1(); Type: FUNCTION; Schema: public; Owner: bien
395
--
396

  
397
CREATE FUNCTION plantobservation_aggregateoccurrence_count_1() RETURNS trigger
398
    LANGUAGE plpgsql
399
    AS $$
400
BEGIN
401
    UPDATE aggregateoccurrence
402
    SET count = GREATEST(COALESCE(count, 0), 1) -- at least 1
403
    WHERE aggregateoccurrence_id = new.aggregateoccurrence_id
404
    ;
405
    RETURN new;
406
END;
407
$$;
408

  
409

  
410
ALTER FUNCTION public.plantobservation_aggregateoccurrence_count_1() OWNER TO bien;
411

  
412
--
413
-- Name: taxonconcept_canon_concept_id_self_ref(); Type: FUNCTION; Schema: public; Owner: bien
414
--
415

  
416
CREATE FUNCTION taxonconcept_canon_concept_id_self_ref() RETURNS trigger
417
    LANGUAGE plpgsql
418
    AS $$
419
BEGIN
420
    IF new.taxonconcept_id IS NULL THEN -- prepopulate taxonconcept_id
421
        new.taxonconcept_id = nextval('taxonconcept_taxonconcept_id_seq'::regclass);
422
    END IF;
423
    IF new.canon_concept_id = 0 THEN -- make self-reference
424
        new.canon_concept_id = new.taxonconcept_id;
425
    END IF;
426
    RETURN new;
427
END;
428
$$;
429

  
430

  
431
ALTER FUNCTION public.taxonconcept_canon_concept_id_self_ref() OWNER TO bien;
432

  
433
--
434
-- Name: taxonconcept_canon_concept_min_fit(); Type: FUNCTION; Schema: public; Owner: bien
435
--
436

  
437
CREATE FUNCTION taxonconcept_canon_concept_min_fit() RETURNS trigger
438
    LANGUAGE plpgsql
439
    AS $$
440
BEGIN
441
    IF new.canon_concept_id IS NOT NULL
442
        AND new.canon_concept_fit_fraction < 0.8 THEN -- insufficient match
443
        new.canon_concept_id = NULL;
444
        new.canon_concept_fit_fraction = NULL;
445
    END IF;
446
    RETURN new;
447
END;
448
$$;
449

  
450

  
451
ALTER FUNCTION public.taxonconcept_canon_concept_min_fit() OWNER TO bien;
452

  
453
--
454
-- Name: taxonconcept_update_ancestors(); Type: FUNCTION; Schema: public; Owner: bien
455
--
456

  
457
CREATE FUNCTION taxonconcept_update_ancestors() RETURNS trigger
458
    LANGUAGE plpgsql
459
    AS $$
460
BEGIN
461
    -- Delete existing ancestors
462
    DELETE FROM taxonconcept_ancestor
463
    WHERE taxonconcept_id = new.taxonconcept_id;
464
    
465
    IF new.parent_id IS NOT NULL THEN
466
        -- Copy parent's ancestors to this node's ancestors
467
        INSERT
468
        INTO taxonconcept_ancestor
469
        (taxonconcept_id, ancestor_id)
470
        SELECT
471
            new.taxonconcept_id, ancestor_id
472
        FROM taxonconcept_ancestor
473
        WHERE taxonconcept_id = new.parent_id
474
        ;
475
    END IF;
476
    
477
    -- Add "ancestor" for this node
478
    /* This is useful for queries, because you don't have to separately test if
479
    the leaf node is the one you're looking for, in addition to that leaf node's
480
    ancestors. */
481
    INSERT
482
    INTO taxonconcept_ancestor
483
    (taxonconcept_id, ancestor_id)
484
    VALUES (new.taxonconcept_id, new.taxonconcept_id)
485
    ;
486
    
487
    -- Tell immediate children to update their ancestors lists, which will
488
    -- recursively tell all descendants
489
    UPDATE taxonconcept
490
    SET taxonconcept_id = taxonconcept_id -- need at least one SET statement
491
    -- Add COALESCE() to enable using taxonconcept_unique index for lookup
492
    WHERE COALESCE(parent_id, 2147483647) = new.taxonconcept_id
493
    ;
494
    
495
    /* Note: We don't need an ON DELETE trigger to update the descendants'
496
    ancestors when a node is deleted, because the taxonconcept.parent_id foreign
497
    key is ON DELETE CASCADE, which just removes all the descendants anyway. */
498
    
499
    RETURN new;
500
END;
501
$$;
502

  
503

  
504
ALTER FUNCTION public.taxonconcept_update_ancestors() OWNER TO bien;
505

  
506
--
507
-- Name: concat(text); Type: AGGREGATE; Schema: public; Owner: bien
508
--
509

  
510
CREATE AGGREGATE concat(text) (
511
    SFUNC = textcat,
512
    STYPE = text,
513
    INITCOND = ''
514
);
515

  
516

  
517
ALTER AGGREGATE public.concat(text) OWNER TO bien;
518

  
519
SET default_tablespace = '';
520

  
521
SET default_with_oids = false;
522

  
523
--
524
-- Name: address; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
525
--
526

  
527
CREATE TABLE address (
528
    address_id integer NOT NULL,
529
    party_id integer NOT NULL,
530
    organization_id integer,
531
    orgposition text,
532
    email text,
533
    deliverypoint text,
534
    city text,
535
    administrativearea text,
536
    postalcode text,
537
    country text,
538
    currentflag boolean,
539
    addressstartdate timestamp with time zone
540
);
541

  
542

  
543
ALTER TABLE public.address OWNER TO bien;
544

  
545
--
546
-- Name: address_address_id_seq; Type: SEQUENCE; Schema: public; Owner: bien
547
--
548

  
549
CREATE SEQUENCE address_address_id_seq
550
    START WITH 1
551
    INCREMENT BY 1
552
    NO MINVALUE
553
    NO MAXVALUE
554
    CACHE 1;
555

  
556

  
557
ALTER TABLE public.address_address_id_seq OWNER TO bien;
558

  
559
--
560
-- Name: address_address_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bien
561
--
562

  
563
ALTER SEQUENCE address_address_id_seq OWNED BY address.address_id;
564

  
565

  
566
--
567
-- Name: address_address_id_seq; Type: SEQUENCE SET; Schema: public; Owner: bien
568
--
569

  
570
SELECT pg_catalog.setval('address_address_id_seq', 1, false);
571

  
572

  
573
--
574
-- Name: aggregateoccurrence; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
575
--
576

  
577
CREATE TABLE aggregateoccurrence (
578
    aggregateoccurrence_id integer NOT NULL,
579
    creator_id integer NOT NULL,
580
    sourceaccessioncode text,
581
    taxonoccurrence_id integer NOT NULL,
582
    collectiondate timestamp with time zone,
583
    cover_fraction double precision,
584
    linecover_m double precision,
585
    basalarea_m2 double precision,
586
    biomass_kg_m2 double precision,
587
    inferencearea_m2 double precision,
588
    count integer,
589
    stratum_id integer,
590
    coverindex_id integer,
591
    occurrencestatus_dwc occurrencestatus_dwc DEFAULT 'present'::occurrencestatus_dwc NOT NULL,
592
    method_id integer,
593
    notes text,
594
    accessioncode text
595
);
596

  
597

  
598
ALTER TABLE public.aggregateoccurrence OWNER TO bien;
599

  
600
--
601
-- Name: TABLE aggregateoccurrence; Type: COMMENT; Schema: public; Owner: bien
602
--
603

  
604
COMMENT ON TABLE aggregateoccurrence IS 'Equivalent to VegBank''s taxonimportance table.';
605

  
606

  
607
--
608
-- Name: COLUMN aggregateoccurrence.linecover_m; Type: COMMENT; Schema: public; Owner: bien
609
--
610

  
611
COMMENT ON COLUMN aggregateoccurrence.linecover_m IS 'The distance in m along which this occurrence intercepts a line subplot.';
612

  
613

  
614
--
615
-- Name: COLUMN aggregateoccurrence.occurrencestatus_dwc; Type: COMMENT; Schema: public; Owner: bien
616
--
617

  
618
COMMENT ON COLUMN aggregateoccurrence.occurrencestatus_dwc IS 'The extent to which the taxon is present. See <http://code.google.com/p/darwincore/wiki/Occurrence#occurrenceStatus>.';
619

  
620

  
621
--
622
-- Name: aggregateoccurrence_aggregateoccurrence_id_seq; Type: SEQUENCE; Schema: public; Owner: bien
623
--
624

  
625
CREATE SEQUENCE aggregateoccurrence_aggregateoccurrence_id_seq
626
    START WITH 1
627
    INCREMENT BY 1
628
    NO MINVALUE
629
    NO MAXVALUE
630
    CACHE 1;
631

  
632

  
633
ALTER TABLE public.aggregateoccurrence_aggregateoccurrence_id_seq OWNER TO bien;
634

  
635
--
636
-- Name: aggregateoccurrence_aggregateoccurrence_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: bien
637
--
638

  
639
ALTER SEQUENCE aggregateoccurrence_aggregateoccurrence_id_seq OWNED BY aggregateoccurrence.aggregateoccurrence_id;
640

  
641

  
642
--
643
-- Name: aggregateoccurrence_aggregateoccurrence_id_seq; Type: SEQUENCE SET; Schema: public; Owner: bien
644
--
645

  
646
SELECT pg_catalog.setval('aggregateoccurrence_aggregateoccurrence_id_seq', 1, false);
647

  
648

  
649
--
650
-- Name: location; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
651
--
652

  
653
CREATE TABLE location (
654
    location_id integer NOT NULL,
655
    creator_id integer NOT NULL,
656
    sourceaccessioncode text,
657
    parent_id integer,
658
    authorlocationcode text,
659
    confidentialitystatus integer DEFAULT 0 NOT NULL,
660
    confidentialityreason text,
661
    sublocationxposition_m double precision,
662
    sublocationyposition_m double precision,
663
    authorzone text,
664
    authordatum text,
665
    authorlocation text,
666
    locationnarrative text,
667
    azimuth double precision,
668
    shape text,
669
    area_m2 double precision,
670
    standsize text,
671
    placementmethod text,
672
    permanence boolean,
673
    layoutnarrative text,
674
    elevation_m double precision,
675
    elevationaccuracy_m double precision,
676
    elevationrange_m double precision,
677
    verbatimelevation text,
678
    slopeaspect_deg double precision,
679
    minslopeaspect_deg double precision,
680
    maxslopeaspect_deg double precision,
681
    slopegradient_fraction double precision,
682
    minslopegradient_fraction double precision,
683
    maxslopegradient_fraction double precision,
684
    topoposition text,
685
    landform text,
686
    surficialdeposits text,
687
    rocktype text,
688
    submitter_surname text,
689
    submitter_givenname text,
690
    submitter_email text,
691
    notespublic boolean,
692
    notesmgt boolean,
693
    revisions boolean,
694
    dateentered timestamp with time zone DEFAULT now(),
695
    locationrationalenarrative text,
696
    accessioncode text,
697
    CONSTRAINT location_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (authorlocationcode IS NOT NULL)))
698
);
699

  
700

  
701
ALTER TABLE public.location OWNER TO bien;
702

  
703
--
704
-- Name: TABLE location; Type: COMMENT; Schema: public; Owner: bien
705
--
706

  
707
COMMENT ON TABLE location IS 'Equivalent to VegBank''s plot table.';
708

  
709

  
710
--
711
-- Name: locationcoords; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
712
--
713

  
714
CREATE TABLE locationcoords (
715
    locationcoords_id integer NOT NULL,
716
    location_id integer NOT NULL,
717
    latitude_deg double precision,
718
    longitude_deg double precision,
719
    verbatimlatitude text,
720
    verbatimlongitude text,
721
    verbatimcoordinates text,
722
    footprintgeometry_dwc text,
723
    coordsaccuracy_deg double precision,
724
    identifier_id integer,
725
    determinationdate timestamp with time zone,
726
    isoriginal boolean DEFAULT false NOT NULL,
727
    iscurrent boolean DEFAULT false NOT NULL,
728
    calculated boolean
729
);
730

  
731

  
732
ALTER TABLE public.locationcoords OWNER TO bien;
733

  
734
--
735
-- Name: COLUMN locationcoords.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: bien
736
--
737

  
738
COMMENT ON COLUMN locationcoords.footprintgeometry_dwc IS 'DwC''s footprintWKT field. "A Well-Known Text (WKT) representation of the shape (footprint, geometry) that defines the Location" (http://rs.tdwg.org/dwc/terms/#footprintWKT).';
739

  
740

  
741
--
742
-- Name: COLUMN locationcoords.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: bien
743
--
744

  
745
COMMENT ON COLUMN locationcoords.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.';
746

  
747

  
748
--
749
-- Name: locationevent; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
750
--
751

  
752
CREATE TABLE locationevent (
753
    locationevent_id integer NOT NULL,
754
    creator_id integer NOT NULL,
755
    sourceaccessioncode text,
756
    parent_id integer,
757
    location_id integer,
758
    project_id integer,
759
    authoreventcode text,
760
    previous_id integer,
761
    dateaccuracy text,
762
    method_id integer,
763
    temperature_c double precision,
764
    precipitation_m double precision,
765
    autotaxoncover boolean,
766
    originaldata text,
767
    effortlevel text,
768
    floristicquality text,
769
    bryophytequality text,
770
    lichenquality text,
771
    locationeventnarrative text,
772
    landscapenarrative text,
773
    homogeneity text,
774
    phenologicaspect text,
775
    representativeness text,
776
    standmaturity text,
777
    successionalstatus text,
778
    basalarea double precision,
779
    hydrologicregime text,
780
    soilmoistureregime text,
781
    soildrainage text,
782
    watersalinity text,
783
    waterdepth_m double precision,
784
    shoredistance double precision,
785
    soildepth double precision,
786
    organicdepth double precision,
787
    soiltaxon_id integer,
788
    soiltaxonsrc text,
789
    percentbedrock double precision,
790
    percentrockgravel double precision,
791
    percentwood double precision,
792
    percentlitter double precision,
793
    percentbaresoil double precision,
794
    percentwater double precision,
795
    percentother double precision,
796
    nameother text,
797
    treeht double precision,
798
    shrubht double precision,
799
    fieldht double precision,
800
    nonvascularht double precision,
801
    submergedht double precision,
802
    treecover double precision,
803
    shrubcover double precision,
804
    fieldcover double precision,
805
    nonvascularcover double precision,
806
    floatingcover double precision,
807
    submergedcover double precision,
808
    dominantstratum text,
809
    growthform1type text,
810
    growthform2type text,
811
    growthform3type text,
812
    growthform1cover double precision,
813
    growthform2cover double precision,
814
    growthform3cover double precision,
815
    totalcover double precision,
816
    notespublic boolean,
817
    notesmgt boolean,
818
    revisions boolean,
819
    obsstartdate timestamp with time zone,
820
    obsenddate timestamp with time zone,
821
    dateentered timestamp with time zone DEFAULT now(),
822
    toptaxon1name text,
823
    toptaxon2name text,
824
    toptaxon3name text,
825
    toptaxon4name text,
826
    toptaxon5name text,
827
    numberoftaxa integer,
828
    accessioncode text,
829
    CONSTRAINT locationevent_required_key CHECK (((sourceaccessioncode IS NOT NULL) OR (location_id IS NOT NULL)))
830
);
831

  
832

  
833
ALTER TABLE public.locationevent OWNER TO bien;
834

  
835
--
836
-- Name: TABLE locationevent; Type: COMMENT; Schema: public; Owner: bien
837
--
838

  
839
COMMENT ON TABLE locationevent IS 'Equivalent to VegBank''s observation table.';
840

  
841

  
842
--
843
-- Name: locationplace; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
844
--
845

  
846
CREATE TABLE locationplace (
847
    locationplace_id integer NOT NULL,
848
    location_id integer NOT NULL,
849
    placepath_id integer NOT NULL,
850
    identifier_id integer
851
);
852

  
853

  
854
ALTER TABLE public.locationplace OWNER TO bien;
855

  
856
--
857
-- Name: TABLE locationplace; Type: COMMENT; Schema: public; Owner: bien
858
--
859

  
860
COMMENT ON TABLE locationplace IS 'Equivalent to VegBank''s place table.';
861

  
862

  
863
--
864
-- Name: method; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
865
--
866

  
867
CREATE TABLE method (
868
    method_id integer NOT NULL,
869
    reference_id integer,
870
    name text NOT NULL,
871
    description text,
872
    diameterheight_m double precision,
873
    mindiameter_m double precision,
874
    maxdiameter_m double precision,
875
    minheight_m double precision,
876
    maxheight_m double precision,
877
    observationtype text,
878
    observationmeasure text,
879
    covermethod_id integer,
880
    samplingfactor double precision DEFAULT 1 NOT NULL,
881
    coverbasis text,
882
    stemsamplemethod text,
883
    shape text,
884
    length_m double precision,
885
    width_m double precision,
886
    radius_m double precision,
887
    area_m2 double precision,
888
    samplearea_m2 double precision,
889
    subplotspacing_m double precision,
890
    subplotmethod_id integer,
891
    pointsperline integer,
892
    accessioncode text
893
);
894

  
895

  
896
ALTER TABLE public.method OWNER TO bien;
897

  
898
--
899
-- Name: TABLE method; Type: COMMENT; Schema: public; Owner: bien
900
--
901

  
902
COMMENT ON TABLE method IS 'A method for sampling and aggregating plants. Replaces VegBank''s stratummethod and stratumtype tables.
903

  
904
Important: *All* length- or area-related measurements throughout VegBIEN must be converted to SI base units, e.g. cm -> m, ha -> m^2.**';
905

  
906

  
907
--
908
-- Name: COLUMN method.reference_id; Type: COMMENT; Schema: public; Owner: bien
909
--
910

  
911
COMMENT ON COLUMN method.reference_id IS 'Use the reference table (e.g. reference.url) to store a link to the original plain text description.';
912

  
913

  
914
--
915
-- Name: COLUMN method.name; Type: COMMENT; Schema: public; Owner: bien
916
--
917

  
918
COMMENT ON COLUMN method.name IS 'A short name for the set of methods used. Although there is no existing standard, many names are widely used, and could be useful for finding plots with similar methodology.';
919

  
920

  
921
--
922
-- Name: COLUMN method.description; Type: COMMENT; Schema: public; Owner: bien
923
--
924

  
925
COMMENT ON COLUMN method.description IS 'Additional metadata helpful for understanding how the data were collected during the observation event.';
926

  
927

  
928
--
929
-- Name: COLUMN method.diameterheight_m; Type: COMMENT; Schema: public; Owner: bien
930
--
931

  
932
COMMENT ON COLUMN method.diameterheight_m IS 'The height in m at which the diameter is measured. e.g. 1.37 m for breast height (DBH).';
933

  
934

  
935
--
936
-- Name: COLUMN method.mindiameter_m; Type: COMMENT; Schema: public; Owner: bien
937
--
938

  
939
COMMENT ON COLUMN method.mindiameter_m IS 'Lower diameter limit in m for inclusion of a tree.';
940

  
941

  
942
--
943
-- Name: COLUMN method.maxdiameter_m; Type: COMMENT; Schema: public; Owner: bien
944
--
945

  
946
COMMENT ON COLUMN method.maxdiameter_m IS 'Upper diameter limit in m for inclusion of a tree.';
947

  
948

  
949
--
950
-- Name: COLUMN method.minheight_m; Type: COMMENT; Schema: public; Owner: bien
951
--
952

  
953
COMMENT ON COLUMN method.minheight_m IS 'Lower height limit in m for inclusion of a tree.';
954

  
955

  
956
--
957
-- Name: COLUMN method.maxheight_m; Type: COMMENT; Schema: public; Owner: bien
958
--
959

  
960
COMMENT ON COLUMN method.maxheight_m IS 'Upper height limit in m for inclusion of a tree.';
961

  
962

  
963
--
964
-- Name: COLUMN method.observationtype; Type: COMMENT; Schema: public; Owner: bien
965
--
966

  
967
COMMENT ON COLUMN method.observationtype IS 'values: aggregate, individual, both';
968

  
969

  
970
--
971
-- Name: COLUMN method.observationmeasure; Type: COMMENT; Schema: public; Owner: bien
972
--
973

  
974
COMMENT ON COLUMN method.observationmeasure IS 'e.g. count, cover, presence, points-intercepted, distance-intercepted';
975

  
976

  
977
--
978
-- Name: COLUMN method.samplingfactor; Type: COMMENT; Schema: public; Owner: bien
979
--
980

  
981
COMMENT ON COLUMN method.samplingfactor IS 'Here, we could explicitly say that we are sampling a particular area by a different size representative sample area. Simply divide the number of plants connected to this record by this value to get the extrapolated (or interpolated) number of plants in the area in question. This explicitly notes a subsample or supersample.';
982

  
983

  
984
--
985
-- Name: COLUMN method.coverbasis; Type: COMMENT; Schema: public; Owner: bien
986
--
987

  
988
COMMENT ON COLUMN method.coverbasis IS 'Were cover values for the total taxon list collected from one contiguous area or dispersed subplots?
989

  
990
entire: Cover based on observation of an entire plot consisting of a single contiguous area of land. subplot-contiguous: Cover based on observation of a single contiguous area of land of less spatial extent than the entire plot.
991

  
992
subplot-regular: Cover based on observation of multiple subplots arranged in a regular pattern within the overall plot.
993

  
994
subplot-random: Cover based on observation of multiple randomly dispersed subplots within the overall plot.
995

  
996
subplot-haphazard: Cover based on observation of multiple subplots haphazardly arranged within the overall plot.
997

  
998
line-intercept: Cover based on length of line touching each species present.
999

  
1000
point-intercept: Cover based on number of points for each species present.
1001
';
1002

  
1003

  
1004
--
1005
-- Name: COLUMN method.stemsamplemethod; Type: COMMENT; Schema: public; Owner: bien
1006
--
1007

  
1008
COMMENT ON COLUMN method.stemsamplemethod IS 'The method used to obtain basal area or tree stem data (e.g., full census, point quarter, random pairs, Bitterlich, other).
1009

  
1010
e.g.:
1011
Full census
1012
Point quarter
1013
Random pairs
1014
Bitterlich
1015
Other
1016
Subsample census';
1017

  
1018

  
1019
--
1020
-- Name: COLUMN method.shape; Type: COMMENT; Schema: public; Owner: bien
1021
--
1022

  
1023
COMMENT ON COLUMN method.shape IS 'e.g. square, rectangle, circle, line, point, other';
1024

  
1025

  
1026
--
1027
-- Name: COLUMN method.samplearea_m2; Type: COMMENT; Schema: public; Owner: bien
1028
--
1029

  
1030
COMMENT ON COLUMN method.samplearea_m2 IS 'The total surface area used for cover estimates and for which a complete species list is provided. If subplots were used, this would be the total area of the subplots without interstitial space.';
1031

  
1032

  
1033
--
1034
-- Name: COLUMN method.subplotspacing_m; Type: COMMENT; Schema: public; Owner: bien
1035
--
1036

  
1037
COMMENT ON COLUMN method.subplotspacing_m IS 'Spacing in m between adjacent subplots, lines (line-intercept data), or points (point-intercept data).';
1038

  
1039

  
1040
--
1041
-- Name: COLUMN method.subplotmethod_id; Type: COMMENT; Schema: public; Owner: bien
1042
--
1043

  
1044
COMMENT ON COLUMN method.subplotmethod_id IS 'Method to use for each subplot/line/point, which will specify subplot size, line length, etc.';
1045

  
1046

  
1047
--
1048
-- Name: COLUMN method.pointsperline; Type: COMMENT; Schema: public; Owner: bien
1049
--
1050

  
1051
COMMENT ON COLUMN method.pointsperline IS 'The number of points sampled on each line subplot for point-intercept data.';
1052

  
1053

  
1054
--
1055
-- Name: party; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
1056
--
1057

  
1058
CREATE TABLE party (
1059
    party_id integer NOT NULL,
1060
    creator_id integer NOT NULL,
1061
    salutation text,
1062
    givenname text,
1063
    middlename text,
1064
    surname text,
1065
    organizationname text,
1066
    currentname_id integer,
1067
    contactinstructions text,
1068
    email text,
1069
    partytype text,
1070
    partypublic boolean DEFAULT true,
1071
    d_obscount integer,
1072
    accessioncode text,
1073
    CONSTRAINT party_required_key CHECK (((organizationname IS NOT NULL) OR ((creator_id <> party_id) AND (surname IS NOT NULL))))
1074
);
1075

  
1076

  
1077
ALTER TABLE public.party OWNER TO bien;
1078

  
1079
--
1080
-- Name: COLUMN party.creator_id; Type: COMMENT; Schema: public; Owner: bien
1081
--
1082

  
1083
COMMENT ON COLUMN party.creator_id IS 'A datasource should point to itself in this field. This will happen automatically by setting it to the special value 0.';
1084

  
1085

  
1086
--
1087
-- Name: placepath; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
1088
--
1089

  
1090
CREATE TABLE placepath (
1091
    placepath_id integer NOT NULL,
1092
    creator_id integer NOT NULL,
1093
    placecode text,
1094
    canon_placepath_id integer,
1095
    place_id integer,
1096
    continent text,
1097
    country text,
1098
    stateprovince text,
1099
    county text,
1100
    municipality text,
1101
    site text,
1102
    otherranks rankedplacename[],
1103
    CONSTRAINT placepath_required_key CHECK (((((((placecode IS NOT NULL) OR (continent IS NOT NULL)) OR (country IS NOT NULL)) OR (stateprovince IS NOT NULL)) OR (county IS NOT NULL)) OR (otherranks IS NOT NULL)))
1104
);
1105

  
1106

  
1107
ALTER TABLE public.placepath OWNER TO bien;
1108

  
1109
--
1110
-- Name: TABLE placepath; Type: COMMENT; Schema: public; Owner: bien
1111
--
1112

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

  
1115
To include a placename at a rank with no explicit column, add it to the otherranks array.';
1116

  
1117

  
1118
--
1119
-- Name: COLUMN placepath.canon_placepath_id; Type: COMMENT; Schema: public; Owner: bien
1120
--
1121

  
1122
COMMENT ON COLUMN placepath.canon_placepath_id IS 'The placepath containing the accepted name of this verbatim place path.  placepaths should be linked in a two-level hierarchy of datasource name -> accepted name.
1123

  
1124
A accepted name should point to itself in this field. This will happen automatically by setting it to the special value 0.';
1125

  
1126

  
1127
--
1128
-- Name: COLUMN placepath.otherranks; Type: COMMENT; Schema: public; Owner: bien
1129
--
1130

  
1131
COMMENT ON COLUMN placepath.otherranks IS 'Additional ranks which do not have a named column. Put ranks in path order, so that lower-level places come after higher-level places.';
1132

  
1133

  
1134
--
1135
-- Name: plantobservation; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
1136
--
1137

  
1138
CREATE TABLE plantobservation (
1139
    plantobservation_id integer NOT NULL,
1140
    creator_id integer NOT NULL,
1141
    sourceaccessioncode text,
1142
    aggregateoccurrence_id integer NOT NULL,
1143
    overallheight_m double precision,
1144
    overallheightaccuracy_m double precision,
1145
    collectionnumber text,
1146
    stemcount integer,
1147
    plant_id integer,
1148
    accessioncode text
1149
);
1150

  
1151

  
1152
ALTER TABLE public.plantobservation OWNER TO bien;
1153

  
1154
--
1155
-- Name: TABLE plantobservation; Type: COMMENT; Schema: public; Owner: bien
1156
--
1157

  
1158
COMMENT ON TABLE plantobservation IS 'Equivalent to VegBank''s stemcount table.';
1159

  
1160

  
1161
--
1162
-- Name: COLUMN plantobservation.collectionnumber; Type: COMMENT; Schema: public; Owner: bien
1163
--
1164

  
1165
COMMENT ON COLUMN plantobservation.collectionnumber IS 'The number of the organism within the data collection or event.';
1166

  
1167

  
1168
--
1169
-- Name: specimenreplicate; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
1170
--
1171

  
1172
CREATE TABLE specimenreplicate (
1173
    specimenreplicate_id integer NOT NULL,
1174
    creator_id integer NOT NULL,
1175
    sourceaccessioncode text,
1176
    plantobservation_id integer,
1177
    institution_id integer,
1178
    collectioncode_dwc text,
1179
    catalognumber_dwc text,
1180
    description text,
1181
    specimen_id integer,
1182
    accessioncode text,
1183
    CONSTRAINT specimenreplicate_required_key CHECK ((((plantobservation_id IS NOT NULL) OR (sourceaccessioncode IS NOT NULL)) OR (catalognumber_dwc IS NOT NULL)))
1184
);
1185

  
1186

  
1187
ALTER TABLE public.specimenreplicate OWNER TO bien;
1188

  
1189
--
1190
-- Name: TABLE specimenreplicate; Type: COMMENT; Schema: public; Owner: bien
1191
--
1192

  
1193
COMMENT ON TABLE specimenreplicate IS 'A herbarium''s replicate of a specimen. Contains Darwin Core specimen data.';
1194

  
1195

  
1196
--
1197
-- Name: COLUMN specimenreplicate.institution_id; Type: COMMENT; Schema: public; Owner: bien
1198
--
1199

  
1200
COMMENT ON COLUMN specimenreplicate.institution_id IS 'The institution (such as a museum) that the specimenreplicate is from.';
1201

  
1202

  
1203
--
1204
-- Name: COLUMN specimenreplicate.collectioncode_dwc; Type: COMMENT; Schema: public; Owner: bien
1205
--
1206

  
1207
COMMENT ON COLUMN specimenreplicate.collectioncode_dwc IS 'The code for the collection that the specimenreplicate is from.';
1208

  
1209

  
1210
--
1211
-- Name: taxonconcept; Type: TABLE; Schema: public; Owner: bien; Tablespace: 
1212
--
1213

  
1214
CREATE TABLE taxonconcept (
1215
    taxonconcept_id integer NOT NULL,
1216
    creator_id integer NOT NULL,
1217
    creationdate timestamp with time zone,
1218
    canon_concept_id integer,
1219
    canon_concept_fit_fraction double precision,
1220
    parent_id integer,
1221
    taxonname text,
1222
    rank taxonrank,
1223
    verbatimrank text,
1224
    identifyingtaxonomicname text,
1225
    taxonomicname text,
1226
    author text,
1227
    taxonomicnamewithauthor text,
1228
    family text,
1229
    genus text,
1230
    species text,
1231
    description text,
1232
    accessioncode text,
1233
    CONSTRAINT taxonconcept_canon_concept_fit_fraction_range CHECK (((canon_concept_fit_fraction >= (0)::double precision) AND (canon_concept_fit_fraction <= (1)::double precision))),
1234
    CONSTRAINT taxonconcept_required_key CHECK ((((((taxonname IS NOT NULL) OR (identifyingtaxonomicname IS NOT NULL)) OR (taxonomicname IS NOT NULL)) OR (taxonomicnamewithauthor IS NOT NULL)) OR ((parent_id IS NOT NULL) AND ((creationdate IS NOT NULL) OR (author IS NOT NULL)))))
1235
);
1236

  
1237

  
1238
ALTER TABLE public.taxonconcept OWNER TO bien;
1239

  
1240
--
1241
-- Name: TABLE taxonconcept; Type: COMMENT; Schema: public; Owner: bien
1242
--
1243

  
1244
COMMENT ON TABLE taxonconcept IS 'A taxon concept defined by an entity. Can be at any level in the taxonomic hierarchy. Can be either verbatim or accepted.
1245

  
1246
"A taxon (plural: taxa) is a group of one (or more) populations of organism(s), which a taxonomist adjudges to be a unit" (http://en.wikipedia.org/wiki/Taxon)
1247

  
1248
Note that taxonname stores only one rank (e.g. family) of the full taxonomic name. The higher-level ranks are stored in the taxon concept''s chain of parent_id ancestors.
1249

  
1250
To include a taxon name at a rank with no explicit column, create a parent taxonconcept for it and point to it using parent_id. To include multiple such names, chain the taxonconcepts together using parent_id. Note that lower-level taxa should point to higher-level taxa.
1251

  
1252
Equivalent to VegBank''s plantConcept and plantName tables, plus plantParent_ID and plantLevel from plantStatus.';
1253

  
1254

  
1255
--
1256
-- Name: COLUMN taxonconcept.creator_id; Type: COMMENT; Schema: public; Owner: bien
1257
--
1258

  
1259
COMMENT ON COLUMN taxonconcept.creator_id IS 'The entity that created the taxon concept.';
1260

  
1261

  
1262
--
1263
-- Name: COLUMN taxonconcept.creationdate; Type: COMMENT; Schema: public; Owner: bien
1264
--
1265

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

  
1268

  
1269
--
1270
-- Name: COLUMN taxonconcept.canon_concept_id; Type: COMMENT; Schema: public; Owner: bien
1271
--
1272

  
1273
COMMENT ON COLUMN taxonconcept.canon_concept_id IS 'The taxonconcept containing the accepted synonym of this taxonconcept. taxonconcepts should be linked in a four-level hierarchy of datasource concept -> parsed concept -> matched concept -> accepted concept. A previously-accepted name''s concept should be further linked to the synonym that has replaced it.
1274

  
1275
To indicate a synonym between taxonconcepts of different sources, choose one taxonconcept to be authoritative and point the other taxonconcept to it using this field.
1276

  
1277
An accepted name should point to itself in this field. This will happen automatically by setting it to the special value 0.';
1278

  
1279

  
1280
--
1281
-- Name: COLUMN taxonconcept.canon_concept_fit_fraction; Type: COMMENT; Schema: public; Owner: bien
1282
--
1283

  
1284
COMMENT ON COLUMN taxonconcept.canon_concept_fit_fraction IS 'The closeness of fit of the canon_concept.';
1285

  
1286

  
1287
--
1288
-- Name: COLUMN taxonconcept.parent_id; Type: COMMENT; Schema: public; Owner: bien
1289
--
1290

  
1291
COMMENT ON COLUMN taxonconcept.parent_id IS 'The parent taxonconcept. Note that while a taxon *name* may have multiple parents, a taxon *concept* has only one, based on the creator''s opinion of where that taxonconcept goes in the taxonomic hierarchy.';
1292

  
1293

  
1294
--
1295
-- Name: COLUMN taxonconcept.taxonname; Type: COMMENT; Schema: public; Owner: bien
1296
--
1297

  
1298
COMMENT ON COLUMN taxonconcept.taxonname IS 'The name of the taxon within its parent taxon. This is the lowest-rank portion of this taxonconcept''s full taxonomic name, if it has one.
1299

  
1300
The morphospecies suffix goes in this field.';
1301

  
1302

  
1303
--
1304
-- Name: COLUMN taxonconcept.rank; Type: COMMENT; Schema: public; Owner: bien
1305
--
1306

  
1307
COMMENT ON COLUMN taxonconcept.rank IS 'The taxonconcept''s level in the taxonomic hierarchy, standardized to a closed list. Even if you specify a custom verbatimrank, you should also specify a closest-match rank from the taxonrank closed list.';
1308

  
1309

  
1310
--
1311
-- Name: COLUMN taxonconcept.verbatimrank; Type: COMMENT; Schema: public; Owner: bien
1312
--
1313

  
1314
COMMENT ON COLUMN taxonconcept.verbatimrank IS 'The taxonconcept''s verbatim level in the taxonomic hierarchy. Does not need to be in the taxonrank closed list.';
1315

  
1316

  
1317
--
1318
-- Name: COLUMN taxonconcept.identifyingtaxonomicname; Type: COMMENT; Schema: public; Owner: bien
1319
--
1320

  
1321
COMMENT ON COLUMN taxonconcept.identifyingtaxonomicname IS 'The taxonomic name that uniquely identifies this taxonconcept. If set, the other fields will not be used in duplicate elimination.';
1322

  
1323

  
1324
--
1325
-- Name: COLUMN taxonconcept.taxonomicname; Type: COMMENT; Schema: public; Owner: bien
1326
--
1327

  
1328
COMMENT ON COLUMN taxonconcept.taxonomicname IS 'The concatenated taxonomic name which uniquely identifies this taxon. Does not include the author of the name.
1329

  
1330
Equivalent to Darwin Core''s scientificName.';
1331

  
1332

  
1333
--
1334
-- Name: COLUMN taxonconcept.author; Type: COMMENT; Schema: public; Owner: bien
1335
--
1336

  
1337
COMMENT ON COLUMN taxonconcept.author IS 'The author of the taxonomic name.
1338

  
1339
Equivalent to Darwin Core''s scientificNameAuthorship.';
1340

  
1341

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

Also available in: Unified diff