Project

General

Profile

« Previous | Next » 

Revision 519

vegbien.sql: Split taxondetermination UNIQUE CONSTRAINT into one constraint for each main key (taxonoccurrence_id, specimen_id, individualplant_id) to deal with Postgres treating a row with NULL in any of those columns as distinct. Added CHECK constraint to require one of taxonoccurrence_id, specimen_id, individualplant_id to be NOT NULL.

View differences:

schemas/vegbien.sql
2500 2500

  
2501 2501
CREATE TABLE taxondetermination (
2502 2502
    taxondetermination_id integer NOT NULL,
2503
    taxonoccurrence_id integer NOT NULL,
2503
    taxonoccurrence_id integer,
2504 2504
    individualplant_id integer,
2505 2505
    plantconcept_id integer,
2506 2506
    plantname_id integer NOT NULL,
......
2522 2522
    determinationdate timestamp with time zone NOT NULL,
2523 2523
    emb_taxondetermination integer,
2524 2524
    accessioncode character varying(255),
2525
    specimen_id integer
2525
    specimen_id integer,
2526
    CONSTRAINT taxondetermination_required_keys CHECK ((((taxonoccurrence_id IS NOT NULL) OR (individualplant_id IS NOT NULL)) OR (specimen_id IS NOT NULL)))
2526 2527
);
2527 2528

  
2528 2529

  
......
4355 4356

  
4356 4357

  
4357 4358
--
4358
-- Name: taxondetermination_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4359
-- Name: taxondetermination_keys_individualplant_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4359 4360
--
4360 4361

  
4361 4362
ALTER TABLE ONLY taxondetermination
4362
    ADD CONSTRAINT taxondetermination_keys UNIQUE (taxonoccurrence_id, individualplant_id, role_id, plantname_id, sourceaccessionnumber);
4363
    ADD CONSTRAINT taxondetermination_keys_individualplant_id UNIQUE (individualplant_id, role_id, plantname_id);
4363 4364

  
4364 4365

  
4365 4366
--
4367
-- Name: taxondetermination_keys_specimen_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4368
--
4369

  
4370
ALTER TABLE ONLY taxondetermination
4371
    ADD CONSTRAINT taxondetermination_keys_specimen_id UNIQUE (specimen_id, role_id, plantname_id);
4372

  
4373

  
4374
--
4375
-- Name: taxondetermination_keys_taxonoccurrence_id; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4376
--
4377

  
4378
ALTER TABLE ONLY taxondetermination
4379
    ADD CONSTRAINT taxondetermination_keys_taxonoccurrence_id UNIQUE (taxonoccurrence_id, role_id, plantname_id);
4380

  
4381

  
4382
--
4366 4383
-- Name: taxondetermination_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4367 4384
--
4368 4385

  

Also available in: Unified diff