Project

General

Profile

« Previous | Next » 

Revision 5608

schemas/vegbien.sql: Renamed taxonconcept to taxonlabel per today's conference call, where it was decided that taxonconcept contained too many unrelated fields to be purely a taxon concept

View differences:

vegbien.my.sql
110 110

  
111 111

  
112 112
--
113
-- Name: _taxonconcept_set_matched_concept_id(int(11), int(11), double precision); Type: FUNCTION; Schema: public; Owner: -
113
-- Name: _taxonlabel_set_matched_label_id(int(11), int(11), double precision); Type: FUNCTION; Schema: public; Owner: -
114 114
--
115 115

  
116 116

  
117 117

  
118 118

  
119 119
--
120
-- Name: _taxonconcept_set_parent_id(int(11), int(11)); Type: FUNCTION; Schema: public; Owner: -
120
-- Name: _taxonlabel_set_parent_id(int(11), int(11)); Type: FUNCTION; Schema: public; Owner: -
121 121
--
122 122

  
123 123

  
......
159 159

  
160 160

  
161 161
--
162
-- Name: taxonconcept_0_matched_concept_id_self_ref(); Type: FUNCTION; Schema: public; Owner: -
162
-- Name: taxonlabel_0_matched_label_id_self_ref(); Type: FUNCTION; Schema: public; Owner: -
163 163
--
164 164

  
165 165

  
166 166

  
167 167

  
168 168
--
169
-- Name: taxonconcept_1_matched_concept_min_fit(); Type: FUNCTION; Schema: public; Owner: -
169
-- Name: taxonlabel_1_matched_label_min_fit(); Type: FUNCTION; Schema: public; Owner: -
170 170
--
171 171

  
172 172

  
173 173

  
174 174

  
175 175
--
176
-- Name: taxonconcept_2_propagate_accepted_concept_id(); Type: FUNCTION; Schema: public; Owner: -
176
-- Name: taxonlabel_2_propagate_accepted_label_id(); Type: FUNCTION; Schema: public; Owner: -
177 177
--
178 178

  
179 179

  
180 180

  
181 181

  
182 182
--
183
-- Name: taxonconcept_3_parent_id_avoid_self_ref(); Type: FUNCTION; Schema: public; Owner: -
183
-- Name: taxonlabel_3_parent_id_avoid_self_ref(); Type: FUNCTION; Schema: public; Owner: -
184 184
--
185 185

  
186 186

  
......
191 191

  
192 192

  
193 193
--
194
-- Name: taxonconcept; Type: TABLE; Schema: public; Owner: -; Tablespace: 
194
-- Name: taxonlabel; Type: TABLE; Schema: public; Owner: -; Tablespace: 
195 195
--
196 196

  
197
CREATE TABLE taxonconcept (
198
    taxonconcept_id int(11) NOT NULL,
197
CREATE TABLE taxonlabel (
198
    taxonlabel_id int(11) NOT NULL,
199 199
    creator_id int(11) NOT NULL,
200 200
    sourceaccessioncode text,
201 201
    creationdate date,
202
    accepted_concept_id int(11),
203
    matched_concept_id int(11),
204
    matched_concept_fit_fraction double precision,
202
    accepted_label_id int(11),
203
    matched_label_id int(11),
204
    matched_label_fit_fraction double precision,
205 205
    parent_id int(11),
206 206
    taxonepithet text,
207 207
    rank text,
......
219 219

  
220 220

  
221 221
--
222
-- Name: TABLE taxonconcept; Type: COMMENT; Schema: public; Owner: -
222
-- Name: TABLE taxonlabel; Type: COMMENT; Schema: public; Owner: -
223 223
--
224 224

  
225 225

  
226 226

  
227 227

  
228 228
--
229
-- Name: COLUMN taxonconcept.creator_id; Type: COMMENT; Schema: public; Owner: -
229
-- Name: COLUMN taxonlabel.creator_id; Type: COMMENT; Schema: public; Owner: -
230 230
--
231 231

  
232 232

  
233 233

  
234 234

  
235 235
--
236
-- Name: COLUMN taxonconcept.sourceaccessioncode; Type: COMMENT; Schema: public; Owner: -
236
-- Name: COLUMN taxonlabel.sourceaccessioncode; Type: COMMENT; Schema: public; Owner: -
237 237
--
238 238

  
239 239

  
240 240

  
241 241

  
242 242
--
243
-- Name: COLUMN taxonconcept.creationdate; Type: COMMENT; Schema: public; Owner: -
243
-- Name: COLUMN taxonlabel.creationdate; Type: COMMENT; Schema: public; Owner: -
244 244
--
245 245

  
246 246

  
247 247

  
248 248

  
249 249
--
250
-- Name: COLUMN taxonconcept.accepted_concept_id; Type: COMMENT; Schema: public; Owner: -
250
-- Name: COLUMN taxonlabel.accepted_label_id; Type: COMMENT; Schema: public; Owner: -
251 251
--
252 252

  
253 253

  
254 254

  
255 255

  
256 256
--
257
-- Name: COLUMN taxonconcept.matched_concept_id; Type: COMMENT; Schema: public; Owner: -
257
-- Name: COLUMN taxonlabel.matched_label_id; Type: COMMENT; Schema: public; Owner: -
258 258
--
259 259

  
260 260

  
261 261

  
262 262

  
263 263
--
264
-- Name: COLUMN taxonconcept.matched_concept_fit_fraction; Type: COMMENT; Schema: public; Owner: -
264
-- Name: COLUMN taxonlabel.matched_label_fit_fraction; Type: COMMENT; Schema: public; Owner: -
265 265
--
266 266

  
267 267

  
268 268

  
269 269

  
270 270
--
271
-- Name: COLUMN taxonconcept.parent_id; Type: COMMENT; Schema: public; Owner: -
271
-- Name: COLUMN taxonlabel.parent_id; Type: COMMENT; Schema: public; Owner: -
272 272
--
273 273

  
274 274

  
275 275

  
276 276

  
277 277
--
278
-- Name: COLUMN taxonconcept.taxonepithet; Type: COMMENT; Schema: public; Owner: -
278
-- Name: COLUMN taxonlabel.taxonepithet; Type: COMMENT; Schema: public; Owner: -
279 279
--
280 280

  
281 281

  
282 282

  
283 283

  
284 284
--
285
-- Name: COLUMN taxonconcept.rank; Type: COMMENT; Schema: public; Owner: -
285
-- Name: COLUMN taxonlabel.rank; Type: COMMENT; Schema: public; Owner: -
286 286
--
287 287

  
288 288

  
289 289

  
290 290

  
291 291
--
292
-- Name: COLUMN taxonconcept.verbatimrank; Type: COMMENT; Schema: public; Owner: -
292
-- Name: COLUMN taxonlabel.verbatimrank; Type: COMMENT; Schema: public; Owner: -
293 293
--
294 294

  
295 295

  
296 296

  
297 297

  
298 298
--
299
-- Name: COLUMN taxonconcept.identifyingtaxonomicname; Type: COMMENT; Schema: public; Owner: -
299
-- Name: COLUMN taxonlabel.identifyingtaxonomicname; Type: COMMENT; Schema: public; Owner: -
300 300
--
301 301

  
302 302

  
303 303

  
304 304

  
305 305
--
306
-- Name: COLUMN taxonconcept.taxonomicname; Type: COMMENT; Schema: public; Owner: -
306
-- Name: COLUMN taxonlabel.taxonomicname; Type: COMMENT; Schema: public; Owner: -
307 307
--
308 308

  
309 309

  
310 310

  
311 311

  
312 312
--
313
-- Name: COLUMN taxonconcept.author; Type: COMMENT; Schema: public; Owner: -
313
-- Name: COLUMN taxonlabel.author; Type: COMMENT; Schema: public; Owner: -
314 314
--
315 315

  
316 316

  
317 317

  
318 318

  
319 319
--
320
-- Name: COLUMN taxonconcept.taxonomicnamewithauthor; Type: COMMENT; Schema: public; Owner: -
320
-- Name: COLUMN taxonlabel.taxonomicnamewithauthor; Type: COMMENT; Schema: public; Owner: -
321 321
--
322 322

  
323 323

  
324 324

  
325 325

  
326 326
--
327
-- Name: COLUMN taxonconcept.family; Type: COMMENT; Schema: public; Owner: -
327
-- Name: COLUMN taxonlabel.family; Type: COMMENT; Schema: public; Owner: -
328 328
--
329 329

  
330 330

  
331 331

  
332 332

  
333 333
--
334
-- Name: COLUMN taxonconcept.genus; Type: COMMENT; Schema: public; Owner: -
334
-- Name: COLUMN taxonlabel.genus; Type: COMMENT; Schema: public; Owner: -
335 335
--
336 336

  
337 337

  
338 338

  
339 339

  
340 340
--
341
-- Name: COLUMN taxonconcept.species; Type: COMMENT; Schema: public; Owner: -
341
-- Name: COLUMN taxonlabel.species; Type: COMMENT; Schema: public; Owner: -
342 342
--
343 343

  
344 344

  
345 345

  
346 346

  
347 347
--
348
-- Name: taxonconcept_update_ancestors(taxonconcept, int(11)); Type: FUNCTION; Schema: public; Owner: -
348
-- Name: taxonlabel_update_ancestors(taxonlabel, int(11)); Type: FUNCTION; Schema: public; Owner: -
349 349
--
350 350

  
351 351

  
352 352

  
353 353

  
354 354
--
355
-- Name: taxonconcept_update_ancestors_on_insert(); Type: FUNCTION; Schema: public; Owner: -
355
-- Name: taxonlabel_update_ancestors_on_insert(); Type: FUNCTION; Schema: public; Owner: -
356 356
--
357 357

  
358 358

  
359 359

  
360 360

  
361 361
--
362
-- Name: taxonconcept_update_ancestors_on_update(); Type: FUNCTION; Schema: public; Owner: -
362
-- Name: taxonlabel_update_ancestors_on_update(); Type: FUNCTION; Schema: public; Owner: -
363 363
--
364 364

  
365 365

  
......
985 985
CREATE TABLE taxondetermination (
986 986
    taxondetermination_id int(11) NOT NULL,
987 987
    taxonoccurrence_id int(11) NOT NULL,
988
    taxonconcept_id int(11) NOT NULL,
988
    taxonlabel_id int(11) NOT NULL,
989 989
    party_id int(11),
990 990
    role text DEFAULT 'unknown' NOT NULL,
991 991
    determinationtype text,
......
1063 1063
--
1064 1064

  
1065 1065
CREATE VIEW analytical_db_view AS
1066
    SELECT datasource.organizationname AS `dataSourceName`, accepted_taxonconcept.family, accepted_taxonconcept.genus, accepted_taxonconcept.species, COALESCE(accepted_taxonconcept.taxonomicnamewithauthor, accepted_taxonconcept.taxonomicname) AS taxon, accepted_taxonconcept.author AS `taxonAuthor`, accepted_taxonconcept.taxonepithet AS `taxonMorphospecies`, placepath.country, placepath.stateprovince AS `stateProvince`, placepath.county AS `countyParish`, taxonoccurrence.verbatimcollectorname AS collector, plantobservation.collectionnumber AS `collectionNumber`, array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], CAST(' ' AS text)) AS `identifiedBy`, aggregateoccurrence.collectiondate AS `observationDate`, location.authorlocationcode AS `plotCode`, functions._m2_to_ha(location.area_m2) AS `plotAreaHa`, method.name AS `plotMethod`, locationcoords.latitude_deg AS latitude, locationcoords.longitude_deg AS longitude, location.elevation_m, taxonoccurrence.iscultivated AS `isCultivated`, taxonoccurrence.cultivatedbasis AS `isCultivatedReason`, _fraction_to_percent(aggregateoccurrence.cover_fraction) AS `pctCover` FROM ((((((((((((((location JOIN party datasource ON (((datasource.party_id = location.creator_id) AND (datasource.organizationname IS NOT NULL)))) LEFT JOIN locationcoords USING (location_id)) LEFT JOIN locationplace USING (location_id)) LEFT JOIN placepath USING (placepath_id)) JOIN locationevent USING (location_id)) LEFT JOIN method USING (method_id)) JOIN taxonoccurrence USING (locationevent_id)) JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) JOIN taxonconcept datasource_taxonconcept USING (taxonconcept_id)) JOIN taxonconcept accepted_taxonconcept ON ((accepted_taxonconcept.taxonconcept_id = datasource_taxonconcept.accepted_concept_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN specimenreplicate USING (plantobservation_id));
1066
    SELECT datasource.organizationname AS `dataSourceName`, accepted_taxonlabel.family, accepted_taxonlabel.genus, accepted_taxonlabel.species, COALESCE(accepted_taxonlabel.taxonomicnamewithauthor, accepted_taxonlabel.taxonomicname) AS taxon, accepted_taxonlabel.author AS `taxonAuthor`, accepted_taxonlabel.taxonepithet AS `taxonMorphospecies`, placepath.country, placepath.stateprovince AS `stateProvince`, placepath.county AS `countyParish`, taxonoccurrence.verbatimcollectorname AS collector, plantobservation.collectionnumber AS `collectionNumber`, array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], CAST(' ' AS text)) AS `identifiedBy`, aggregateoccurrence.collectiondate AS `observationDate`, location.authorlocationcode AS `plotCode`, functions._m2_to_ha(location.area_m2) AS `plotAreaHa`, method.name AS `plotMethod`, locationcoords.latitude_deg AS latitude, locationcoords.longitude_deg AS longitude, location.elevation_m, taxonoccurrence.iscultivated AS `isCultivated`, taxonoccurrence.cultivatedbasis AS `isCultivatedReason`, _fraction_to_percent(aggregateoccurrence.cover_fraction) AS `pctCover` FROM ((((((((((((((location JOIN party datasource ON (((datasource.party_id = location.creator_id) AND (datasource.organizationname IS NOT NULL)))) LEFT JOIN locationcoords USING (location_id)) LEFT JOIN locationplace USING (location_id)) LEFT JOIN placepath USING (placepath_id)) JOIN locationevent USING (location_id)) LEFT JOIN method USING (method_id)) JOIN taxonoccurrence USING (locationevent_id)) JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.accepted_label_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN specimenreplicate USING (plantobservation_id));
1067 1067

  
1068 1068

  
1069 1069
--
......
1620 1620
CREATE TABLE methodtaxonclass (
1621 1621
    methodtaxonclass_id int(11) NOT NULL,
1622 1622
    method_id int(11) NOT NULL,
1623
    taxonconcept_id int(11),
1623
    taxonlabel_id int(11),
1624 1624
    included int(1) NOT NULL,
1625 1625
    submethod_id int(11),
1626 1626
    taxonclass text
......
2351 2351
CREATE TABLE taxonalt (
2352 2352
    taxonalt_id int(11) NOT NULL,
2353 2353
    taxondetermination_id int(11) NOT NULL,
2354
    taxonconcept_id int(11) NOT NULL,
2354
    taxonlabel_id int(11) NOT NULL,
2355 2355
    taxonaltfit text,
2356 2356
    taxonaltconfidence text,
2357 2357
    taxonaltnotes text
......
2373 2373

  
2374 2374

  
2375 2375
--
2376
-- Name: taxonconcept_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2376
-- Name: taxoncorrelation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2377 2377
--
2378 2378

  
2379
CREATE TABLE taxonconcept_ancestor (
2380
    descendant_id int(11) NOT NULL,
2381
    ancestor_id int(11) NOT NULL
2379
CREATE TABLE taxoncorrelation (
2380
    taxoncorrelation_id int(11) NOT NULL,
2381
    taxonstatus_id int(11) NOT NULL,
2382
    taxonlabel_id int(11) NOT NULL,
2383
    plantconvergence text NOT NULL,
2384
    correlationstart date NOT NULL,
2385
    correlationstop date
2382 2386
);
2383 2387

  
2384 2388

  
2385 2389
--
2386
-- Name: TABLE taxonconcept_ancestor; Type: COMMENT; Schema: public; Owner: -
2390
-- Name: taxoncorrelation_taxoncorrelation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2387 2391
--
2388 2392

  
2389 2393

  
2390 2394

  
2391 2395

  
2392 2396
--
2393
-- Name: taxonconcept_taxonconcept_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2397
-- Name: taxoncorrelation_taxoncorrelation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2394 2398
--
2395 2399

  
2396 2400

  
2397 2401

  
2398 2402

  
2399 2403
--
2400
-- Name: taxonconcept_taxonconcept_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2404
-- Name: taxondetermination_taxondetermination_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2401 2405
--
2402 2406

  
2403 2407

  
2404 2408

  
2405 2409

  
2406 2410
--
2407
-- Name: taxoncorrelation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2411
-- Name: taxondetermination_taxondetermination_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2408 2412
--
2409 2413

  
2410
CREATE TABLE taxoncorrelation (
2411
    taxoncorrelation_id int(11) NOT NULL,
2412
    taxonstatus_id int(11) NOT NULL,
2413
    taxonconcept_id int(11) NOT NULL,
2414
    plantconvergence text NOT NULL,
2415
    correlationstart date NOT NULL,
2416
    correlationstop date
2417
);
2418 2414

  
2419 2415

  
2416

  
2420 2417
--
2421
-- Name: taxoncorrelation_taxoncorrelation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2418
-- Name: taxonlabel_ancestor; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2422 2419
--
2423 2420

  
2421
CREATE TABLE taxonlabel_ancestor (
2422
    descendant_id int(11) NOT NULL,
2423
    ancestor_id int(11) NOT NULL
2424
);
2424 2425

  
2425 2426

  
2426

  
2427 2427
--
2428
-- Name: taxoncorrelation_taxoncorrelation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2428
-- Name: TABLE taxonlabel_ancestor; Type: COMMENT; Schema: public; Owner: -
2429 2429
--
2430 2430

  
2431 2431

  
2432 2432

  
2433 2433

  
2434 2434
--
2435
-- Name: taxondetermination_taxondetermination_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2435
-- Name: taxonlabel_taxonlabel_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2436 2436
--
2437 2437

  
2438 2438

  
2439 2439

  
2440 2440

  
2441 2441
--
2442
-- Name: taxondetermination_taxondetermination_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2442
-- Name: taxonlabel_taxonlabel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2443 2443
--
2444 2444

  
2445 2445

  
......
2490 2490

  
2491 2491
CREATE TABLE taxonstatus (
2492 2492
    taxonstatus_id int(11) NOT NULL,
2493
    taxonconcept_id int(11) NOT NULL,
2493
    taxonlabel_id int(11) NOT NULL,
2494 2494
    party_id int(11),
2495
    taxonconceptstatus text DEFAULT 'undetermined' NOT NULL,
2495
    taxonlabelstatus text DEFAULT 'undetermined' NOT NULL,
2496 2496
    reference_id int(11),
2497 2497
    plantpartycomments text,
2498 2498
    startdate date,
......
2521 2521

  
2522 2522
CREATE TABLE taxonusage (
2523 2523
    taxonusage_id int(11) NOT NULL,
2524
    taxonconcept_id int(11) NOT NULL,
2524
    taxonlabel_id int(11) NOT NULL,
2525 2525
    taxonstatus text,
2526 2526
    taxon text,
2527 2527
    classsystem text,
......
2990 2990

  
2991 2991

  
2992 2992
--
2993
-- Name: taxonconcept_id; Type: DEFAULT; Schema: public; Owner: -
2993
-- Name: taxoncorrelation_id; Type: DEFAULT; Schema: public; Owner: -
2994 2994
--
2995 2995

  
2996 2996

  
2997 2997

  
2998 2998

  
2999 2999
--
3000
-- Name: taxoncorrelation_id; Type: DEFAULT; Schema: public; Owner: -
3000
-- Name: taxondetermination_id; Type: DEFAULT; Schema: public; Owner: -
3001 3001
--
3002 3002

  
3003 3003

  
3004 3004

  
3005 3005

  
3006 3006
--
3007
-- Name: taxondetermination_id; Type: DEFAULT; Schema: public; Owner: -
3007
-- Name: taxonlabel_id; Type: DEFAULT; Schema: public; Owner: -
3008 3008
--
3009 3009

  
3010 3010

  
......
3299 3299

  
3300 3300

  
3301 3301
--
3302
-- Name: methodtaxonclass_unique_taxonconcept_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3302
-- Name: methodtaxonclass_unique_taxonlabel_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3303 3303
--
3304 3304

  
3305 3305
ALTER TABLE methodtaxonclass
3306
    ADD CONSTRAINT methodtaxonclass_unique_taxonconcept_id UNIQUE (method_id, taxonconcept_id);
3306
    ADD CONSTRAINT methodtaxonclass_unique_taxonlabel_id UNIQUE (method_id, taxonlabel_id);
3307 3307

  
3308 3308

  
3309 3309
--
......
3523 3523

  
3524 3524

  
3525 3525
--
3526
-- Name: taxonconcept_ancestor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3526
-- Name: taxoncorrelation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3527 3527
--
3528 3528

  
3529
ALTER TABLE taxonconcept_ancestor
3530
    ADD CONSTRAINT taxonconcept_ancestor_pkey PRIMARY KEY (descendant_id, ancestor_id);
3529
ALTER TABLE taxoncorrelation
3530
    ADD CONSTRAINT taxoncorrelation_pkey PRIMARY KEY (taxoncorrelation_id);
3531 3531

  
3532 3532

  
3533 3533
--
3534
-- Name: taxonconcept_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3534
-- Name: taxondetermination_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3535 3535
--
3536 3536

  
3537
ALTER TABLE taxonconcept
3538
    ADD CONSTRAINT taxonconcept_pkey PRIMARY KEY (taxonconcept_id);
3537
ALTER TABLE taxondetermination
3538
    ADD CONSTRAINT taxondetermination_pkey PRIMARY KEY (taxondetermination_id);
3539 3539

  
3540 3540

  
3541 3541
--
3542
-- Name: taxoncorrelation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3542
-- Name: taxonlabel_ancestor_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3543 3543
--
3544 3544

  
3545
ALTER TABLE taxoncorrelation
3546
    ADD CONSTRAINT taxoncorrelation_pkey PRIMARY KEY (taxoncorrelation_id);
3545
ALTER TABLE taxonlabel_ancestor
3546
    ADD CONSTRAINT taxonlabel_ancestor_pkey PRIMARY KEY (descendant_id, ancestor_id);
3547 3547

  
3548 3548

  
3549 3549
--
3550
-- Name: taxondetermination_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3550
-- Name: taxonlabel_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3551 3551
--
3552 3552

  
3553
ALTER TABLE taxondetermination
3554
    ADD CONSTRAINT taxondetermination_pkey PRIMARY KEY (taxondetermination_id);
3553
ALTER TABLE taxonlabel
3554
    ADD CONSTRAINT taxonlabel_pkey PRIMARY KEY (taxonlabel_id);
3555 3555

  
3556 3556

  
3557 3557
--
......
3583 3583
--
3584 3584

  
3585 3585
ALTER TABLE taxonstatus
3586
    ADD CONSTRAINT taxonstatus_unique UNIQUE (taxonconcept_id, party_id);
3586
    ADD CONSTRAINT taxonstatus_unique UNIQUE (taxonlabel_id, party_id);
3587 3587

  
3588 3588

  
3589 3589
--
......
3986 3986

  
3987 3987

  
3988 3988
--
3989
-- Name: taxonconcept_0_unique_identifying_name; Type: INDEX; Schema: public; Owner: -; Tablespace: 
3989
-- Name: taxondetermination_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
3990 3990
--
3991 3991

  
3992
CREATE UNIQUE INDEX taxondetermination_accessioncode_index ON taxondetermination  (accessioncode);
3992 3993

  
3993 3994

  
3994

  
3995 3995
--
3996
-- Name: taxonconcept_1_unique_sourceaccessioncode; Type: INDEX; Schema: public; Owner: -; Tablespace: 
3996
-- Name: taxondetermination_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
3997 3997
--
3998 3998

  
3999 3999

  
4000 4000

  
4001 4001

  
4002 4002
--
4003
-- Name: taxonconcept_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4003
-- Name: taxonlabel_0_unique_identifying_name; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4004 4004
--
4005 4005

  
4006
CREATE UNIQUE INDEX taxonconcept_accessioncode_index ON taxonconcept  (accessioncode);
4007 4006

  
4008 4007

  
4008

  
4009 4009
--
4010
-- Name: taxonconcept_ancestor_descendants; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4010
-- Name: taxonlabel_1_unique_sourceaccessioncode; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4011 4011
--
4012 4012

  
4013
CREATE INDEX taxonconcept_ancestor_descendants ON taxonconcept_ancestor  (ancestor_id, descendant_id);
4014 4013

  
4015 4014

  
4015

  
4016 4016
--
4017
-- Name: taxonconcept_matched_concept_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4017
-- Name: taxonlabel_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4018 4018
--
4019 4019

  
4020
CREATE INDEX taxonconcept_matched_concept_id_idx ON taxonconcept  (matched_concept_id);
4020
CREATE UNIQUE INDEX taxonlabel_accessioncode_index ON taxonlabel  (accessioncode);
4021 4021

  
4022 4022

  
4023 4023
--
4024
-- Name: taxonconcept_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4024
-- Name: taxonlabel_ancestor_descendants; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4025 4025
--
4026 4026

  
4027
CREATE INDEX taxonlabel_ancestor_descendants ON taxonlabel_ancestor  (ancestor_id, descendant_id);
4027 4028

  
4028 4029

  
4029

  
4030 4030
--
4031
-- Name: taxondetermination_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4031
-- Name: taxonlabel_matched_label_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4032 4032
--
4033 4033

  
4034
CREATE UNIQUE INDEX taxondetermination_accessioncode_index ON taxondetermination  (accessioncode);
4034
CREATE INDEX taxonlabel_matched_label_id_idx ON taxonlabel  (matched_label_id);
4035 4035

  
4036 4036

  
4037 4037
--
4038
-- Name: taxondetermination_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4038
-- Name: taxonlabel_unique; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4039 4039
--
4040 4040

  
4041 4041

  
......
4112 4112

  
4113 4113

  
4114 4114
--
4115
-- Name: taxonconcept_0_matched_concept_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
4115
-- Name: taxonlabel_0_matched_label_id_self_ref; Type: TRIGGER; Schema: public; Owner: -
4116 4116
--
4117 4117

  
4118 4118

  
4119 4119

  
4120 4120

  
4121 4121
--
4122
-- Name: taxonconcept_1_matched_concept_min_fit; Type: TRIGGER; Schema: public; Owner: -
4122
-- Name: taxonlabel_1_matched_label_min_fit; Type: TRIGGER; Schema: public; Owner: -
4123 4123
--
4124 4124

  
4125 4125

  
4126 4126

  
4127 4127

  
4128 4128
--
4129
-- Name: taxonconcept_2_propagate_accepted_concept_id; Type: TRIGGER; Schema: public; Owner: -
4129
-- Name: taxonlabel_2_propagate_accepted_label_id; Type: TRIGGER; Schema: public; Owner: -
4130 4130
--
4131 4131

  
4132 4132

  
4133 4133

  
4134 4134

  
4135 4135
--
4136
-- Name: taxonconcept_3_parent_id_avoid_self_ref; Type: TRIGGER; Schema: public; Owner: -
4136
-- Name: taxonlabel_3_parent_id_avoid_self_ref; Type: TRIGGER; Schema: public; Owner: -
4137 4137
--
4138 4138

  
4139 4139

  
4140 4140

  
4141 4141

  
4142 4142
--
4143
-- Name: taxonconcept_update_ancestors_on_insert; Type: TRIGGER; Schema: public; Owner: -
4143
-- Name: taxonlabel_update_ancestors_on_insert; Type: TRIGGER; Schema: public; Owner: -
4144 4144
--
4145 4145

  
4146 4146

  
4147 4147

  
4148 4148

  
4149 4149
--
4150
-- Name: taxonconcept_update_ancestors_on_update; Type: TRIGGER; Schema: public; Owner: -
4150
-- Name: taxonlabel_update_ancestors_on_update; Type: TRIGGER; Schema: public; Owner: -
4151 4151
--
4152 4152

  
4153 4153

  
......
4597 4597

  
4598 4598

  
4599 4599
--
4600
-- Name: methodtaxonclass_taxonconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4600
-- Name: methodtaxonclass_taxonlabel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4601 4601
--
4602 4602

  
4603 4603
ALTER TABLE methodtaxonclass
4604
    ADD CONSTRAINT methodtaxonclass_taxonconcept_id_fkey FOREIGN KEY (taxonconcept_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
4604
    ADD CONSTRAINT methodtaxonclass_taxonlabel_id_fkey FOREIGN KEY (taxonlabel_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
4605 4605

  
4606 4606

  
4607 4607
--
......
4884 4884

  
4885 4885

  
4886 4886
--
4887
-- Name: taxonalt_taxonconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4887
-- Name: taxonalt_taxondetermination_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4888 4888
--
4889 4889

  
4890 4890
ALTER TABLE taxonalt
4891
    ADD CONSTRAINT taxonalt_taxonconcept_id_fkey FOREIGN KEY (taxonconcept_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
4891
    ADD CONSTRAINT taxonalt_taxondetermination_id_fkey FOREIGN KEY (taxondetermination_id) REFERENCES taxondetermination(taxondetermination_id) ON UPDATE CASCADE ON DELETE CASCADE;
4892 4892

  
4893 4893

  
4894 4894
--
4895
-- Name: taxonalt_taxondetermination_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4895
-- Name: taxonalt_taxonlabel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4896 4896
--
4897 4897

  
4898 4898
ALTER TABLE taxonalt
4899
    ADD CONSTRAINT taxonalt_taxondetermination_id_fkey FOREIGN KEY (taxondetermination_id) REFERENCES taxondetermination(taxondetermination_id) ON UPDATE CASCADE ON DELETE CASCADE;
4899
    ADD CONSTRAINT taxonalt_taxonlabel_id_fkey FOREIGN KEY (taxonlabel_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
4900 4900

  
4901 4901

  
4902 4902
--
4903
-- Name: taxonconcept_accepted_concept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4903
-- Name: taxoncorrelation_taxonlabel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4904 4904
--
4905 4905

  
4906
ALTER TABLE taxonconcept
4907
    ADD CONSTRAINT taxonconcept_accepted_concept_id_fkey FOREIGN KEY (accepted_concept_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
4908 4906

  
4909 4907

  
4908

  
4910 4909
--
4911
-- Name: taxonconcept_ancestor_ancestor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4910
-- Name: taxoncorrelation_taxonstatus_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4912 4911
--
4913 4912

  
4914
ALTER TABLE taxonconcept_ancestor
4915
    ADD CONSTRAINT taxonconcept_ancestor_ancestor_id_fkey FOREIGN KEY (ancestor_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
4913
ALTER TABLE taxoncorrelation
4914
    ADD CONSTRAINT taxoncorrelation_taxonstatus_id_fkey FOREIGN KEY (taxonstatus_id) REFERENCES taxonstatus(taxonstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;
4916 4915

  
4917 4916

  
4918 4917
--
4919
-- Name: taxonconcept_ancestor_descendant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4918
-- Name: taxondetermination_party_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4920 4919
--
4921 4920

  
4922
ALTER TABLE taxonconcept_ancestor
4923
    ADD CONSTRAINT taxonconcept_ancestor_descendant_id_fkey FOREIGN KEY (descendant_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
4924 4921

  
4925 4922

  
4923

  
4926 4924
--
4927
-- Name: taxonconcept_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4925
-- Name: taxondetermination_reference_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4928 4926
--
4929 4927

  
4930 4928

  
4931 4929

  
4932 4930

  
4933 4931
--
4934
-- Name: taxonconcept_matched_concept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4932
-- Name: taxondetermination_taxonlabel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4935 4933
--
4936 4934

  
4937
ALTER TABLE taxonconcept
4938
    ADD CONSTRAINT taxonconcept_matched_concept_id_fkey FOREIGN KEY (matched_concept_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
4935
ALTER TABLE taxondetermination
4936
    ADD CONSTRAINT taxondetermination_taxonlabel_id_fkey FOREIGN KEY (taxonlabel_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
4939 4937

  
4940 4938

  
4941 4939
--
4942
-- Name: taxonconcept_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4940
-- Name: taxondetermination_taxonoccurrence_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4943 4941
--
4944 4942

  
4945
ALTER TABLE taxonconcept
4946
    ADD CONSTRAINT taxonconcept_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
4943
ALTER TABLE taxondetermination
4944
    ADD CONSTRAINT taxondetermination_taxonoccurrence_id_fkey FOREIGN KEY (taxonoccurrence_id) REFERENCES taxonoccurrence(taxonoccurrence_id) ON UPDATE CASCADE ON DELETE CASCADE;
4947 4945

  
4948 4946

  
4949 4947
--
4950
-- Name: taxoncorrelation_taxonconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4948
-- Name: taxonlabel_accepted_label_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4951 4949
--
4952 4950

  
4951
ALTER TABLE taxonlabel
4952
    ADD CONSTRAINT taxonlabel_accepted_label_id_fkey FOREIGN KEY (accepted_label_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
4953 4953

  
4954 4954

  
4955

  
4956 4955
--
4957
-- Name: taxoncorrelation_taxonstatus_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4956
-- Name: taxonlabel_ancestor_ancestor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4958 4957
--
4959 4958

  
4960
ALTER TABLE taxoncorrelation
4961
    ADD CONSTRAINT taxoncorrelation_taxonstatus_id_fkey FOREIGN KEY (taxonstatus_id) REFERENCES taxonstatus(taxonstatus_id) ON UPDATE CASCADE ON DELETE CASCADE;
4959
ALTER TABLE taxonlabel_ancestor
4960
    ADD CONSTRAINT taxonlabel_ancestor_ancestor_id_fkey FOREIGN KEY (ancestor_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
4962 4961

  
4963 4962

  
4964 4963
--
4965
-- Name: taxondetermination_party_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4964
-- Name: taxonlabel_ancestor_descendant_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4966 4965
--
4967 4966

  
4967
ALTER TABLE taxonlabel_ancestor
4968
    ADD CONSTRAINT taxonlabel_ancestor_descendant_id_fkey FOREIGN KEY (descendant_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
4968 4969

  
4969 4970

  
4970

  
4971 4971
--
4972
-- Name: taxondetermination_reference_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4972
-- Name: taxonlabel_creator_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4973 4973
--
4974 4974

  
4975 4975

  
4976 4976

  
4977 4977

  
4978 4978
--
4979
-- Name: taxondetermination_taxonconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4979
-- Name: taxonlabel_matched_label_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4980 4980
--
4981 4981

  
4982
ALTER TABLE taxondetermination
4983
    ADD CONSTRAINT taxondetermination_taxonconcept_id_fkey FOREIGN KEY (taxonconcept_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
4982
ALTER TABLE taxonlabel
4983
    ADD CONSTRAINT taxonlabel_matched_label_id_fkey FOREIGN KEY (matched_label_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
4984 4984

  
4985 4985

  
4986 4986
--
4987
-- Name: taxondetermination_taxonoccurrence_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4987
-- Name: taxonlabel_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
4988 4988
--
4989 4989

  
4990
ALTER TABLE taxondetermination
4991
    ADD CONSTRAINT taxondetermination_taxonoccurrence_id_fkey FOREIGN KEY (taxonoccurrence_id) REFERENCES taxonoccurrence(taxonoccurrence_id) ON UPDATE CASCADE ON DELETE CASCADE;
4990
ALTER TABLE taxonlabel
4991
    ADD CONSTRAINT taxonlabel_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
4992 4992

  
4993 4993

  
4994 4994
--
......
5037 5037

  
5038 5038

  
5039 5039
--
5040
-- Name: taxonstatus_taxonconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5040
-- Name: taxonstatus_taxonlabel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5041 5041
--
5042 5042

  
5043 5043
ALTER TABLE taxonstatus
5044
    ADD CONSTRAINT taxonstatus_taxonconcept_id_fkey FOREIGN KEY (taxonconcept_id) REFERENCES taxonconcept(taxonconcept_id) ON UPDATE CASCADE ON DELETE CASCADE;
5044
    ADD CONSTRAINT taxonstatus_taxonlabel_id_fkey FOREIGN KEY (taxonlabel_id) REFERENCES taxonlabel(taxonlabel_id) ON UPDATE CASCADE ON DELETE CASCADE;
5045 5045

  
5046 5046

  
5047 5047
--
......
5052 5052

  
5053 5053

  
5054 5054
--
5055
-- Name: taxonusage_taxonconcept_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5055
-- Name: taxonusage_taxonlabel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
5056 5056
--
5057 5057

  
5058 5058

  

Also available in: Unified diff