Project

General

Profile

1 537 aaronmk
-- 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 552 aaronmk
CREATE TABLE place
80
(
81
  locationplace_id int(11) NOT NULL AUTO_INCREMENT,
82
  location_id int(11) NOT NULL,
83
  calculated int(1),
84
  namedplace_id int(11) NOT NULL,
85
  CONSTRAINT place_pkey PRIMARY KEY (locationplace_id ),
86
  CONSTRAINT place_location_id FOREIGN KEY (location_id)
87
      REFERENCES location (location_id) MATCH SIMPLE
88
      ON UPDATE CASCADE ON DELETE CASCADE,
89
  CONSTRAINT place_namedplace_id FOREIGN KEY (namedplace_id)
90
      REFERENCES namedplace (namedplace_id) MATCH SIMPLE
91
      ON UPDATE CASCADE ON DELETE CASCADE,
92
  CONSTRAINT place_keys UNIQUE (location_id , namedplace_id )
93
);
94
95 537 aaronmk
CREATE TABLE project
96
(
97
  project_id int(11) NOT NULL AUTO_INCREMENT,
98
  projectname character varying(150) NOT NULL,
99
  projectdescription text,
100
  startdate timestamp,
101
  stopdate timestamp,
102
  d_obscount int(11),
103
  d_lastlocationaddeddate timestamp,
104
  accessioncode character varying(255),
105
  CONSTRAINT project_pkey PRIMARY KEY (project_id ),
106
  CONSTRAINT project_keys UNIQUE (projectname , startdate , stopdate )
107
);
108
109
-- New tables
110
111 536 aaronmk
CREATE TABLE location
112
(
113
  location_id int(11) NOT NULL AUTO_INCREMENT,
114
  sourceid character varying(30),
115
  reference_id int(11),
116
  parent_id int(11),
117
  reallatitude double precision,
118
  reallongitude double precision,
119
  locationaccuracy double precision,
120
  confidentialitystatus int(11) NOT NULL,
121
  confidentialityreason character varying(200),
122
  latitude double precision,
123
  longitude double precision,
124
  -- ...
125
  accessioncode character varying(255),
126
  sublocationxposition double precision,
127
  sublocationyposition double precision,
128
  namedplace_id int(11),
129
  CONSTRAINT location_pkey PRIMARY KEY (location_id ),
130
  CONSTRAINT location_namedplace_id FOREIGN KEY (namedplace_id)
131
      REFERENCES namedplace (namedplace_id) MATCH SIMPLE
132
      ON UPDATE CASCADE ON DELETE CASCADE,
133
  CONSTRAINT location_parent_id FOREIGN KEY (parent_id)
134
      REFERENCES location (location_id) MATCH SIMPLE
135
      ON UPDATE CASCADE ON DELETE CASCADE,
136
  CONSTRAINT location_reference_id FOREIGN KEY (reference_id)
137
      REFERENCES reference (reference_id) MATCH SIMPLE
138
      ON UPDATE CASCADE ON DELETE CASCADE,
139
  CONSTRAINT location_keys UNIQUE (reference_id , parent_id , sourceid )
140
);
141
142
CREATE TABLE locationevent -- VegBank's observation table.
143
(
144
  locationevent_id int(11) NOT NULL AUTO_INCREMENT,
145
  previous_id int(11),
146
  location_id int(11) NOT NULL,
147
  project_id int(11),
148
  sourceid character varying(30),
149
  -- ...
150
  accessioncode character varying(255),
151
  CONSTRAINT locationevent_pkey PRIMARY KEY (locationevent_id ),
152
  CONSTRAINT locationevent_location_id FOREIGN KEY (location_id)
153
      REFERENCES location (location_id) MATCH SIMPLE
154
      ON UPDATE CASCADE ON DELETE CASCADE,
155
  CONSTRAINT locationevent_project_id FOREIGN KEY (project_id)
156
      REFERENCES project (project_id) MATCH SIMPLE
157
      ON UPDATE CASCADE ON DELETE CASCADE,
158
  CONSTRAINT locationevent_keys UNIQUE (location_id , project_id , sourceid )
159
);
160
161
CREATE TABLE taxonoccurrence -- VegBank's taxonobservation table.
162
(
163
  taxonoccurrence_id int(11) NOT NULL AUTO_INCREMENT,
164
  locationevent_id int(11) NOT NULL,
165
  authorplantname character varying(255),
166
  reference_id int(11),
167
  taxoninferencearea double precision,
168
  emb_taxonoccurrence int(11),
169 539 aaronmk
  -- ...
170 536 aaronmk
  accessioncode character varying(255),
171
  CONSTRAINT taxonoccurrence_pkey PRIMARY KEY (taxonoccurrence_id ),
172
  CONSTRAINT taxonoccurrence_locationevent_id FOREIGN KEY (locationevent_id)
173
      REFERENCES locationevent (locationevent_id) MATCH SIMPLE
174
      ON UPDATE CASCADE ON DELETE CASCADE,
175
  CONSTRAINT taxonoccurrence_reference_id FOREIGN KEY (reference_id)
176
      REFERENCES reference (reference_id) MATCH SIMPLE
177
      ON UPDATE CASCADE ON DELETE CASCADE
178
);
179
180
CREATE TABLE aggregateoccurrence -- VegBank's taxonimportance table.
181
(
182
  aggregateoccurrence_id int(11) NOT NULL AUTO_INCREMENT,
183
  taxonoccurrence_id int(11) NOT NULL,
184
  taxonbin_id int(11),
185
  cover double precision,
186
  basalarea double precision,
187
  biomass double precision,
188
  inferencearea double precision,
189
  stratumbase double precision,
190
  stratumheight double precision,
191
  emb_aggregateoccurrence int(11),
192
  covercode character varying(10),
193
  count int(11) NOT NULL,
194
  accessioncode character varying(255),
195
  CONSTRAINT aggregateoccurrence_pkey PRIMARY KEY (aggregateoccurrence_id ),
196
  CONSTRAINT aggregateoccurrence_taxonbin_id FOREIGN KEY (taxonbin_id)
197
      REFERENCES taxonbin (taxonbin_id) MATCH SIMPLE
198
      ON UPDATE CASCADE ON DELETE CASCADE,
199
  CONSTRAINT aggregateoccurrence_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id)
200
      REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE
201
      ON UPDATE CASCADE ON DELETE CASCADE,
202
  CONSTRAINT aggregateoccurrence_keys UNIQUE (taxonoccurrence_id , taxonbin_id )
203
);
204
205
CREATE TABLE individualplant -- VegBank's stemcount table.
206
(
207
  individualplant_id int(11) NOT NULL AUTO_INCREMENT,
208
  aggregateoccurrence_id int(11) NOT NULL,
209
  height double precision,
210
  heightaccuracy double precision,
211
  emb_individualplant int(11),
212
  sourceid character varying(20),
213
  accessioncode character varying(255),
214
  stemcount int(11),
215
  CONSTRAINT individualplant_pkey PRIMARY KEY (individualplant_id ),
216
  CONSTRAINT individualplant_aggregateoccurrence_id FOREIGN KEY (aggregateoccurrence_id)
217
      REFERENCES aggregateoccurrence (aggregateoccurrence_id) MATCH SIMPLE
218
      ON UPDATE CASCADE ON DELETE CASCADE,
219
  CONSTRAINT individualplant_keys UNIQUE (aggregateoccurrence_id , sourceid )
220
);
221
222
CREATE TABLE stem -- VegBank's stemlocation table.
223
(
224
  stem_id int(11) NOT NULL AUTO_INCREMENT,
225
  individualplant_id int(11) NOT NULL,
226
  sourceid character varying(20),
227
  xposition double precision,
228
  yposition double precision,
229
  health character varying(50),
230
  emb_stem int(11),
231
  diameter double precision,
232
  height double precision,
233
  heightaccuracy double precision,
234
  age double precision,
235
  accessioncode character varying(255),
236 556 aaronmk
  diameteraccuracy double precision,
237 536 aaronmk
  CONSTRAINT stem_pkey PRIMARY KEY (stem_id ),
238
  CONSTRAINT stem_individualplant_id FOREIGN KEY (individualplant_id)
239
      REFERENCES individualplant (individualplant_id) MATCH SIMPLE
240
      ON UPDATE CASCADE ON DELETE CASCADE,
241
  CONSTRAINT stem_keys UNIQUE (individualplant_id , sourceid )
242
);
243
244 537 aaronmk
CREATE TABLE specimen -- A herbarium specimen. Contains Darwin Core specimen data.
245
(
246
  specimen_id int(11) NOT NULL AUTO_INCREMENT,
247
  reference_id int(11) NOT NULL,
248
  collectioncode_dwc character varying(255),
249
  catalognumber_dwc character varying(255),
250
  collectiondate timestamp,
251
  collector_id int(11),
252
  museum_id int(11),
253
  sourceaccessionnumber character varying(100),
254
  accessioncode character varying(255),
255
  taxonoccurrence_id int(11),
256
  CONSTRAINT specimen_pkey PRIMARY KEY (specimen_id ),
257
  CONSTRAINT specimen_collector_id FOREIGN KEY (collector_id)
258
      REFERENCES party (party_id) MATCH SIMPLE
259
      ON UPDATE CASCADE ON DELETE CASCADE,
260
  CONSTRAINT specimen_museum_id FOREIGN KEY (museum_id)
261
      REFERENCES party (party_id) MATCH SIMPLE
262
      ON UPDATE CASCADE ON DELETE CASCADE,
263
  CONSTRAINT specimen_reference_id_fkey FOREIGN KEY (reference_id)
264
      REFERENCES reference (reference_id) MATCH SIMPLE
265
      ON UPDATE CASCADE ON DELETE CASCADE,
266
  CONSTRAINT specimen_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id)
267
      REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE
268
      ON UPDATE CASCADE ON DELETE CASCADE,
269
  CONSTRAINT specimen_keys UNIQUE (reference_id , collectioncode_dwc , catalognumber_dwc )
270
);
271
272 544 aaronmk
CREATE TABLE voucher
273
(
274
  voucher_id int(11) NOT NULL AUTO_INCREMENT,
275 545 aaronmk
  taxonoccurrence_id int(11) NOT NULL,
276
  specimen_id int(11) NOT NULL,
277 544 aaronmk
  accessioncode character varying(255),
278
  CONSTRAINT voucher_pkey PRIMARY KEY (voucher_id ),
279
  CONSTRAINT voucher_specimen_id FOREIGN KEY (specimen_id)
280
      REFERENCES specimen (specimen_id) MATCH SIMPLE
281
      ON UPDATE CASCADE ON DELETE CASCADE,
282
  CONSTRAINT voucher_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id)
283
      REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE
284
      ON UPDATE CASCADE ON DELETE CASCADE,
285
  CONSTRAINT voucher_keys UNIQUE (taxonoccurrence_id , specimen_id )
286
);
287
288 536 aaronmk
CREATE TABLE taxondetermination -- VegBank's taxoninterpretation table.
289
(
290
  taxondetermination_id int(11) NOT NULL AUTO_INCREMENT,
291
  taxonoccurrence_id int(11) NOT NULL,
292
  plantconcept_id int(11) NOT NULL,
293
  party_id int(11) NOT NULL,
294
  role_id int(11) NOT NULL,
295
  determinationtype character varying(30),
296
  reference_id int(11),
297
  originaldetermination int(1) NOT NULL,
298
  currentdetermination int(1) NOT NULL,
299
  taxonfit character varying(50),
300
  taxonconfidence character varying(50),
301
  grouptype character varying(20),
302
  notes text,
303
  notespublic int(1),
304
  notesmgt int(1),
305
  revisions int(1),
306 537 aaronmk
  determinationdate timestamp NOT NULL,
307 536 aaronmk
  emb_taxondetermination int(11),
308
  accessioncode character varying(255),
309
  CONSTRAINT taxondetermination_pkey PRIMARY KEY (taxondetermination_id ),
310
  CONSTRAINT taxondetermination_party_id FOREIGN KEY (party_id)
311
      REFERENCES party (party_id) MATCH SIMPLE
312
      ON UPDATE CASCADE ON DELETE CASCADE,
313
  CONSTRAINT taxondetermination_plantconcept_id FOREIGN KEY (plantconcept_id)
314
      REFERENCES plantconcept (plantconcept_id) MATCH SIMPLE
315
      ON UPDATE CASCADE ON DELETE CASCADE,
316
  CONSTRAINT taxondetermination_reference_id FOREIGN KEY (reference_id)
317
      REFERENCES reference (reference_id) MATCH SIMPLE
318
      ON UPDATE CASCADE ON DELETE CASCADE,
319
  CONSTRAINT taxondetermination_role_id FOREIGN KEY (role_id)
320
      REFERENCES aux_role (role_id) MATCH SIMPLE
321
      ON UPDATE CASCADE ON DELETE CASCADE,
322
  CONSTRAINT taxondetermination_taxonoccurrence_id FOREIGN KEY (taxonoccurrence_id)
323
      REFERENCES taxonoccurrence (taxonoccurrence_id) MATCH SIMPLE
324
      ON UPDATE CASCADE ON DELETE CASCADE
325
);
326
327 552 aaronmk
CREATE TABLE stratum
328
(
329
  stratum_id int(11) NOT NULL AUTO_INCREMENT,
330
  locationevent_id int(11) NOT NULL,
331
  stratumtype_id int(11) NOT NULL,
332
  stratummethod_id int(11),
333
  stratumname character varying(30),
334
  stratumheight double precision,
335
  stratumbase double precision,
336
  stratumcover double precision,
337
  stratumdescription character varying(200),
338
  CONSTRAINT stratum_pkey PRIMARY KEY (stratum_id ),
339
  CONSTRAINT stratum_locationevent_id FOREIGN KEY (locationevent_id)
340
      REFERENCES locationevent (locationevent_id) MATCH SIMPLE
341
      ON UPDATE CASCADE ON DELETE CASCADE,
342
);
343
344 537 aaronmk
CREATE TABLE sizeclass -- A range of size measurements used to aggregate organisms.
345 536 aaronmk
(
346 537 aaronmk
  sizeclass_id int(11) NOT NULL AUTO_INCREMENT,
347
  mindiameter double precision,
348 557 aaronmk
  diameterprecision double precision,
349 537 aaronmk
  minheight double precision,
350 557 aaronmk
  heightprecision double precision,
351 537 aaronmk
  maxdiameter double precision,
352
  maxheight double precision,
353 536 aaronmk
  accessioncode character varying(255),
354 537 aaronmk
  CONSTRAINT sizeclass_pkey PRIMARY KEY (sizeclass_id )
355 536 aaronmk
);
356
357
CREATE TABLE taxonbin -- Defines a set of aggregate measurements. Used by aggregateoccurrence to define how measurements were aggregated.
358
(
359
  taxonbin_id int(11) NOT NULL,
360
  label character varying(255) NOT NULL,
361
  stratum_id int(11),
362
  sizeclass_id int(11),
363
  coverindex_id int(11),
364
  accessioncode character varying(255),
365
  CONSTRAINT taxonbin_pkey PRIMARY KEY (taxonbin_id ),
366
  CONSTRAINT taxonbin_sizeclass_id FOREIGN KEY (sizeclass_id)
367
      REFERENCES sizeclass (sizeclass_id) MATCH SIMPLE
368
      ON UPDATE CASCADE ON DELETE CASCADE
369
);