1
|
-- Existing tables
|
2
|
|
3
|
CREATE TABLE aux_role
|
4
|
(
|
5
|
role_id int(11) NOT NULL AUTO_INCREMENT,
|
6
|
rolecode character varying(30) NOT NULL,
|
7
|
roledescription character varying(200),
|
8
|
CONSTRAINT aux_role_pkey PRIMARY KEY (role_id )
|
9
|
);
|
10
|
|
11
|
CREATE TABLE reference
|
12
|
(
|
13
|
reference_id int(11) NOT NULL AUTO_INCREMENT,
|
14
|
shortname character varying(250),
|
15
|
fulltext__ text,
|
16
|
referencetype character varying(250)
|
17
|
);
|
18
|
|
19
|
CREATE TABLE party
|
20
|
(
|
21
|
party_id int(11) NOT NULL AUTO_INCREMENT,
|
22
|
salutation character varying(20),
|
23
|
givenname character varying(50),
|
24
|
middlename character varying(50),
|
25
|
surname character varying(50),
|
26
|
organizationname character varying(100)
|
27
|
);
|
28
|
|
29
|
CREATE TABLE plantname
|
30
|
(
|
31
|
plantname_id int(11) NOT NULL AUTO_INCREMENT,
|
32
|
plantname character varying(255) NOT NULL,
|
33
|
reference_id int(11),
|
34
|
dateentered timestamp DEFAULT now(),
|
35
|
CONSTRAINT plantname_pkey PRIMARY KEY (plantname_id ),
|
36
|
CONSTRAINT plantname_reference_id FOREIGN KEY (reference_id)
|
37
|
REFERENCES reference (reference_id) MATCH SIMPLE
|
38
|
ON UPDATE CASCADE ON DELETE CASCADE
|
39
|
);
|
40
|
|
41
|
CREATE TABLE plantconcept
|
42
|
(
|
43
|
plantconcept_id int(11) NOT NULL AUTO_INCREMENT,
|
44
|
plantname_id int(11) NOT NULL,
|
45
|
reference_id int(11) NOT NULL,
|
46
|
plantname character varying(200),
|
47
|
plantcode character varying(23),
|
48
|
plantdescription text,
|
49
|
d_obscount int(11),
|
50
|
d_currentaccepted int(1),
|
51
|
accessioncode character varying(255),
|
52
|
CONSTRAINT plantconcept_pkey PRIMARY KEY (plantconcept_id ),
|
53
|
CONSTRAINT plantconcept_plantname_id FOREIGN KEY (plantname_id)
|
54
|
REFERENCES plantname (plantname_id) MATCH SIMPLE
|
55
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
56
|
CONSTRAINT plantconcept_reference_id FOREIGN KEY (reference_id)
|
57
|
REFERENCES reference (reference_id) MATCH SIMPLE
|
58
|
ON UPDATE CASCADE ON DELETE CASCADE
|
59
|
);
|
60
|
|
61
|
CREATE TABLE namedplace
|
62
|
(
|
63
|
namedplace_id int(11) NOT NULL AUTO_INCREMENT,
|
64
|
placesystem character varying(50),
|
65
|
placename character varying(100) NOT NULL,
|
66
|
placedescription text,
|
67
|
placecode character varying(15),
|
68
|
owner character varying(100),
|
69
|
reference_id int(11),
|
70
|
d_obscount int(11),
|
71
|
accessioncode character varying(255),
|
72
|
CONSTRAINT namedplace_pkey PRIMARY KEY (namedplace_id ),
|
73
|
CONSTRAINT namedplace_reference_id FOREIGN KEY (reference_id)
|
74
|
REFERENCES reference (reference_id) MATCH SIMPLE
|
75
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
76
|
CONSTRAINT namedplace_keys UNIQUE (placesystem , placename )
|
77
|
);
|
78
|
|
79
|
CREATE TABLE project
|
80
|
(
|
81
|
project_id int(11) NOT NULL AUTO_INCREMENT,
|
82
|
projectname character varying(150) NOT NULL,
|
83
|
projectdescription text,
|
84
|
startdate timestamp,
|
85
|
stopdate timestamp,
|
86
|
d_obscount int(11),
|
87
|
d_lastlocationaddeddate timestamp,
|
88
|
accessioncode character varying(255),
|
89
|
CONSTRAINT project_pkey PRIMARY KEY (project_id ),
|
90
|
CONSTRAINT project_keys UNIQUE (projectname , startdate , stopdate )
|
91
|
);
|
92
|
|
93
|
-- New tables
|
94
|
|
95
|
CREATE TABLE location
|
96
|
(
|
97
|
location_id int(11) NOT NULL AUTO_INCREMENT,
|
98
|
sourceid character varying(30),
|
99
|
reference_id int(11),
|
100
|
parent_id int(11),
|
101
|
reallatitude double precision,
|
102
|
reallongitude double precision,
|
103
|
locationaccuracy double precision,
|
104
|
confidentialitystatus int(11) NOT NULL,
|
105
|
confidentialityreason character varying(200),
|
106
|
latitude double precision,
|
107
|
longitude double precision,
|
108
|
-- ...
|
109
|
accessioncode character varying(255),
|
110
|
sublocationxposition double precision,
|
111
|
sublocationyposition double precision,
|
112
|
namedplace_id int(11),
|
113
|
CONSTRAINT location_pkey PRIMARY KEY (location_id ),
|
114
|
CONSTRAINT location_namedplace_id FOREIGN KEY (namedplace_id)
|
115
|
REFERENCES namedplace (namedplace_id) MATCH SIMPLE
|
116
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
117
|
CONSTRAINT location_parent_id FOREIGN KEY (parent_id)
|
118
|
REFERENCES location (location_id) MATCH SIMPLE
|
119
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
120
|
CONSTRAINT location_reference_id FOREIGN KEY (reference_id)
|
121
|
REFERENCES reference (reference_id) MATCH SIMPLE
|
122
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
123
|
CONSTRAINT location_keys UNIQUE (reference_id , parent_id , sourceid )
|
124
|
);
|
125
|
|
126
|
CREATE TABLE locationevent -- VegBank's observation table.
|
127
|
(
|
128
|
locationevent_id int(11) NOT NULL AUTO_INCREMENT,
|
129
|
previous_id int(11),
|
130
|
location_id int(11) NOT NULL,
|
131
|
project_id int(11),
|
132
|
sourceid character varying(30),
|
133
|
-- ...
|
134
|
accessioncode character varying(255),
|
135
|
CONSTRAINT locationevent_pkey PRIMARY KEY (locationevent_id ),
|
136
|
CONSTRAINT locationevent_location_id FOREIGN KEY (location_id)
|
137
|
REFERENCES location (location_id) MATCH SIMPLE
|
138
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
139
|
CONSTRAINT locationevent_project_id FOREIGN KEY (project_id)
|
140
|
REFERENCES project (project_id) MATCH SIMPLE
|
141
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
142
|
CONSTRAINT locationevent_keys UNIQUE (location_id , project_id , sourceid )
|
143
|
);
|
144
|
|
145
|
CREATE TABLE taxonoccurrence -- VegBank's taxonobservation table.
|
146
|
(
|
147
|
taxonoccurrence_id int(11) NOT NULL AUTO_INCREMENT,
|
148
|
locationevent_id int(11) NOT NULL,
|
149
|
authorplantname character varying(255),
|
150
|
reference_id int(11),
|
151
|
taxoninferencearea double precision,
|
152
|
emb_taxonoccurrence int(11),
|
153
|
int_origplantconcept_id int(11),
|
154
|
int_origplantscifull character varying(255),
|
155
|
int_origplantscinamenoauth character varying(255),
|
156
|
int_origplantcommon character varying(255),
|
157
|
int_origplantcode character varying(255),
|
158
|
int_currplantconcept_id int(11),
|
159
|
int_currplantscifull character varying(255),
|
160
|
int_currplantscinamenoauth character varying(255),
|
161
|
int_currplantcommon character varying(255),
|
162
|
int_currplantcode character varying(255),
|
163
|
accessioncode character varying(255),
|
164
|
CONSTRAINT taxonoccurrence_pkey PRIMARY KEY (taxonoccurrence_id ),
|
165
|
CONSTRAINT taxonoccurrence_locationevent_id FOREIGN KEY (locationevent_id)
|
166
|
REFERENCES locationevent (locationevent_id) MATCH SIMPLE
|
167
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
168
|
CONSTRAINT taxonoccurrence_reference_id FOREIGN KEY (reference_id)
|
169
|
REFERENCES reference (reference_id) MATCH SIMPLE
|
170
|
ON UPDATE CASCADE ON DELETE CASCADE
|
171
|
);
|
172
|
|
173
|
CREATE TABLE aggregateoccurrence -- VegBank's taxonimportance table.
|
174
|
(
|
175
|
aggregateoccurrence_id int(11) NOT NULL AUTO_INCREMENT,
|
176
|
taxonoccurrence_id int(11) NOT NULL,
|
177
|
taxonbin_id int(11),
|
178
|
cover double precision,
|
179
|
basalarea double precision,
|
180
|
biomass double precision,
|
181
|
inferencearea double precision,
|
182
|
stratumbase double precision,
|
183
|
stratumheight double precision,
|
184
|
emb_aggregateoccurrence int(11),
|
185
|
covercode character varying(10),
|
186
|
count int(11) NOT NULL,
|
187
|
accessioncode character varying(255),
|
188
|
CONSTRAINT aggregateoccurrence_pkey PRIMARY KEY (aggregateoccurrence_id ),
|
189
|
CONSTRAINT aggregateoccurrence_taxonbin_id FOREIGN KEY (taxonbin_id)
|
190
|
REFERENCES taxonbin (taxonbin_id) MATCH SIMPLE
|
191
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
192
|
CONSTRAINT aggregateoccurrence_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id)
|
193
|
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE
|
194
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
195
|
CONSTRAINT aggregateoccurrence_keys UNIQUE (taxonoccurrence_id , taxonbin_id )
|
196
|
);
|
197
|
|
198
|
CREATE TABLE individualplant -- VegBank's stemcount table.
|
199
|
(
|
200
|
individualplant_id int(11) NOT NULL AUTO_INCREMENT,
|
201
|
aggregateoccurrence_id int(11) NOT NULL,
|
202
|
height double precision,
|
203
|
heightaccuracy double precision,
|
204
|
emb_individualplant int(11),
|
205
|
sourceid character varying(20),
|
206
|
accessioncode character varying(255),
|
207
|
stemcount int(11),
|
208
|
CONSTRAINT individualplant_pkey PRIMARY KEY (individualplant_id ),
|
209
|
CONSTRAINT individualplant_aggregateoccurrence_id FOREIGN KEY (aggregateoccurrence_id)
|
210
|
REFERENCES aggregateoccurrence (aggregateoccurrence_id) MATCH SIMPLE
|
211
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
212
|
CONSTRAINT individualplant_keys UNIQUE (aggregateoccurrence_id , sourceid )
|
213
|
);
|
214
|
|
215
|
CREATE TABLE stem -- VegBank's stemlocation table.
|
216
|
(
|
217
|
stem_id int(11) NOT NULL AUTO_INCREMENT,
|
218
|
individualplant_id int(11) NOT NULL,
|
219
|
sourceid character varying(20),
|
220
|
xposition double precision,
|
221
|
yposition double precision,
|
222
|
health character varying(50),
|
223
|
emb_stem int(11),
|
224
|
diameter double precision,
|
225
|
height double precision,
|
226
|
heightaccuracy double precision,
|
227
|
age double precision,
|
228
|
accessioncode character varying(255),
|
229
|
CONSTRAINT stem_pkey PRIMARY KEY (stem_id ),
|
230
|
CONSTRAINT stem_individualplant_id FOREIGN KEY (individualplant_id)
|
231
|
REFERENCES individualplant (individualplant_id) MATCH SIMPLE
|
232
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
233
|
CONSTRAINT stem_keys UNIQUE (individualplant_id , sourceid )
|
234
|
);
|
235
|
|
236
|
CREATE TABLE specimen -- A herbarium specimen. Contains Darwin Core specimen data.
|
237
|
(
|
238
|
specimen_id int(11) NOT NULL AUTO_INCREMENT,
|
239
|
individualplant_id int(11),
|
240
|
reference_id int(11) NOT NULL,
|
241
|
collectioncode_dwc character varying(255),
|
242
|
catalognumber_dwc character varying(255),
|
243
|
collectiondate timestamp,
|
244
|
collector_id int(11),
|
245
|
museum_id int(11),
|
246
|
sourceaccessionnumber character varying(100),
|
247
|
accessioncode character varying(255),
|
248
|
taxonoccurrence_id int(11),
|
249
|
CONSTRAINT specimen_pkey PRIMARY KEY (specimen_id ),
|
250
|
CONSTRAINT specimen_collector_id FOREIGN KEY (collector_id)
|
251
|
REFERENCES party (party_id) MATCH SIMPLE
|
252
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
253
|
CONSTRAINT specimen_individualplant_id_fkey FOREIGN KEY (individualplant_id)
|
254
|
REFERENCES individualplant (individualplant_id) MATCH SIMPLE
|
255
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
256
|
CONSTRAINT specimen_museum_id FOREIGN KEY (museum_id)
|
257
|
REFERENCES party (party_id) MATCH SIMPLE
|
258
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
259
|
CONSTRAINT specimen_reference_id_fkey FOREIGN KEY (reference_id)
|
260
|
REFERENCES reference (reference_id) MATCH SIMPLE
|
261
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
262
|
CONSTRAINT specimen_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id)
|
263
|
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE
|
264
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
265
|
CONSTRAINT specimen_keys UNIQUE (reference_id , collectioncode_dwc , catalognumber_dwc )
|
266
|
);
|
267
|
|
268
|
CREATE TABLE taxondetermination -- VegBank's taxoninterpretation table.
|
269
|
(
|
270
|
taxondetermination_id int(11) NOT NULL AUTO_INCREMENT,
|
271
|
taxonoccurrence_id int(11) NOT NULL,
|
272
|
plantconcept_id int(11) NOT NULL,
|
273
|
party_id int(11) NOT NULL,
|
274
|
role_id int(11) NOT NULL,
|
275
|
determinationtype character varying(30),
|
276
|
reference_id int(11),
|
277
|
originaldetermination int(1) NOT NULL,
|
278
|
currentdetermination int(1) NOT NULL,
|
279
|
taxonfit character varying(50),
|
280
|
taxonconfidence character varying(50),
|
281
|
grouptype character varying(20),
|
282
|
notes text,
|
283
|
notespublic int(1),
|
284
|
notesmgt int(1),
|
285
|
revisions int(1),
|
286
|
determinationdate timestamp NOT NULL,
|
287
|
emb_taxondetermination int(11),
|
288
|
accessioncode character varying(255),
|
289
|
CONSTRAINT taxondetermination_pkey PRIMARY KEY (taxondetermination_id ),
|
290
|
CONSTRAINT taxondetermination_party_id FOREIGN KEY (party_id)
|
291
|
REFERENCES party (party_id) MATCH SIMPLE
|
292
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
293
|
CONSTRAINT taxondetermination_plantconcept_id FOREIGN KEY (plantconcept_id)
|
294
|
REFERENCES plantconcept (plantconcept_id) MATCH SIMPLE
|
295
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
296
|
CONSTRAINT taxondetermination_reference_id FOREIGN KEY (reference_id)
|
297
|
REFERENCES reference (reference_id) MATCH SIMPLE
|
298
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
299
|
CONSTRAINT taxondetermination_role_id FOREIGN KEY (role_id)
|
300
|
REFERENCES aux_role (role_id) MATCH SIMPLE
|
301
|
ON UPDATE CASCADE ON DELETE CASCADE,
|
302
|
CONSTRAINT taxondetermination_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id)
|
303
|
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE
|
304
|
ON UPDATE CASCADE ON DELETE CASCADE
|
305
|
);
|
306
|
|
307
|
CREATE TABLE sizeclass -- A range of size measurements used to aggregate organisms.
|
308
|
(
|
309
|
sizeclass_id int(11) NOT NULL AUTO_INCREMENT,
|
310
|
mindiameter double precision,
|
311
|
diameteraccuracy double precision,
|
312
|
minheight double precision,
|
313
|
heightaccuracy double precision,
|
314
|
maxdiameter double precision,
|
315
|
maxheight double precision,
|
316
|
accessioncode character varying(255),
|
317
|
CONSTRAINT sizeclass_pkey PRIMARY KEY (sizeclass_id )
|
318
|
);
|
319
|
|
320
|
CREATE TABLE taxonbin -- Defines a set of aggregate measurements. Used by aggregateoccurrence to define how measurements were aggregated.
|
321
|
(
|
322
|
taxonbin_id int(11) NOT NULL,
|
323
|
label character varying(255) NOT NULL,
|
324
|
stratum_id int(11),
|
325
|
sizeclass_id int(11),
|
326
|
coverindex_id int(11),
|
327
|
accessioncode character varying(255),
|
328
|
CONSTRAINT taxonbin_pkey PRIMARY KEY (taxonbin_id ),
|
329
|
CONSTRAINT taxonbin_sizeclass_id FOREIGN KEY (sizeclass_id)
|
330
|
REFERENCES sizeclass (sizeclass_id) MATCH SIMPLE
|
331
|
ON UPDATE CASCADE ON DELETE CASCADE
|
332
|
);
|