Revision 692
Added by Aaron Marcuse-Kubitza about 13 years ago
schemas/vegbien.for_ERD.my.sql | ||
---|---|---|
1 |
-- Existing tables |
|
2 |
|
|
3 |
CREATE TABLE 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 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 NULL , |
|
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), |
|
46 |
plantcode character varying(23), |
|
47 |
plantdescription text, |
|
48 |
d_obscount int(11), |
|
49 |
d_currentaccepted int(1), |
|
50 |
accessioncode character varying(255), |
|
51 |
CONSTRAINT plantconcept_pkey PRIMARY KEY (plantconcept_id ), |
|
52 |
CONSTRAINT plantconcept_plantname_id FOREIGN KEY (plantname_id) |
|
53 |
REFERENCES plantname (plantname_id) MATCH SIMPLE |
|
54 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
55 |
CONSTRAINT plantconcept_reference_id FOREIGN KEY (reference_id) |
|
56 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
57 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
58 |
); |
|
59 |
|
|
60 |
CREATE TABLE stratummethod |
|
61 |
( |
|
62 |
stratummethod_id int(11) NOT NULL AUTO_INCREMENT, |
|
63 |
reference_id int(11), |
|
64 |
stratummethodname character varying(30) NOT NULL, |
|
65 |
stratummethoddescription text, |
|
66 |
stratumassignment character varying(50), |
|
67 |
accessioncode character varying(255), |
|
68 |
CONSTRAINT stratummethod_pkey PRIMARY KEY (stratummethod_id ), |
|
69 |
CONSTRAINT stratummethod_reference_id FOREIGN KEY (reference_id) |
|
70 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
71 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
72 |
); |
|
73 |
|
|
74 |
CREATE TABLE stratumtype |
|
75 |
( |
|
76 |
stratumtype_id int(11) NOT NULL AUTO_INCREMENT, |
|
77 |
stratummethod_id int(11) NOT NULL, |
|
78 |
stratumindex character varying(10), |
|
79 |
stratumname character varying(30), |
|
80 |
stratumdescription text, |
|
81 |
CONSTRAINT stratumtype_pkey PRIMARY KEY (stratumtype_id ), |
|
82 |
CONSTRAINT stratumtype_stratummethod_id FOREIGN KEY (stratummethod_id) |
|
83 |
REFERENCES stratummethod (stratummethod_id) MATCH SIMPLE |
|
84 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
85 |
); |
|
86 |
|
|
87 |
CREATE TABLE namedplace |
|
88 |
( |
|
89 |
namedplace_id int(11) NOT NULL AUTO_INCREMENT, |
|
90 |
placesystem character varying(50), |
|
91 |
placename character varying(100) NOT NULL, |
|
92 |
placedescription text, |
|
93 |
placecode character varying(15), |
|
94 |
owner character varying(100), |
|
95 |
reference_id int(11), |
|
96 |
d_obscount int(11), |
|
97 |
accessioncode character varying(255), |
|
98 |
CONSTRAINT namedplace_pkey PRIMARY KEY (namedplace_id ), |
|
99 |
CONSTRAINT namedplace_reference_id FOREIGN KEY (reference_id) |
|
100 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
101 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
102 |
CONSTRAINT namedplace_keys UNIQUE (placesystem , placename ) |
|
103 |
); |
|
104 |
|
|
105 |
CREATE TABLE locationplace |
|
106 |
( |
|
107 |
locationplace_id int(11) NOT NULL AUTO_INCREMENT, |
|
108 |
location_id int(11) NOT NULL, |
|
109 |
calculated int(1), |
|
110 |
namedplace_id int(11) NOT NULL, |
|
111 |
CONSTRAINT locationplace_pkey PRIMARY KEY (locationplace_id ), |
|
112 |
CONSTRAINT locationplace_location_id FOREIGN KEY (location_id) |
|
113 |
REFERENCES location (location_id) MATCH SIMPLE |
|
114 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
115 |
CONSTRAINT locationplace_namedplace_id FOREIGN KEY (namedplace_id) |
|
116 |
REFERENCES namedplace (namedplace_id) MATCH SIMPLE |
|
117 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
118 |
CONSTRAINT locationplace_keys UNIQUE (location_id , namedplace_id ) |
|
119 |
); |
|
120 |
|
|
121 |
CREATE TABLE project |
|
122 |
( |
|
123 |
project_id int(11) NOT NULL AUTO_INCREMENT, |
|
124 |
projectname character varying(150) NOT NULL, |
|
125 |
projectdescription text, |
|
126 |
startdate timestamp NULL, |
|
127 |
stopdate timestamp NULL, |
|
128 |
d_obscount int(11), |
|
129 |
d_lastlocationaddeddate timestamp NULL, |
|
130 |
accessioncode character varying(255), |
|
131 |
CONSTRAINT project_pkey PRIMARY KEY (project_id ), |
|
132 |
CONSTRAINT project_keys UNIQUE (projectname , startdate , stopdate ) |
|
133 |
); |
|
134 |
|
|
135 |
-- New tables |
|
136 |
|
|
137 |
CREATE TABLE location |
|
138 |
( |
|
139 |
location_id int(11) NOT NULL AUTO_INCREMENT, |
|
140 |
authorlocationcode character varying(30), |
|
141 |
reference_id int(11), |
|
142 |
parent_id int(11), |
|
143 |
reallatitude double precision, |
|
144 |
reallongitude double precision, |
|
145 |
locationaccuracy double precision, |
|
146 |
confidentialitystatus int(11) NOT NULL DEFAULT 0, |
|
147 |
confidentialityreason character varying(200), |
|
148 |
publiclatitude double precision, |
|
149 |
publiclongitude double precision, |
|
150 |
`... (truncated) ...` int(11), |
|
151 |
accessioncode character varying(255), |
|
152 |
sublocationxposition double precision, |
|
153 |
sublocationyposition double precision, |
|
154 |
namedplace_id int(11), |
|
155 |
CONSTRAINT location_pkey PRIMARY KEY (location_id ), |
|
156 |
CONSTRAINT location_namedplace_id FOREIGN KEY (namedplace_id) |
|
157 |
REFERENCES namedplace (namedplace_id) MATCH SIMPLE |
|
158 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
159 |
CONSTRAINT location_parent_id FOREIGN KEY (parent_id) |
|
160 |
REFERENCES location (location_id) MATCH SIMPLE |
|
161 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
162 |
CONSTRAINT location_reference_id FOREIGN KEY (reference_id) |
|
163 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
164 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
165 |
CONSTRAINT location_keys_code UNIQUE (reference_id , authorlocationcode ), |
|
166 |
CONSTRAINT location_keys_coords UNIQUE (reference_id , reallatitude , reallongitude ), |
|
167 |
CONSTRAINT location_keys_subplot_code UNIQUE (parent_id , authorlocationcode ), |
|
168 |
CONSTRAINT location_keys_subplot_coords UNIQUE (parent_id , sublocationxposition , sublocationyposition ) |
|
169 |
); |
|
170 |
|
|
171 |
CREATE TABLE locationevent -- VegBank's observation table. |
|
172 |
( |
|
173 |
locationevent_id int(11) NOT NULL AUTO_INCREMENT, |
|
174 |
previous_id int(11), |
|
175 |
location_id int(11), |
|
176 |
project_id int(11), |
|
177 |
authoreventcode character varying(30), |
|
178 |
`... (truncated) ...` int(11), |
|
179 |
accessioncode character varying(255), |
|
180 |
sourceaccessioncode character varying(100), |
|
181 |
CONSTRAINT locationevent_pkey PRIMARY KEY (locationevent_id ), |
|
182 |
CONSTRAINT locationevent_location_id FOREIGN KEY (location_id) |
|
183 |
REFERENCES location (location_id) MATCH SIMPLE |
|
184 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
185 |
CONSTRAINT locationevent_project_id FOREIGN KEY (project_id) |
|
186 |
REFERENCES project (project_id) MATCH SIMPLE |
|
187 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
188 |
CONSTRAINT locationevent_keys_accessioncode UNIQUE (location_id , project_id , sourceaccessioncode ), |
|
189 |
CONSTRAINT locationevent_keys_code UNIQUE (location_id , project_id , authoreventcode ) |
|
190 |
); |
|
191 |
|
|
192 |
CREATE TABLE taxonoccurrence -- VegBank's taxonobservation table. |
|
193 |
( |
|
194 |
taxonoccurrence_id int(11) NOT NULL AUTO_INCREMENT, |
|
195 |
locationevent_id int(11), |
|
196 |
authorplantname character varying(255), |
|
197 |
reference_id int(11), |
|
198 |
taxoninferencearea double precision, |
|
199 |
emb_taxonoccurrence int(11), |
|
200 |
`... (truncated) ...` int(11), |
|
201 |
accessioncode character varying(255), |
|
202 |
CONSTRAINT taxonoccurrence_pkey PRIMARY KEY (taxonoccurrence_id ), |
|
203 |
CONSTRAINT taxonoccurrence_locationevent_id FOREIGN KEY (locationevent_id) |
|
204 |
REFERENCES locationevent (locationevent_id) MATCH SIMPLE |
|
205 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
206 |
CONSTRAINT taxonoccurrence_reference_id FOREIGN KEY (reference_id) |
|
207 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
208 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
209 |
); |
|
210 |
|
|
211 |
CREATE TABLE aggregateoccurrence -- VegBank's taxonimportance table. |
|
212 |
( |
|
213 |
aggregateoccurrence_id int(11) NOT NULL AUTO_INCREMENT, |
|
214 |
taxonoccurrence_id int(11) NOT NULL, |
|
215 |
cover double precision, |
|
216 |
basalarea double precision, |
|
217 |
biomass double precision, |
|
218 |
inferencearea double precision, |
|
219 |
stratumbase double precision, |
|
220 |
stratumheight double precision, |
|
221 |
emb_aggregateoccurrence int(11), |
|
222 |
covercode character varying(10), |
|
223 |
count int(11), |
|
224 |
accessioncode character varying(255), |
|
225 |
sourceaccessioncode character varying(100), |
|
226 |
plantobservation_id int(11), |
|
227 |
stratum_id int(11), |
|
228 |
sizeclass_id int(11), |
|
229 |
coverindex_id int(11), |
|
230 |
CONSTRAINT aggregateoccurrence_pkey PRIMARY KEY (aggregateoccurrence_id ), |
|
231 |
CONSTRAINT aggregateoccurrence_plantobservation_id FOREIGN KEY (plantobservation_id) |
|
232 |
REFERENCES plantobservation (plantobservation_id) MATCH SIMPLE |
|
233 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
234 |
CONSTRAINT aggregateoccurrence_sizeclass_id FOREIGN KEY (sizeclass_id) |
|
235 |
REFERENCES sizeclass (sizeclass_id) MATCH SIMPLE |
|
236 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
237 |
CONSTRAINT aggregateoccurrence_stratum_id FOREIGN KEY (stratum_id) |
|
238 |
REFERENCES stratum (stratum_id) MATCH SIMPLE |
|
239 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
240 |
CONSTRAINT aggregateoccurrence_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) |
|
241 |
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE |
|
242 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
243 |
CONSTRAINT aggregateoccurrence_keys_accessioncode UNIQUE (taxonoccurrence_id , sourceaccessioncode ) |
|
244 |
); |
|
245 |
|
|
246 |
CREATE TABLE planttag |
|
247 |
( |
|
248 |
planttag_id int(11) NOT NULL AUTO_INCREMENT, |
|
249 |
plantobservation_id int(11) NOT NULL, |
|
250 |
tag character varying(255) NOT NULL, |
|
251 |
iscurrent int(1) NOT NULL DEFAULT true, |
|
252 |
CONSTRAINT planttag_pkey PRIMARY KEY (planttag_id ), |
|
253 |
CONSTRAINT planttag_plantobservation_id FOREIGN KEY (plantobservation_id) |
|
254 |
REFERENCES plantobservation (plantobservation_id) MATCH SIMPLE |
|
255 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
256 |
CONSTRAINT planttag_current_unique UNIQUE (plantobservation_id , iscurrent ), |
|
257 |
CONSTRAINT planttag_keys UNIQUE (plantobservation_id , tag ) |
|
258 |
); |
|
259 |
|
|
260 |
CREATE TABLE plant -- A physical, tagged plant. |
|
261 |
( |
|
262 |
plant_id int(11) NOT NULL AUTO_INCREMENT, |
|
263 |
CONSTRAINT plant_pkey PRIMARY KEY (plant_id ) |
|
264 |
); |
|
265 |
|
|
266 |
CREATE TABLE plantobservation -- VegBank's stemcount table. |
|
267 |
( |
|
268 |
plantobservation_id int(11) NOT NULL AUTO_INCREMENT, |
|
269 |
overallheight double precision, |
|
270 |
overallheightaccuracy double precision, |
|
271 |
emb_plantobservation int(11), |
|
272 |
authorplantcode character varying(20), |
|
273 |
accessioncode character varying(255), |
|
274 |
stemcount int(11), |
|
275 |
sourceaccessioncode character varying(100), |
|
276 |
plant_id int(11), |
|
277 |
CONSTRAINT plantobservation_pkey PRIMARY KEY (plantobservation_id ), |
|
278 |
CONSTRAINT plantobservation_plant_id FOREIGN KEY (plant_id) |
|
279 |
REFERENCES plant (plant_id) MATCH SIMPLE |
|
280 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
281 |
); |
|
282 |
|
|
283 |
CREATE TABLE stemobservation -- VegBank's stemlocation table. |
|
284 |
( |
|
285 |
stemobservation_id int(11) NOT NULL AUTO_INCREMENT, |
|
286 |
plantobservation_id int(11) NOT NULL, |
|
287 |
authorstemcode character varying(20), |
|
288 |
xposition double precision, |
|
289 |
yposition double precision, |
|
290 |
health character varying(50), |
|
291 |
emb_stemobservation int(11), |
|
292 |
diameter double precision, |
|
293 |
height double precision, |
|
294 |
heightaccuracy double precision, |
|
295 |
age double precision, |
|
296 |
accessioncode character varying(255), |
|
297 |
diameteraccuracy double precision, |
|
298 |
sourceaccessioncode character varying(100), |
|
299 |
CONSTRAINT stemobservation_pkey PRIMARY KEY (stemobservation_id ), |
|
300 |
CONSTRAINT stemobservation_plantobservation_id FOREIGN KEY (plantobservation_id) |
|
301 |
REFERENCES plantobservation (plantobservation_id) MATCH SIMPLE |
|
302 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
303 |
CONSTRAINT stemobservation_keys_accessioncode UNIQUE (plantobservation_id , sourceaccessioncode ), |
|
304 |
CONSTRAINT stemobservation_keys_code UNIQUE (plantobservation_id , authorstemcode ) |
|
305 |
); |
|
306 |
|
|
307 |
CREATE TABLE specimen -- A physical specimen collected from a plant. Used to link replicates of the same specimen together. |
|
308 |
( |
|
309 |
specimen_id int(11) NOT NULL AUTO_INCREMENT, |
|
310 |
CONSTRAINT specimen_pkey PRIMARY KEY (specimen_id ) |
|
311 |
); |
|
312 |
|
|
313 |
CREATE TABLE specimenreplicate -- A herbarium's replicate of a specimen. Contains Darwin Core specimen data. |
|
314 |
( |
|
315 |
specimenreplicate_id int(11) NOT NULL AUTO_INCREMENT, |
|
316 |
reference_id int(11) NOT NULL, |
|
317 |
collectioncode_dwc character varying(255), -- The code for the collection that the specimenreplicate is from. |
|
318 |
catalognumber_dwc character varying(255), |
|
319 |
collectiondate timestamp NULL, |
|
320 |
museum_id int(11), |
|
321 |
sourceaccessioncode character varying(100), |
|
322 |
accessioncode character varying(255), |
|
323 |
taxonoccurrence_id int(11) NOT NULL, |
|
324 |
verbatimcollectorname character varying(255), |
|
325 |
collectionnumber character varying(255), -- The number of the specimenreplicate within the collection. |
|
326 |
specimen_id int(11), |
|
327 |
CONSTRAINT specimenreplicate_pkey PRIMARY KEY (specimenreplicate_id ), |
|
328 |
CONSTRAINT specimenreplicate_museum_id FOREIGN KEY (museum_id) |
|
329 |
REFERENCES party (party_id) MATCH SIMPLE |
|
330 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
331 |
CONSTRAINT specimenreplicate_reference_id_fkey FOREIGN KEY (reference_id) |
|
332 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
333 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
334 |
CONSTRAINT specimenreplicate_specimen_id FOREIGN KEY (specimen_id) |
|
335 |
REFERENCES specimen (specimen_id) MATCH SIMPLE |
|
336 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
337 |
CONSTRAINT specimenreplicate_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) |
|
338 |
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE |
|
339 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
340 |
CONSTRAINT specimenreplicate_keys_accessioncode UNIQUE (reference_id , collectioncode_dwc , sourceaccessioncode ), |
|
341 |
CONSTRAINT specimenreplicate_keys_catalognumber UNIQUE (reference_id , collectioncode_dwc , catalognumber_dwc ), |
|
342 |
CONSTRAINT specimenreplicate_keys_collectionnumber UNIQUE (reference_id , collectioncode_dwc , collectionnumber ) |
|
343 |
); |
|
344 |
|
|
345 |
CREATE TABLE voucher |
|
346 |
( |
|
347 |
voucher_id int(11) NOT NULL AUTO_INCREMENT, |
|
348 |
taxonoccurrence_id int(11) NOT NULL, |
|
349 |
specimenreplicate_id int(11) NOT NULL, |
|
350 |
accessioncode character varying(255), |
|
351 |
CONSTRAINT voucher_pkey PRIMARY KEY (voucher_id ), |
|
352 |
CONSTRAINT voucher_specimenreplicate_id FOREIGN KEY (specimenreplicate_id) |
|
353 |
REFERENCES specimenreplicate (specimenreplicate_id) MATCH SIMPLE |
|
354 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
355 |
CONSTRAINT voucher_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) |
|
356 |
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE |
|
357 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
358 |
CONSTRAINT voucher_keys UNIQUE (taxonoccurrence_id , specimenreplicate_id ) |
|
359 |
); |
|
360 |
|
|
361 |
CREATE TABLE taxondetermination -- VegBank's taxoninterpretation table. |
|
362 |
( |
|
363 |
taxondetermination_id int(11) NOT NULL AUTO_INCREMENT, |
|
364 |
taxonoccurrence_id int(11) NOT NULL, |
|
365 |
plantconcept_id int(11) NOT NULL, |
|
366 |
party_id int(11), |
|
367 |
role_id int(11) NOT NULL, |
|
368 |
determinationtype character varying(30), |
|
369 |
reference_id int(11), |
|
370 |
isoriginal int(1) NOT NULL DEFAULT false, |
|
371 |
iscurrent int(1) NOT NULL DEFAULT false, |
|
372 |
taxonfit character varying(50), |
|
373 |
taxonconfidence character varying(50), |
|
374 |
grouptype character varying(20), |
|
375 |
notes text, |
|
376 |
notespublic int(1), |
|
377 |
notesmgt int(1), |
|
378 |
revisions int(1), |
|
379 |
determinationdate timestamp NULL, |
|
380 |
emb_taxondetermination int(11), |
|
381 |
accessioncode character varying(255), |
|
382 |
CONSTRAINT taxondetermination_pkey PRIMARY KEY (taxondetermination_id ), |
|
383 |
CONSTRAINT taxondetermination_party_id FOREIGN KEY (party_id) |
|
384 |
REFERENCES party (party_id) MATCH SIMPLE |
|
385 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
386 |
CONSTRAINT taxondetermination_plantconcept_id FOREIGN KEY (plantconcept_id) |
|
387 |
REFERENCES plantconcept (plantconcept_id) MATCH SIMPLE |
|
388 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
389 |
CONSTRAINT taxondetermination_reference_id FOREIGN KEY (reference_id) |
|
390 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
391 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
392 |
CONSTRAINT taxondetermination_role_id FOREIGN KEY (role_id) |
|
393 |
REFERENCES role (role_id) MATCH SIMPLE |
|
394 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
395 |
CONSTRAINT taxondetermination_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) |
|
396 |
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE |
|
397 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
398 |
); |
|
399 |
|
|
400 |
CREATE TABLE stratum |
|
401 |
( |
|
402 |
stratum_id int(11) NOT NULL AUTO_INCREMENT, |
|
403 |
locationevent_id int(11) NOT NULL, |
|
404 |
stratumtype_id int(11) NOT NULL, |
|
405 |
stratumheight double precision, |
|
406 |
stratumbase double precision, |
|
407 |
stratumcover double precision, |
|
408 |
area double precision, |
|
409 |
CONSTRAINT stratum_pkey PRIMARY KEY (stratum_id ), |
|
410 |
CONSTRAINT stratum_locationevent_id FOREIGN KEY (locationevent_id) |
|
411 |
REFERENCES locationevent (locationevent_id) MATCH SIMPLE |
|
412 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
413 |
CONSTRAINT stratum_stratumtype_id FOREIGN KEY (stratumtype_id) |
|
414 |
REFERENCES stratumtype (stratumtype_id) MATCH SIMPLE |
|
415 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
416 |
); |
|
417 |
|
|
418 |
CREATE TABLE sizeclass -- A range of size measurements used to aggregate organisms. |
|
419 |
( |
|
420 |
sizeclass_id int(11) NOT NULL AUTO_INCREMENT, |
|
421 |
mindiameter double precision, |
|
422 |
minheight double precision, |
|
423 |
maxdiameter double precision, |
|
424 |
maxheight double precision, |
|
425 |
accessioncode character varying(255), |
|
426 |
CONSTRAINT sizeclass_pkey PRIMARY KEY (sizeclass_id ) |
|
427 |
); |
schemas/vegbien.for_wiki.sql | ||
---|---|---|
1 |
CREATE TABLE location |
|
2 |
( |
|
3 |
location_id serial NOT NULL, |
|
4 |
authorlocationcode character varying(30), |
|
5 |
reference_id integer, |
|
6 |
parent_id integer, |
|
7 |
reallatitude double precision, |
|
8 |
reallongitude double precision, |
|
9 |
locationaccuracy double precision, |
|
10 |
confidentialitystatus integer NOT NULL DEFAULT 0, |
|
11 |
confidentialityreason character varying(200), |
|
12 |
publiclatitude double precision, |
|
13 |
publiclongitude double precision, |
|
14 |
"... (truncated) ..." integer, |
|
15 |
accessioncode character varying(255), |
|
16 |
sublocationxposition double precision, |
|
17 |
sublocationyposition double precision, |
|
18 |
namedplace_id integer, |
|
19 |
); |
|
20 |
|
|
21 |
CREATE TABLE locationevent -- VegBank's observation table. |
|
22 |
( |
|
23 |
locationevent_id serial NOT NULL, |
|
24 |
previous_id integer, |
|
25 |
location_id integer, |
|
26 |
project_id integer, |
|
27 |
authoreventcode character varying(30), |
|
28 |
"... (truncated) ..." integer, |
|
29 |
accessioncode character varying(255), |
|
30 |
sourceaccessioncode character varying(100), |
|
31 |
); |
|
32 |
|
|
33 |
CREATE TABLE taxonoccurrence -- VegBank's taxonobservation table. |
|
34 |
( |
|
35 |
taxonoccurrence_id serial NOT NULL, |
|
36 |
locationevent_id integer, |
|
37 |
authorplantname character varying(255), |
|
38 |
reference_id integer, |
|
39 |
taxoninferencearea double precision, |
|
40 |
emb_taxonoccurrence integer, |
|
41 |
"... (truncated) ..." integer, |
|
42 |
accessioncode character varying(255), |
|
43 |
); |
|
44 |
|
|
45 |
CREATE TABLE aggregateoccurrence -- VegBank's taxonimportance table. |
|
46 |
( |
|
47 |
aggregateoccurrence_id serial NOT NULL, |
|
48 |
taxonoccurrence_id integer NOT NULL, |
|
49 |
cover double precision, |
|
50 |
basalarea double precision, |
|
51 |
biomass double precision, |
|
52 |
inferencearea double precision, |
|
53 |
stratumbase double precision, |
|
54 |
stratumheight double precision, |
|
55 |
emb_aggregateoccurrence integer, |
|
56 |
covercode character varying(10), |
|
57 |
count integer, |
|
58 |
accessioncode character varying(255), |
|
59 |
sourceaccessioncode character varying(100), |
|
60 |
plantobservation_id integer, |
|
61 |
stratum_id integer, |
|
62 |
sizeclass_id integer, |
|
63 |
coverindex_id integer, |
|
64 |
); |
|
65 |
|
|
66 |
CREATE TABLE planttag |
|
67 |
( |
|
68 |
planttag_id serial NOT NULL, |
|
69 |
plantobservation_id integer NOT NULL, |
|
70 |
tag character varying(255) NOT NULL, |
|
71 |
iscurrent boolean NOT NULL DEFAULT true, |
|
72 |
); |
|
73 |
|
|
74 |
CREATE TABLE plant -- A physical, tagged plant. |
|
75 |
( |
|
76 |
plant_id serial NOT NULL, |
|
77 |
); |
|
78 |
|
|
79 |
CREATE TABLE plantobservation -- VegBank's stemcount table. |
|
80 |
( |
|
81 |
plantobservation_id serial NOT NULL, |
|
82 |
overallheight double precision, |
|
83 |
overallheightaccuracy double precision, |
|
84 |
emb_plantobservation integer, |
|
85 |
authorplantcode character varying(20), |
|
86 |
accessioncode character varying(255), |
|
87 |
stemcount integer, |
|
88 |
sourceaccessioncode character varying(100), |
|
89 |
plant_id integer, |
|
90 |
); |
|
91 |
|
|
92 |
CREATE TABLE stemobservation -- VegBank's stemlocation table. |
|
93 |
( |
|
94 |
stemobservation_id serial NOT NULL, |
|
95 |
plantobservation_id integer NOT NULL, |
|
96 |
authorstemcode character varying(20), |
|
97 |
xposition double precision, |
|
98 |
yposition double precision, |
|
99 |
health character varying(50), |
|
100 |
emb_stemobservation integer, |
|
101 |
diameter double precision, |
|
102 |
height double precision, |
|
103 |
heightaccuracy double precision, |
|
104 |
age double precision, |
|
105 |
accessioncode character varying(255), |
|
106 |
diameteraccuracy double precision, |
|
107 |
sourceaccessioncode character varying(100), |
|
108 |
); |
|
109 |
|
|
110 |
CREATE TABLE specimen -- A physical specimen collected from a plant. Used to link replicates of the same specimen together. |
|
111 |
( |
|
112 |
specimen_id serial NOT NULL, |
|
113 |
); |
|
114 |
|
|
115 |
CREATE TABLE specimenreplicate -- A herbarium's replicate of a specimen. Contains Darwin Core specimen data. |
|
116 |
( |
|
117 |
specimenreplicate_id serial NOT NULL, |
|
118 |
reference_id integer NOT NULL, |
|
119 |
collectioncode_dwc character varying(255), -- The code for the collection that the specimenreplicate is from. |
|
120 |
catalognumber_dwc character varying(255), |
|
121 |
collectiondate timestamp with time zone, |
|
122 |
museum_id integer, |
|
123 |
sourceaccessioncode character varying(100), |
|
124 |
accessioncode character varying(255), |
|
125 |
taxonoccurrence_id integer NOT NULL, |
|
126 |
verbatimcollectorname character varying(255), |
|
127 |
collectionnumber character varying(255), -- The number of the specimenreplicate within the collection. |
|
128 |
specimen_id integer, |
|
129 |
); |
|
130 |
|
|
131 |
CREATE TABLE voucher |
|
132 |
( |
|
133 |
voucher_id serial NOT NULL, |
|
134 |
taxonoccurrence_id integer NOT NULL, |
|
135 |
specimenreplicate_id integer NOT NULL, |
|
136 |
accessioncode character varying(255), |
|
137 |
); |
|
138 |
|
|
139 |
CREATE TABLE taxondetermination -- VegBank's taxoninterpretation table. |
|
140 |
( |
|
141 |
taxondetermination_id serial NOT NULL, |
|
142 |
taxonoccurrence_id integer NOT NULL, |
|
143 |
plantconcept_id integer NOT NULL, |
|
144 |
party_id integer, |
|
145 |
role_id integer NOT NULL, |
|
146 |
determinationtype character varying(30), |
|
147 |
reference_id integer, |
|
148 |
isoriginal boolean NOT NULL DEFAULT false, |
|
149 |
iscurrent boolean NOT NULL DEFAULT false, |
|
150 |
taxonfit character varying(50), |
|
151 |
taxonconfidence character varying(50), |
|
152 |
grouptype character varying(20), |
|
153 |
notes text, |
|
154 |
notespublic boolean, |
|
155 |
notesmgt boolean, |
|
156 |
revisions boolean, |
|
157 |
determinationdate timestamp with time zone, |
|
158 |
emb_taxondetermination integer, |
|
159 |
accessioncode character varying(255), |
|
160 |
); |
|
161 |
|
|
162 |
CREATE TABLE stratum |
|
163 |
( |
|
164 |
stratum_id serial NOT NULL, |
|
165 |
locationevent_id integer NOT NULL, |
|
166 |
stratumtype_id integer NOT NULL, |
|
167 |
stratumheight double precision, |
|
168 |
stratumbase double precision, |
|
169 |
stratumcover double precision, |
|
170 |
area double precision, |
|
171 |
); |
|
172 |
|
|
173 |
CREATE TABLE sizeclass -- A range of size measurements used to aggregate organisms. |
|
174 |
( |
|
175 |
sizeclass_id serial NOT NULL, |
|
176 |
mindiameter double precision, |
|
177 |
minheight double precision, |
|
178 |
maxdiameter double precision, |
|
179 |
maxheight double precision, |
|
180 |
accessioncode character varying(255), |
|
181 |
); |
schemas/vegbien.for_ERD.sql | ||
---|---|---|
1 |
-- Existing tables |
|
2 |
|
|
3 |
CREATE TABLE role |
|
4 |
( |
|
5 |
role_id serial NOT NULL, |
|
6 |
rolecode character varying(30) NOT NULL, |
|
7 |
roledescription character varying(200), |
|
8 |
CONSTRAINT role_pkey PRIMARY KEY (role_id ) |
|
9 |
); |
|
10 |
|
|
11 |
CREATE TABLE reference |
|
12 |
( |
|
13 |
reference_id serial NOT NULL, |
|
14 |
shortname character varying(250), |
|
15 |
fulltext text, |
|
16 |
referencetype character varying(250) |
|
17 |
); |
|
18 |
|
|
19 |
CREATE TABLE party |
|
20 |
( |
|
21 |
party_id serial NOT NULL, |
|
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 serial NOT NULL, |
|
32 |
plantname character varying(255) NOT NULL, |
|
33 |
reference_id integer, |
|
34 |
dateentered timestamp with time zone 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 serial NOT NULL, |
|
44 |
plantname_id integer NOT NULL, |
|
45 |
reference_id integer, |
|
46 |
plantcode character varying(23), |
|
47 |
plantdescription text, |
|
48 |
d_obscount integer, |
|
49 |
d_currentaccepted boolean, |
|
50 |
accessioncode character varying(255), |
|
51 |
CONSTRAINT plantconcept_pkey PRIMARY KEY (plantconcept_id ), |
|
52 |
CONSTRAINT plantconcept_plantname_id FOREIGN KEY (plantname_id) |
|
53 |
REFERENCES plantname (plantname_id) MATCH SIMPLE |
|
54 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
55 |
CONSTRAINT plantconcept_reference_id FOREIGN KEY (reference_id) |
|
56 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
57 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
58 |
); |
|
59 |
|
|
60 |
CREATE TABLE stratummethod |
|
61 |
( |
|
62 |
stratummethod_id serial NOT NULL, |
|
63 |
reference_id integer, |
|
64 |
stratummethodname character varying(30) NOT NULL, |
|
65 |
stratummethoddescription text, |
|
66 |
stratumassignment character varying(50), |
|
67 |
accessioncode character varying(255), |
|
68 |
CONSTRAINT stratummethod_pkey PRIMARY KEY (stratummethod_id ), |
|
69 |
CONSTRAINT stratummethod_reference_id FOREIGN KEY (reference_id) |
|
70 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
71 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
72 |
); |
|
73 |
|
|
74 |
CREATE TABLE stratumtype |
|
75 |
( |
|
76 |
stratumtype_id serial NOT NULL, |
|
77 |
stratummethod_id integer NOT NULL, |
|
78 |
stratumindex character varying(10), |
|
79 |
stratumname character varying(30), |
|
80 |
stratumdescription text, |
|
81 |
CONSTRAINT stratumtype_pkey PRIMARY KEY (stratumtype_id ), |
|
82 |
CONSTRAINT stratumtype_stratummethod_id FOREIGN KEY (stratummethod_id) |
|
83 |
REFERENCES stratummethod (stratummethod_id) MATCH SIMPLE |
|
84 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
85 |
); |
|
86 |
|
|
87 |
CREATE TABLE namedplace |
|
88 |
( |
|
89 |
namedplace_id serial NOT NULL, |
|
90 |
placesystem character varying(50), |
|
91 |
placename character varying(100) NOT NULL, |
|
92 |
placedescription text, |
|
93 |
placecode character varying(15), |
|
94 |
owner character varying(100), |
|
95 |
reference_id integer, |
|
96 |
d_obscount integer, |
|
97 |
accessioncode character varying(255), |
|
98 |
CONSTRAINT namedplace_pkey PRIMARY KEY (namedplace_id ), |
|
99 |
CONSTRAINT namedplace_reference_id FOREIGN KEY (reference_id) |
|
100 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
101 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
102 |
CONSTRAINT namedplace_keys UNIQUE (placesystem , placename ) |
|
103 |
); |
|
104 |
|
|
105 |
CREATE TABLE locationplace |
|
106 |
( |
|
107 |
locationplace_id serial NOT NULL, |
|
108 |
location_id integer NOT NULL, |
|
109 |
calculated boolean, |
|
110 |
namedplace_id integer NOT NULL, |
|
111 |
CONSTRAINT locationplace_pkey PRIMARY KEY (locationplace_id ), |
|
112 |
CONSTRAINT locationplace_location_id FOREIGN KEY (location_id) |
|
113 |
REFERENCES location (location_id) MATCH SIMPLE |
|
114 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
115 |
CONSTRAINT locationplace_namedplace_id FOREIGN KEY (namedplace_id) |
|
116 |
REFERENCES namedplace (namedplace_id) MATCH SIMPLE |
|
117 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
118 |
CONSTRAINT locationplace_keys UNIQUE (location_id , namedplace_id ) |
|
119 |
); |
|
120 |
|
|
121 |
CREATE TABLE project |
|
122 |
( |
|
123 |
project_id serial NOT NULL, |
|
124 |
projectname character varying(150) NOT NULL, |
|
125 |
projectdescription text, |
|
126 |
startdate timestamp with time zone, |
|
127 |
stopdate timestamp with time zone, |
|
128 |
d_obscount integer, |
|
129 |
d_lastlocationaddeddate timestamp with time zone, |
|
130 |
accessioncode character varying(255), |
|
131 |
CONSTRAINT project_pkey PRIMARY KEY (project_id ), |
|
132 |
CONSTRAINT project_keys UNIQUE (projectname , startdate , stopdate ) |
|
133 |
); |
|
134 |
|
|
135 |
-- New tables |
|
136 |
|
|
137 |
CREATE TABLE location |
|
138 |
( |
|
139 |
location_id serial NOT NULL, |
|
140 |
authorlocationcode character varying(30), |
|
141 |
reference_id integer, |
|
142 |
parent_id integer, |
|
143 |
reallatitude double precision, |
|
144 |
reallongitude double precision, |
|
145 |
locationaccuracy double precision, |
|
146 |
confidentialitystatus integer NOT NULL DEFAULT 0, |
|
147 |
confidentialityreason character varying(200), |
|
148 |
publiclatitude double precision, |
|
149 |
publiclongitude double precision, |
|
150 |
"... (truncated) ..." integer, |
|
151 |
accessioncode character varying(255), |
|
152 |
sublocationxposition double precision, |
|
153 |
sublocationyposition double precision, |
|
154 |
namedplace_id integer, |
|
155 |
CONSTRAINT location_pkey PRIMARY KEY (location_id ), |
|
156 |
CONSTRAINT location_namedplace_id FOREIGN KEY (namedplace_id) |
|
157 |
REFERENCES namedplace (namedplace_id) MATCH SIMPLE |
|
158 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
159 |
CONSTRAINT location_parent_id FOREIGN KEY (parent_id) |
|
160 |
REFERENCES location (location_id) MATCH SIMPLE |
|
161 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
162 |
CONSTRAINT location_reference_id FOREIGN KEY (reference_id) |
|
163 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
164 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
165 |
CONSTRAINT location_keys_code UNIQUE (reference_id , authorlocationcode ), |
|
166 |
CONSTRAINT location_keys_coords UNIQUE (reference_id , reallatitude , reallongitude ), |
|
167 |
CONSTRAINT location_keys_subplot_code UNIQUE (parent_id , authorlocationcode ), |
|
168 |
CONSTRAINT location_keys_subplot_coords UNIQUE (parent_id , sublocationxposition , sublocationyposition ) |
|
169 |
); |
|
170 |
|
|
171 |
CREATE TABLE locationevent -- VegBank's observation table. |
|
172 |
( |
|
173 |
locationevent_id serial NOT NULL, |
|
174 |
previous_id integer, |
|
175 |
location_id integer, |
|
176 |
project_id integer, |
|
177 |
authoreventcode character varying(30), |
|
178 |
"... (truncated) ..." integer, |
|
179 |
accessioncode character varying(255), |
|
180 |
sourceaccessioncode character varying(100), |
|
181 |
CONSTRAINT locationevent_pkey PRIMARY KEY (locationevent_id ), |
|
182 |
CONSTRAINT locationevent_location_id FOREIGN KEY (location_id) |
|
183 |
REFERENCES location (location_id) MATCH SIMPLE |
|
184 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
185 |
CONSTRAINT locationevent_project_id FOREIGN KEY (project_id) |
|
186 |
REFERENCES project (project_id) MATCH SIMPLE |
|
187 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
188 |
CONSTRAINT locationevent_keys_accessioncode UNIQUE (location_id , project_id , sourceaccessioncode ), |
|
189 |
CONSTRAINT locationevent_keys_code UNIQUE (location_id , project_id , authoreventcode ) |
|
190 |
); |
|
191 |
|
|
192 |
CREATE TABLE taxonoccurrence -- VegBank's taxonobservation table. |
|
193 |
( |
|
194 |
taxonoccurrence_id serial NOT NULL, |
|
195 |
locationevent_id integer, |
|
196 |
authorplantname character varying(255), |
|
197 |
reference_id integer, |
|
198 |
taxoninferencearea double precision, |
|
199 |
emb_taxonoccurrence integer, |
|
200 |
"... (truncated) ..." integer, |
|
201 |
accessioncode character varying(255), |
|
202 |
CONSTRAINT taxonoccurrence_pkey PRIMARY KEY (taxonoccurrence_id ), |
|
203 |
CONSTRAINT taxonoccurrence_locationevent_id FOREIGN KEY (locationevent_id) |
|
204 |
REFERENCES locationevent (locationevent_id) MATCH SIMPLE |
|
205 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
206 |
CONSTRAINT taxonoccurrence_reference_id FOREIGN KEY (reference_id) |
|
207 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
208 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
209 |
); |
|
210 |
|
|
211 |
CREATE TABLE aggregateoccurrence -- VegBank's taxonimportance table. |
|
212 |
( |
|
213 |
aggregateoccurrence_id serial NOT NULL, |
|
214 |
taxonoccurrence_id integer NOT NULL, |
|
215 |
cover double precision, |
|
216 |
basalarea double precision, |
|
217 |
biomass double precision, |
|
218 |
inferencearea double precision, |
|
219 |
stratumbase double precision, |
|
220 |
stratumheight double precision, |
|
221 |
emb_aggregateoccurrence integer, |
|
222 |
covercode character varying(10), |
|
223 |
count integer, |
|
224 |
accessioncode character varying(255), |
|
225 |
sourceaccessioncode character varying(100), |
|
226 |
plantobservation_id integer, |
|
227 |
stratum_id integer, |
|
228 |
sizeclass_id integer, |
|
229 |
coverindex_id integer, |
|
230 |
CONSTRAINT aggregateoccurrence_pkey PRIMARY KEY (aggregateoccurrence_id ), |
|
231 |
CONSTRAINT aggregateoccurrence_plantobservation_id FOREIGN KEY (plantobservation_id) |
|
232 |
REFERENCES plantobservation (plantobservation_id) MATCH SIMPLE |
|
233 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
234 |
CONSTRAINT aggregateoccurrence_sizeclass_id FOREIGN KEY (sizeclass_id) |
|
235 |
REFERENCES sizeclass (sizeclass_id) MATCH SIMPLE |
|
236 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
237 |
CONSTRAINT aggregateoccurrence_stratum_id FOREIGN KEY (stratum_id) |
|
238 |
REFERENCES stratum (stratum_id) MATCH SIMPLE |
|
239 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
240 |
CONSTRAINT aggregateoccurrence_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) |
|
241 |
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE |
|
242 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
243 |
CONSTRAINT aggregateoccurrence_keys_accessioncode UNIQUE (taxonoccurrence_id , sourceaccessioncode ) |
|
244 |
); |
|
245 |
|
|
246 |
CREATE TABLE planttag |
|
247 |
( |
|
248 |
planttag_id serial NOT NULL, |
|
249 |
plantobservation_id integer NOT NULL, |
|
250 |
tag character varying(255) NOT NULL, |
|
251 |
iscurrent boolean NOT NULL DEFAULT true, |
|
252 |
CONSTRAINT planttag_pkey PRIMARY KEY (planttag_id ), |
|
253 |
CONSTRAINT planttag_plantobservation_id FOREIGN KEY (plantobservation_id) |
|
254 |
REFERENCES plantobservation (plantobservation_id) MATCH SIMPLE |
|
255 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
256 |
CONSTRAINT planttag_current_unique UNIQUE (plantobservation_id , iscurrent ), |
|
257 |
CONSTRAINT planttag_keys UNIQUE (plantobservation_id , tag ) |
|
258 |
); |
|
259 |
|
|
260 |
CREATE TABLE plant -- A physical, tagged plant. |
|
261 |
( |
|
262 |
plant_id serial NOT NULL, |
|
263 |
CONSTRAINT plant_pkey PRIMARY KEY (plant_id ) |
|
264 |
); |
|
265 |
|
|
266 |
CREATE TABLE plantobservation -- VegBank's stemcount table. |
|
267 |
( |
|
268 |
plantobservation_id serial NOT NULL, |
|
269 |
overallheight double precision, |
|
270 |
overallheightaccuracy double precision, |
|
271 |
emb_plantobservation integer, |
|
272 |
authorplantcode character varying(20), |
|
273 |
accessioncode character varying(255), |
|
274 |
stemcount integer, |
|
275 |
sourceaccessioncode character varying(100), |
|
276 |
plant_id integer, |
|
277 |
CONSTRAINT plantobservation_pkey PRIMARY KEY (plantobservation_id ), |
|
278 |
CONSTRAINT plantobservation_plant_id FOREIGN KEY (plant_id) |
|
279 |
REFERENCES plant (plant_id) MATCH SIMPLE |
|
280 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
281 |
); |
|
282 |
|
|
283 |
CREATE TABLE stemobservation -- VegBank's stemlocation table. |
|
284 |
( |
|
285 |
stemobservation_id serial NOT NULL, |
|
286 |
plantobservation_id integer NOT NULL, |
|
287 |
authorstemcode character varying(20), |
|
288 |
xposition double precision, |
|
289 |
yposition double precision, |
|
290 |
health character varying(50), |
|
291 |
emb_stemobservation integer, |
|
292 |
diameter double precision, |
|
293 |
height double precision, |
|
294 |
heightaccuracy double precision, |
|
295 |
age double precision, |
|
296 |
accessioncode character varying(255), |
|
297 |
diameteraccuracy double precision, |
|
298 |
sourceaccessioncode character varying(100), |
|
299 |
CONSTRAINT stemobservation_pkey PRIMARY KEY (stemobservation_id ), |
|
300 |
CONSTRAINT stemobservation_plantobservation_id FOREIGN KEY (plantobservation_id) |
|
301 |
REFERENCES plantobservation (plantobservation_id) MATCH SIMPLE |
|
302 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
303 |
CONSTRAINT stemobservation_keys_accessioncode UNIQUE (plantobservation_id , sourceaccessioncode ), |
|
304 |
CONSTRAINT stemobservation_keys_code UNIQUE (plantobservation_id , authorstemcode ) |
|
305 |
); |
|
306 |
|
|
307 |
CREATE TABLE specimen -- A physical specimen collected from a plant. Used to link replicates of the same specimen together. |
|
308 |
( |
|
309 |
specimen_id serial NOT NULL, |
|
310 |
CONSTRAINT specimen_pkey PRIMARY KEY (specimen_id ) |
|
311 |
); |
|
312 |
|
|
313 |
CREATE TABLE specimenreplicate -- A herbarium's replicate of a specimen. Contains Darwin Core specimen data. |
|
314 |
( |
|
315 |
specimenreplicate_id serial NOT NULL, |
|
316 |
reference_id integer NOT NULL, |
|
317 |
collectioncode_dwc character varying(255), -- The code for the collection that the specimenreplicate is from. |
|
318 |
catalognumber_dwc character varying(255), |
|
319 |
collectiondate timestamp with time zone, |
|
320 |
museum_id integer, |
|
321 |
sourceaccessioncode character varying(100), |
|
322 |
accessioncode character varying(255), |
|
323 |
taxonoccurrence_id integer NOT NULL, |
|
324 |
verbatimcollectorname character varying(255), |
|
325 |
collectionnumber character varying(255), -- The number of the specimenreplicate within the collection. |
|
326 |
specimen_id integer, |
|
327 |
CONSTRAINT specimenreplicate_pkey PRIMARY KEY (specimenreplicate_id ), |
|
328 |
CONSTRAINT specimenreplicate_museum_id FOREIGN KEY (museum_id) |
|
329 |
REFERENCES party (party_id) MATCH SIMPLE |
|
330 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
331 |
CONSTRAINT specimenreplicate_reference_id_fkey FOREIGN KEY (reference_id) |
|
332 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
333 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
334 |
CONSTRAINT specimenreplicate_specimen_id FOREIGN KEY (specimen_id) |
|
335 |
REFERENCES specimen (specimen_id) MATCH SIMPLE |
|
336 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
337 |
CONSTRAINT specimenreplicate_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) |
|
338 |
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE |
|
339 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
340 |
CONSTRAINT specimenreplicate_keys_accessioncode UNIQUE (reference_id , collectioncode_dwc , sourceaccessioncode ), |
|
341 |
CONSTRAINT specimenreplicate_keys_catalognumber UNIQUE (reference_id , collectioncode_dwc , catalognumber_dwc ), |
|
342 |
CONSTRAINT specimenreplicate_keys_collectionnumber UNIQUE (reference_id , collectioncode_dwc , collectionnumber ) |
|
343 |
); |
|
344 |
|
|
345 |
CREATE TABLE voucher |
|
346 |
( |
|
347 |
voucher_id serial NOT NULL, |
|
348 |
taxonoccurrence_id integer NOT NULL, |
|
349 |
specimenreplicate_id integer NOT NULL, |
|
350 |
accessioncode character varying(255), |
|
351 |
CONSTRAINT voucher_pkey PRIMARY KEY (voucher_id ), |
|
352 |
CONSTRAINT voucher_specimenreplicate_id FOREIGN KEY (specimenreplicate_id) |
|
353 |
REFERENCES specimenreplicate (specimenreplicate_id) MATCH SIMPLE |
|
354 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
355 |
CONSTRAINT voucher_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) |
|
356 |
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE |
|
357 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
358 |
CONSTRAINT voucher_keys UNIQUE (taxonoccurrence_id , specimenreplicate_id ) |
|
359 |
); |
|
360 |
|
|
361 |
CREATE TABLE taxondetermination -- VegBank's taxoninterpretation table. |
|
362 |
( |
|
363 |
taxondetermination_id serial NOT NULL, |
|
364 |
taxonoccurrence_id integer NOT NULL, |
|
365 |
plantconcept_id integer NOT NULL, |
|
366 |
party_id integer, |
|
367 |
role_id integer NOT NULL, |
|
368 |
determinationtype character varying(30), |
|
369 |
reference_id integer, |
|
370 |
isoriginal boolean NOT NULL DEFAULT false, |
|
371 |
iscurrent boolean NOT NULL DEFAULT false, |
|
372 |
taxonfit character varying(50), |
|
373 |
taxonconfidence character varying(50), |
|
374 |
grouptype character varying(20), |
|
375 |
notes text, |
|
376 |
notespublic boolean, |
|
377 |
notesmgt boolean, |
|
378 |
revisions boolean, |
|
379 |
determinationdate timestamp with time zone, |
|
380 |
emb_taxondetermination integer, |
|
381 |
accessioncode character varying(255), |
|
382 |
CONSTRAINT taxondetermination_pkey PRIMARY KEY (taxondetermination_id ), |
|
383 |
CONSTRAINT taxondetermination_party_id FOREIGN KEY (party_id) |
|
384 |
REFERENCES party (party_id) MATCH SIMPLE |
|
385 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
386 |
CONSTRAINT taxondetermination_plantconcept_id FOREIGN KEY (plantconcept_id) |
|
387 |
REFERENCES plantconcept (plantconcept_id) MATCH SIMPLE |
|
388 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
389 |
CONSTRAINT taxondetermination_reference_id FOREIGN KEY (reference_id) |
|
390 |
REFERENCES reference (reference_id) MATCH SIMPLE |
|
391 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
392 |
CONSTRAINT taxondetermination_role_id FOREIGN KEY (role_id) |
|
393 |
REFERENCES role (role_id) MATCH SIMPLE |
|
394 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
395 |
CONSTRAINT taxondetermination_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id) |
|
396 |
REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE |
|
397 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
398 |
); |
|
399 |
|
|
400 |
CREATE TABLE stratum |
|
401 |
( |
|
402 |
stratum_id serial NOT NULL, |
|
403 |
locationevent_id integer NOT NULL, |
|
404 |
stratumtype_id integer NOT NULL, |
|
405 |
stratumheight double precision, |
|
406 |
stratumbase double precision, |
|
407 |
stratumcover double precision, |
|
408 |
area double precision, |
|
409 |
CONSTRAINT stratum_pkey PRIMARY KEY (stratum_id ), |
|
410 |
CONSTRAINT stratum_locationevent_id FOREIGN KEY (locationevent_id) |
|
411 |
REFERENCES locationevent (locationevent_id) MATCH SIMPLE |
|
412 |
ON UPDATE CASCADE ON DELETE CASCADE, |
|
413 |
CONSTRAINT stratum_stratumtype_id FOREIGN KEY (stratumtype_id) |
|
414 |
REFERENCES stratumtype (stratumtype_id) MATCH SIMPLE |
|
415 |
ON UPDATE CASCADE ON DELETE CASCADE |
|
416 |
); |
|
417 |
|
|
418 |
CREATE TABLE sizeclass -- A range of size measurements used to aggregate organisms. |
|
419 |
( |
|
420 |
sizeclass_id serial NOT NULL, |
|
421 |
mindiameter double precision, |
|
422 |
minheight double precision, |
|
423 |
maxdiameter double precision, |
|
424 |
maxheight double precision, |
|
425 |
accessioncode character varying(255), |
|
426 |
CONSTRAINT sizeclass_pkey PRIMARY KEY (sizeclass_id ) |
|
427 |
); |
schemas/Makefile | ||
---|---|---|
5 | 5 |
|
6 | 6 |
##### |
7 | 7 |
|
8 |
all = vegbien.sql vegbien_empty.sql vegbien.my.sql vegbien.for_ERD.my.sql\ |
|
9 |
vegbien.for_wiki.sql |
|
8 |
all = vegbien.sql vegbien_empty.sql vegbien.my.sql |
|
10 | 9 |
|
11 | 10 |
all: _always $(all) ; |
12 | 11 |
|
... | ... | |
40 | 39 |
|
41 | 40 |
%.my.sql: %.sql ../lib/PostgreSQL-MySQL.csv |
42 | 41 |
$(repl) |
43 |
|
|
44 |
%.for_wiki.sql: %.for_ERD.sql ../lib/ERD-wiki.csv |
|
45 |
$(repl) |
Also available in: Unified diff
schemas/Makefile: Don't generate for_ERD DDLs because the ERD is now synced with the full schema