1
|
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
2
|
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
3
|
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
|
4
|
|
5
|
DROP SCHEMA IF EXISTS `default_schema` ;
|
6
|
CREATE SCHEMA IF NOT EXISTS `default_schema` ;
|
7
|
USE `default_schema` ;
|
8
|
|
9
|
-- -----------------------------------------------------
|
10
|
-- Table `default_schema`.`reference`
|
11
|
-- -----------------------------------------------------
|
12
|
DROP TABLE IF EXISTS `default_schema`.`reference` ;
|
13
|
|
14
|
CREATE TABLE IF NOT EXISTS `default_schema`.`reference` (
|
15
|
`reference_id` INT NOT NULL ,
|
16
|
PRIMARY KEY (`reference_id`) )
|
17
|
ENGINE = InnoDB;
|
18
|
|
19
|
|
20
|
-- -----------------------------------------------------
|
21
|
-- Table `default_schema`.`taxon`
|
22
|
-- -----------------------------------------------------
|
23
|
DROP TABLE IF EXISTS `default_schema`.`taxon` ;
|
24
|
|
25
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxon` (
|
26
|
`taxon_id` INT NOT NULL ,
|
27
|
`taxonrank` VARCHAR(45) NOT NULL ,
|
28
|
`scientificname` VARCHAR(100) NOT NULL ,
|
29
|
`scientificnameauthorship` VARCHAR(150) NULL ,
|
30
|
`authorship_reference_id` INT NULL ,
|
31
|
PRIMARY KEY (`taxon_id`) ,
|
32
|
INDEX `fk_taxon_reference2` (`authorship_reference_id` ASC) ,
|
33
|
CONSTRAINT `fk_taxon_reference2`
|
34
|
FOREIGN KEY (`authorship_reference_id` )
|
35
|
REFERENCES `default_schema`.`reference` (`reference_id` )
|
36
|
ON DELETE NO ACTION
|
37
|
ON UPDATE NO ACTION)
|
38
|
ENGINE = InnoDB;
|
39
|
|
40
|
|
41
|
-- -----------------------------------------------------
|
42
|
-- Table `default_schema`.`taxonconcept`
|
43
|
-- -----------------------------------------------------
|
44
|
DROP TABLE IF EXISTS `default_schema`.`taxonconcept` ;
|
45
|
|
46
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxonconcept` (
|
47
|
`taxonconcept_id` INT(11) NOT NULL ,
|
48
|
`taxon_id` INT NOT NULL ,
|
49
|
`concept_reference_id` INT NOT NULL ,
|
50
|
PRIMARY KEY (`taxonconcept_id`) ,
|
51
|
INDEX `fk_taxonconcept_taxon1` (`taxon_id` ASC) ,
|
52
|
INDEX `fk_taxonconcept_reference1` (`concept_reference_id` ASC) ,
|
53
|
CONSTRAINT `fk_taxonconcept_taxon1`
|
54
|
FOREIGN KEY (`taxon_id` )
|
55
|
REFERENCES `default_schema`.`taxon` (`taxon_id` )
|
56
|
ON DELETE NO ACTION
|
57
|
ON UPDATE NO ACTION,
|
58
|
CONSTRAINT `fk_taxonconcept_reference1`
|
59
|
FOREIGN KEY (`concept_reference_id` )
|
60
|
REFERENCES `default_schema`.`reference` (`reference_id` )
|
61
|
ON DELETE NO ACTION
|
62
|
ON UPDATE NO ACTION);
|
63
|
|
64
|
|
65
|
-- -----------------------------------------------------
|
66
|
-- Table `default_schema`.`taxonverbatim`
|
67
|
-- -----------------------------------------------------
|
68
|
DROP TABLE IF EXISTS `default_schema`.`taxonverbatim` ;
|
69
|
|
70
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxonverbatim` (
|
71
|
`taxonverbatim_id` INT NOT NULL ,
|
72
|
`scientificname` VARCHAR(200) NULL DEFAULT NULL ,
|
73
|
`scientificnameauthorship` VARCHAR(200) NULL DEFAULT NULL ,
|
74
|
`scientificnamewithauthor` VARCHAR(250) NULL DEFAULT NULL ,
|
75
|
`kingdom` VARCHAR(50) NULL DEFAULT NULL ,
|
76
|
`subkingdom` VARCHAR(50) NULL DEFAULT NULL ,
|
77
|
`division` VARCHAR(50) NULL DEFAULT NULL ,
|
78
|
`subdivision` VARCHAR(50) NULL DEFAULT NULL ,
|
79
|
`class` VARCHAR(50) NULL DEFAULT NULL ,
|
80
|
`subclass` VARCHAR(50) NULL DEFAULT NULL ,
|
81
|
`order` VARCHAR(50) NULL DEFAULT NULL ,
|
82
|
`suborder` VARCHAR(50) NULL DEFAULT NULL ,
|
83
|
`family` VARCHAR(50) NULL DEFAULT NULL ,
|
84
|
`subfamily` VARCHAR(50) NULL DEFAULT NULL ,
|
85
|
`tribe` VARCHAR(50) NULL DEFAULT NULL ,
|
86
|
`subtribe` VARCHAR(50) NULL DEFAULT NULL ,
|
87
|
`genus` VARCHAR(50) NULL DEFAULT NULL ,
|
88
|
`subgenus` VARCHAR(50) NULL DEFAULT NULL ,
|
89
|
`section` VARCHAR(50) NULL DEFAULT NULL ,
|
90
|
`subsection` VARCHAR(50) NULL DEFAULT NULL ,
|
91
|
`series` VARCHAR(50) NULL DEFAULT NULL ,
|
92
|
`subseries` VARCHAR(50) NULL DEFAULT NULL ,
|
93
|
`species` VARCHAR(50) NULL DEFAULT NULL ,
|
94
|
`subspecies` VARCHAR(50) NULL DEFAULT NULL ,
|
95
|
`variety` VARCHAR(50) NULL DEFAULT NULL ,
|
96
|
`subvariety` VARCHAR(50) NULL DEFAULT NULL ,
|
97
|
`form` VARCHAR(50) NULL DEFAULT NULL ,
|
98
|
`matched_taxonconcept_id` INT(11) NULL ,
|
99
|
`taxonmatched` VARCHAR(100) NULL ,
|
100
|
`taxonmatchedauthor` VARCHAR(150) NULL ,
|
101
|
`unmatchedterms` VARCHAR(250) NULL ,
|
102
|
`matchscore` DECIMAL(3,1) NULL ,
|
103
|
`taxonmatchedacceptance` VARCHAR(45) NULL ,
|
104
|
`accepted_taxonconcept_id` INT(11) NULL ,
|
105
|
`acceptedtaxon` VARCHAR(100) NULL ,
|
106
|
`acceptedauthor` VARCHAR(150) NULL ,
|
107
|
`family_taxonconcept_id` INT(11) NULL ,
|
108
|
`acceptedfamily` VARCHAR(50) NULL ,
|
109
|
`acceptedgenus` VARCHAR(50) NULL ,
|
110
|
`acceptedspecies` VARCHAR(45) NULL ,
|
111
|
`accepted_taxonacceptance` VARCHAR(45) NULL ,
|
112
|
`acceptedtaxonrank` VARCHAR(45) NULL ,
|
113
|
`acceptedtaxonmorphospecies` VARCHAR(250) NULL ,
|
114
|
PRIMARY KEY (`taxonverbatim_id`) ,
|
115
|
INDEX `fk_taxonverbatim_taxonconcept1` (`matched_taxonconcept_id` ASC) ,
|
116
|
INDEX `fk_taxonverbatim_taxonconcept2` (`accepted_taxonconcept_id` ASC) ,
|
117
|
INDEX `fk_taxonverbatim_taxonconcept3` (`family_taxonconcept_id` ASC) ,
|
118
|
CONSTRAINT `fk_taxonverbatim_taxonconcept1`
|
119
|
FOREIGN KEY (`matched_taxonconcept_id` )
|
120
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
121
|
ON DELETE NO ACTION
|
122
|
ON UPDATE NO ACTION,
|
123
|
CONSTRAINT `fk_taxonverbatim_taxonconcept2`
|
124
|
FOREIGN KEY (`accepted_taxonconcept_id` )
|
125
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
126
|
ON DELETE NO ACTION
|
127
|
ON UPDATE NO ACTION,
|
128
|
CONSTRAINT `fk_taxonverbatim_taxonconcept3`
|
129
|
FOREIGN KEY (`family_taxonconcept_id` )
|
130
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
131
|
ON DELETE NO ACTION
|
132
|
ON UPDATE NO ACTION)
|
133
|
ENGINE = InnoDB,
|
134
|
COMMENT = '\n' ;
|
135
|
|
136
|
|
137
|
-- -----------------------------------------------------
|
138
|
-- Table `default_schema`.`taxondetermination`
|
139
|
-- -----------------------------------------------------
|
140
|
DROP TABLE IF EXISTS `default_schema`.`taxondetermination` ;
|
141
|
|
142
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxondetermination` (
|
143
|
`taxondetermination_id` INT(11) NOT NULL ,
|
144
|
`taxonverbatim_id` INT NOT NULL ,
|
145
|
`taxonoccurrence_id` INT(11) NOT NULL ,
|
146
|
`determiner_party_id` INT(11) NULL DEFAULT NULL ,
|
147
|
`determiner_role` VARCHAR(250) NOT NULL DEFAULT 'unknown' ,
|
148
|
`determinationtype` TEXT NULL DEFAULT NULL ,
|
149
|
`determination_reference_id` INT NOT NULL ,
|
150
|
`isoriginal` INT(1) NOT NULL DEFAULT false ,
|
151
|
`iscurrent` INT(1) NOT NULL DEFAULT false ,
|
152
|
`taxonfit` TEXT NULL DEFAULT NULL ,
|
153
|
`taxonconfidence` TEXT NULL DEFAULT NULL ,
|
154
|
`grouptype` TEXT NULL DEFAULT NULL ,
|
155
|
`notes` TEXT NULL DEFAULT NULL ,
|
156
|
`notespublic` INT(1) NULL DEFAULT NULL ,
|
157
|
`notesmgt` INT(1) NULL DEFAULT NULL ,
|
158
|
`revisions` INT(1) NULL DEFAULT NULL ,
|
159
|
`determinationdate` TIMESTAMP NULL DEFAULT NULL ,
|
160
|
`taxonverbatim_id` INT(11) NULL DEFAULT NULL ,
|
161
|
PRIMARY KEY (`taxondetermination_id`) ,
|
162
|
INDEX `fk_taxondetermination_taxonverbatim1` (`taxonverbatim_id` ASC) ,
|
163
|
INDEX `fk_taxondetermination_reference1` (`determination_reference_id` ASC) ,
|
164
|
CONSTRAINT `fk_taxondetermination_taxonverbatim1`
|
165
|
FOREIGN KEY (`taxonverbatim_id` )
|
166
|
REFERENCES `default_schema`.`taxonverbatim` (`taxonverbatim_id` )
|
167
|
ON DELETE NO ACTION
|
168
|
ON UPDATE NO ACTION,
|
169
|
CONSTRAINT `fk_taxondetermination_reference1`
|
170
|
FOREIGN KEY (`determination_reference_id` )
|
171
|
REFERENCES `default_schema`.`reference` (`reference_id` )
|
172
|
ON DELETE NO ACTION
|
173
|
ON UPDATE NO ACTION);
|
174
|
|
175
|
|
176
|
-- -----------------------------------------------------
|
177
|
-- Table `default_schema`.`taxonstatus`
|
178
|
-- -----------------------------------------------------
|
179
|
DROP TABLE IF EXISTS `default_schema`.`taxonstatus` ;
|
180
|
|
181
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxonstatus` (
|
182
|
`taxonstatus_id` INT(11) NOT NULL ,
|
183
|
`taxonconcept_id` INT(11) NOT NULL ,
|
184
|
`party_id` INT(11) NULL DEFAULT NULL ,
|
185
|
`taxonconceptstatus` VARCHAR(250) NOT NULL DEFAULT 'undetermined' ,
|
186
|
`reference_id` INT(11) NULL DEFAULT NULL ,
|
187
|
`taxonpartycomments` TEXT NULL DEFAULT NULL ,
|
188
|
`startdate` TIMESTAMP NULL DEFAULT NULL ,
|
189
|
`stopdate` TIMESTAMP NULL DEFAULT NULL ,
|
190
|
PRIMARY KEY (`taxonstatus_id`) ,
|
191
|
UNIQUE INDEX `taxonstatus_unique` (`taxonconcept_id` ASC, `party_id` ASC) ,
|
192
|
CONSTRAINT `taxonstatus_taxonconcept_id_fkey`
|
193
|
FOREIGN KEY (`taxonconcept_id` )
|
194
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
195
|
ON DELETE CASCADE
|
196
|
ON UPDATE CASCADE);
|
197
|
|
198
|
|
199
|
-- -----------------------------------------------------
|
200
|
-- Table `default_schema`.`taxoncorrelation`
|
201
|
-- -----------------------------------------------------
|
202
|
DROP TABLE IF EXISTS `default_schema`.`taxoncorrelation` ;
|
203
|
|
204
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxoncorrelation` (
|
205
|
`taxoncorrelation_id` INT(11) NOT NULL ,
|
206
|
`taxonstatus_id` INT(11) NOT NULL ,
|
207
|
`taxonconcept_id` INT(11) NOT NULL ,
|
208
|
`taxonconcept_id` INT(11) NOT NULL ,
|
209
|
`plantconvergence` TEXT NOT NULL ,
|
210
|
`correlationstart` TIMESTAMP NOT NULL ,
|
211
|
`correlationstop` TIMESTAMP NULL DEFAULT NULL ,
|
212
|
PRIMARY KEY (`taxoncorrelation_id`) ,
|
213
|
INDEX `taxoncorrelation_taxonstatus_id_fkey` (`taxonstatus_id` ASC) ,
|
214
|
INDEX `fk_taxoncorrelation_taxonconcept1` (`taxonconcept_id` ASC) ,
|
215
|
CONSTRAINT `taxoncorrelation_taxonstatus_id_fkey`
|
216
|
FOREIGN KEY (`taxonstatus_id` )
|
217
|
REFERENCES `default_schema`.`taxonstatus` (`taxonstatus_id` )
|
218
|
ON DELETE CASCADE
|
219
|
ON UPDATE CASCADE,
|
220
|
CONSTRAINT `fk_taxoncorrelation_taxonconcept1`
|
221
|
FOREIGN KEY (`taxonconcept_id` )
|
222
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
223
|
ON DELETE NO ACTION
|
224
|
ON UPDATE NO ACTION);
|
225
|
|
226
|
|
227
|
-- -----------------------------------------------------
|
228
|
-- Table `default_schema`.`taxonlineage`
|
229
|
-- -----------------------------------------------------
|
230
|
DROP TABLE IF EXISTS `default_schema`.`taxonlineage` ;
|
231
|
|
232
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxonlineage` (
|
233
|
`taxonlineage_id` INT(11) NOT NULL ,
|
234
|
`childtaxonstatus_id` INT(11) NOT NULL ,
|
235
|
`parenttaxonstatus_id` INT(11) NOT NULL ,
|
236
|
PRIMARY KEY (`taxonlineage_id`) ,
|
237
|
INDEX `taxonlineage_childtaxonstatus_id_fkey` (`childtaxonstatus_id` ASC) ,
|
238
|
INDEX `taxonlineage_parenttaxonstatus_id_fkey` (`parenttaxonstatus_id` ASC) ,
|
239
|
CONSTRAINT `taxonlineage_childtaxonstatus_id_fkey`
|
240
|
FOREIGN KEY (`childtaxonstatus_id` )
|
241
|
REFERENCES `default_schema`.`taxonstatus` (`taxonstatus_id` )
|
242
|
ON DELETE CASCADE
|
243
|
ON UPDATE CASCADE,
|
244
|
CONSTRAINT `taxonlineage_parenttaxonstatus_id_fkey`
|
245
|
FOREIGN KEY (`parenttaxonstatus_id` )
|
246
|
REFERENCES `default_schema`.`taxonstatus` (`taxonstatus_id` )
|
247
|
ON DELETE CASCADE
|
248
|
ON UPDATE CASCADE);
|
249
|
|
250
|
|
251
|
-- -----------------------------------------------------
|
252
|
-- Table `default_schema`.`taxonclassification`
|
253
|
-- -----------------------------------------------------
|
254
|
DROP TABLE IF EXISTS `default_schema`.`taxonclassification` ;
|
255
|
|
256
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxonclassification` (
|
257
|
`taxonclassification_id` INT NOT NULL ,
|
258
|
`taxonconcept_id` INT(11) NOT NULL ,
|
259
|
`parent_taxonconcept_id` INT(11) NOT NULL ,
|
260
|
PRIMARY KEY (`taxonclassification_id`) ,
|
261
|
INDEX `fk_taxonclassification_taxonconcept1` (`taxonconcept_id` ASC) ,
|
262
|
INDEX `fk_taxonclassification_taxonconcept2` (`parent_taxonconcept_id` ASC) ,
|
263
|
CONSTRAINT `fk_taxonclassification_taxonconcept1`
|
264
|
FOREIGN KEY (`taxonconcept_id` )
|
265
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
266
|
ON DELETE NO ACTION
|
267
|
ON UPDATE NO ACTION,
|
268
|
CONSTRAINT `fk_taxonclassification_taxonconcept2`
|
269
|
FOREIGN KEY (`parent_taxonconcept_id` )
|
270
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
271
|
ON DELETE NO ACTION
|
272
|
ON UPDATE NO ACTION)
|
273
|
ENGINE = InnoDB;
|
274
|
|
275
|
|
276
|
-- -----------------------------------------------------
|
277
|
-- Table `default_schema`.`taxon`
|
278
|
-- -----------------------------------------------------
|
279
|
DROP TABLE IF EXISTS `default_schema`.`taxon` ;
|
280
|
|
281
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxon` (
|
282
|
`taxon_id` INT NOT NULL ,
|
283
|
`taxonrank` VARCHAR(45) NOT NULL ,
|
284
|
`scientificname` VARCHAR(100) NOT NULL ,
|
285
|
`scientificnameauthorship` VARCHAR(150) NULL ,
|
286
|
`authorship_reference_id` INT NULL ,
|
287
|
PRIMARY KEY (`taxon_id`) ,
|
288
|
INDEX `fk_taxon_reference2` (`authorship_reference_id` ASC) ,
|
289
|
CONSTRAINT `fk_taxon_reference2`
|
290
|
FOREIGN KEY (`authorship_reference_id` )
|
291
|
REFERENCES `default_schema`.`reference` (`reference_id` )
|
292
|
ON DELETE NO ACTION
|
293
|
ON UPDATE NO ACTION)
|
294
|
ENGINE = InnoDB;
|
295
|
|
296
|
|
297
|
-- -----------------------------------------------------
|
298
|
-- Table `default_schema`.`taxonclassification`
|
299
|
-- -----------------------------------------------------
|
300
|
DROP TABLE IF EXISTS `default_schema`.`taxonclassification` ;
|
301
|
|
302
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxonclassification` (
|
303
|
`taxonclassification_id` INT NOT NULL ,
|
304
|
`taxonconcept_id` INT(11) NOT NULL ,
|
305
|
`parent_taxonconcept_id` INT(11) NOT NULL ,
|
306
|
PRIMARY KEY (`taxonclassification_id`) ,
|
307
|
INDEX `fk_taxonclassification_taxonconcept1` (`taxonconcept_id` ASC) ,
|
308
|
INDEX `fk_taxonclassification_taxonconcept2` (`parent_taxonconcept_id` ASC) ,
|
309
|
CONSTRAINT `fk_taxonclassification_taxonconcept1`
|
310
|
FOREIGN KEY (`taxonconcept_id` )
|
311
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
312
|
ON DELETE NO ACTION
|
313
|
ON UPDATE NO ACTION,
|
314
|
CONSTRAINT `fk_taxonclassification_taxonconcept2`
|
315
|
FOREIGN KEY (`parent_taxonconcept_id` )
|
316
|
REFERENCES `default_schema`.`taxonconcept` (`taxonconcept_id` )
|
317
|
ON DELETE NO ACTION
|
318
|
ON UPDATE NO ACTION)
|
319
|
ENGINE = InnoDB;
|
320
|
|
321
|
|
322
|
-- -----------------------------------------------------
|
323
|
-- Table `default_schema`.`taxonclassification_reference`
|
324
|
-- -----------------------------------------------------
|
325
|
DROP TABLE IF EXISTS `default_schema`.`taxonclassification_reference` ;
|
326
|
|
327
|
CREATE TABLE IF NOT EXISTS `default_schema`.`taxonclassification_reference` (
|
328
|
`taxonclassification_reference_id` INT NOT NULL ,
|
329
|
`taxonclassification_id` INT NOT NULL ,
|
330
|
`reference_id` INT NOT NULL ,
|
331
|
`taxonclassification_start` TIMESTAMP NULL ,
|
332
|
`taxonclassification_stop` TIMESTAMP NULL ,
|
333
|
PRIMARY KEY (`taxonclassification_reference_id`) ,
|
334
|
INDEX `fk_taxonclassification_reference_taxonclassification1` (`taxonclassification_id` ASC) ,
|
335
|
INDEX `fk_taxonclassification_reference_reference1` (`reference_id` ASC) ,
|
336
|
CONSTRAINT `fk_taxonclassification_reference_taxonclassification1`
|
337
|
FOREIGN KEY (`taxonclassification_id` )
|
338
|
REFERENCES `default_schema`.`taxonclassification` (`taxonclassification_id` )
|
339
|
ON DELETE NO ACTION
|
340
|
ON UPDATE NO ACTION,
|
341
|
CONSTRAINT `fk_taxonclassification_reference_reference1`
|
342
|
FOREIGN KEY (`reference_id` )
|
343
|
REFERENCES `default_schema`.`reference` (`reference_id` )
|
344
|
ON DELETE NO ACTION
|
345
|
ON UPDATE NO ACTION)
|
346
|
ENGINE = InnoDB;
|
347
|
|
348
|
|
349
|
|
350
|
SET SQL_MODE=@OLD_SQL_MODE;
|
351
|
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
352
|
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|