Project

General

Profile

« Previous | Next » 

Revision 903

vegbien.sql: Removed morphospecies, instead using plantconcept and new table plantconceptscope to represent scoped morphospecies. Reorganized plant* tables in ERD.

View differences:

schemas/vegbien.my.sql
1209 1209

  
1210 1210

  
1211 1211

  
1212

  
1213

  
1214 1212
--
1215
-- Name: morphospecies; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1216
--
1217

  
1218
CREATE TABLE morphospecies (
1219
    morphospecies_id int(11) NOT NULL,
1220
    locationevent_id int(11) NOT NULL,
1221
    name text NOT NULL
1222
);
1223

  
1224

  
1225
--
1226
-- Name: morphospecies_morphospecies_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1227
--
1228

  
1229

  
1230

  
1231

  
1232
--
1233
-- Name: morphospecies_morphospecies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1234
--
1235

  
1236

  
1237

  
1238

  
1239

  
1240

  
1241
--
1242 1213
-- Name: namedplace; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1243 1214
--
1244 1215

  
......
1460 1431
    plantdescription text,
1461 1432
    d_obscount int(11),
1462 1433
    d_currentaccepted int(1),
1463
    accessioncode text
1434
    accessioncode text,
1435
    scope_id int(11)
1464 1436
);
1465 1437

  
1466 1438

  
......
1478 1450

  
1479 1451

  
1480 1452

  
1453

  
1454

  
1481 1455
--
1456
-- Name: plantconceptscope; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1457
--
1458

  
1459
CREATE TABLE plantconceptscope (
1460
    plantconceptscope_id int(11) NOT NULL,
1461
    locationevent_id int(11),
1462
    project_id int(11)
1463
);
1464

  
1465

  
1466
--
1467
-- Name: plantconceptscope_plantconceptscope_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1468
--
1469

  
1470

  
1471

  
1472

  
1473
--
1474
-- Name: plantconceptscope_plantconceptscope_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1475
--
1476

  
1477

  
1478

  
1479

  
1480

  
1481

  
1482
--
1482 1483
-- Name: plantcorrelation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1483 1484
--
1484 1485

  
......
1602 1603
CREATE TABLE plantstatus (
1603 1604
    plantstatus_id int(11) NOT NULL,
1604 1605
    plantconcept_id int(11) NOT NULL,
1606
    plantparent_id int(11),
1607
    plantlevel text,
1605 1608
    reference_id int(11),
1606 1609
    plantconceptstatus text DEFAULT 'undetermined',
1607 1610
    plantpartycomments text,
1608 1611
    plantparentname text,
1609
    plantparentconcept_id int(11),
1610
    plantparent_id int(11),
1611
    plantlevel text,
1612 1612
    party_id int(11),
1613 1613
    startdate timestamp NULL,
1614 1614
    stopdate timestamp NULL,
......
2375 2375
    revisions int(1),
2376 2376
    determinationdate timestamp NULL,
2377 2377
    emb_taxondetermination int(11),
2378
    accessioncode text,
2379
    morphospecies_id int(11)
2378
    accessioncode text
2380 2379
);
2381 2380

  
2382 2381

  
......
3165 3164

  
3166 3165

  
3167 3166
--
3168
-- Name: morphospecies_id; Type: DEFAULT; Schema: public; Owner: -
3169
--
3170

  
3171

  
3172

  
3173

  
3174
--
3175 3167
-- Name: namedplace_id; Type: DEFAULT; Schema: public; Owner: -
3176 3168
--
3177 3169

  
......
3228 3220

  
3229 3221

  
3230 3222
--
3223
-- Name: plantconceptscope_id; Type: DEFAULT; Schema: public; Owner: -
3224
--
3225

  
3226

  
3227

  
3228

  
3229
--
3231 3230
-- Name: plantcorrelation_id; Type: DEFAULT; Schema: public; Owner: -
3232 3231
--
3233 3232

  
......
3903 3902

  
3904 3903

  
3905 3904
--
3906
-- Name: morphospecies_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3907
--
3908

  
3909
ALTER TABLE morphospecies
3910
    ADD CONSTRAINT morphospecies_keys UNIQUE (locationevent_id, name);
3911

  
3912

  
3913
--
3914
-- Name: morphospecies_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3915
--
3916

  
3917
ALTER TABLE morphospecies
3918
    ADD CONSTRAINT morphospecies_pkey PRIMARY KEY (morphospecies_id);
3919

  
3920

  
3921
--
3922 3905
-- Name: namedplace_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3923 3906
--
3924 3907

  
......
3991 3974

  
3992 3975

  
3993 3976
--
3977
-- Name: plantconceptscope_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3978
--
3979

  
3980
ALTER TABLE plantconceptscope
3981
    ADD CONSTRAINT plantconceptscope_pkey PRIMARY KEY (plantconceptscope_id);
3982

  
3983

  
3984
--
3994 3985
-- Name: plantcorrelation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
3995 3986
--
3996 3987

  
......
4831 4822

  
4832 4823

  
4833 4824
--
4825
-- Name: fki_plantconcept_scope_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4826
--
4827

  
4828
CREATE INDEX fki_plantconcept_scope_id ON plantconcept  (scope_id);
4829

  
4830

  
4831
--
4832
-- Name: fki_plantconceptscope_locationevent_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4833
--
4834

  
4835
CREATE INDEX fki_plantconceptscope_locationevent_id ON plantconceptscope  (locationevent_id);
4836

  
4837

  
4838
--
4839
-- Name: fki_plantconceptscope_project_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4840
--
4841

  
4842
CREATE INDEX fki_plantconceptscope_project_id ON plantconceptscope  (project_id);
4843

  
4844

  
4845
--
4834 4846
-- Name: fki_plantobservation_plant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4835 4847
--
4836 4848

  
......
4880 4892

  
4881 4893

  
4882 4894
--
4883
-- Name: fki_taxondetermination_morphospecies_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4884
--
4885

  
4886
CREATE INDEX fki_taxondetermination_morphospecies_id ON taxondetermination  (morphospecies_id);
4887

  
4888

  
4889
--
4890 4895
-- Name: graphic_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4891 4896
--
4892 4897

  
......
5188 5193

  
5189 5194

  
5190 5195
--
5196
-- Name: plantconceptscope_keys; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5197
--
5198

  
5199

  
5200

  
5201

  
5202
--
5191 5203
-- Name: plantcorrelation_plantconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5192 5204
--
5193 5205

  
......
6096 6108

  
6097 6109

  
6098 6110
--
6099
-- Name: morphospecies_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6100
--
6101

  
6102
ALTER TABLE morphospecies
6103
    ADD CONSTRAINT morphospecies_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;
6104

  
6105

  
6106
--
6107 6111
-- Name: namedplace_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6108 6112
--
6109 6113

  
......
6197 6201

  
6198 6202

  
6199 6203
--
6204
-- Name: plantconcept_scope_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6205
--
6206

  
6207
ALTER TABLE plantconcept
6208
    ADD CONSTRAINT plantconcept_scope_id FOREIGN KEY (scope_id) REFERENCES plantconceptscope(plantconceptscope_id) ON UPDATE CASCADE ON DELETE CASCADE;
6209

  
6210

  
6211
--
6212
-- Name: plantconceptscope_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6213
--
6214

  
6215
ALTER TABLE plantconceptscope
6216
    ADD CONSTRAINT plantconceptscope_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;
6217

  
6218

  
6219
--
6220
-- Name: plantconceptscope_project_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6221
--
6222

  
6223
ALTER TABLE plantconceptscope
6224
    ADD CONSTRAINT plantconceptscope_project_id FOREIGN KEY (project_id) REFERENCES project(project_id) ON UPDATE CASCADE ON DELETE CASCADE;
6225

  
6226

  
6227
--
6200 6228
-- Name: plantcorrelation_plantconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6201 6229
--
6202 6230

  
......
6499 6527

  
6500 6528

  
6501 6529
--
6502
-- Name: taxondetermination_morphospecies_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6503
--
6504

  
6505
ALTER TABLE taxondetermination
6506
    ADD CONSTRAINT taxondetermination_morphospecies_id FOREIGN KEY (morphospecies_id) REFERENCES morphospecies(morphospecies_id) ON UPDATE CASCADE ON DELETE CASCADE;
6507

  
6508

  
6509
--
6510 6530
-- Name: taxondetermination_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6511 6531
--
6512 6532

  
schemas/vegbien_empty.sql
34 34
TRUNCATE locationeventcontributor CASCADE;
35 35
TRUNCATE locationeventsynonym CASCADE;
36 36
TRUNCATE locationplace CASCADE;
37
TRUNCATE morphospecies CASCADE;
38 37
TRUNCATE namedplace CASCADE;
39 38
TRUNCATE namedplacecorrelation CASCADE;
40 39
TRUNCATE note CASCADE;
......
43 42
TRUNCATE partymember CASCADE;
44 43
TRUNCATE plant CASCADE;
45 44
TRUNCATE plantconcept CASCADE;
45
TRUNCATE plantconceptscope CASCADE;
46 46
TRUNCATE plantcorrelation CASCADE;
47 47
TRUNCATE plantlineage CASCADE;
48 48
TRUNCATE plantname CASCADE;
schemas/vegbien.sql
1395 1395
ALTER SEQUENCE locationplace_locationplace_id_seq OWNED BY locationplace.locationplace_id;
1396 1396

  
1397 1397

  
1398
SET default_with_oids = false;
1399

  
1400 1398
--
1401
-- Name: morphospecies; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1402
--
1403

  
1404
CREATE TABLE morphospecies (
1405
    morphospecies_id integer NOT NULL,
1406
    locationevent_id integer NOT NULL,
1407
    name text NOT NULL
1408
);
1409

  
1410

  
1411
--
1412
-- Name: morphospecies_morphospecies_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1413
--
1414

  
1415
CREATE SEQUENCE morphospecies_morphospecies_id_seq
1416
    START WITH 1
1417
    INCREMENT BY 1
1418
    NO MINVALUE
1419
    NO MAXVALUE
1420
    CACHE 1;
1421

  
1422

  
1423
--
1424
-- Name: morphospecies_morphospecies_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1425
--
1426

  
1427
ALTER SEQUENCE morphospecies_morphospecies_id_seq OWNED BY morphospecies.morphospecies_id;
1428

  
1429

  
1430
SET default_with_oids = true;
1431

  
1432
--
1433 1399
-- Name: namedplace; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1434 1400
--
1435 1401

  
......
1686 1652
    plantdescription text,
1687 1653
    d_obscount integer,
1688 1654
    d_currentaccepted boolean,
1689
    accessioncode text
1655
    accessioncode text,
1656
    scope_id integer
1690 1657
);
1691 1658

  
1692 1659

  
......
1709 1676
ALTER SEQUENCE plantconcept_plantconcept_id_seq OWNED BY plantconcept.plantconcept_id;
1710 1677

  
1711 1678

  
1679
SET default_with_oids = false;
1680

  
1712 1681
--
1682
-- Name: plantconceptscope; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1683
--
1684

  
1685
CREATE TABLE plantconceptscope (
1686
    plantconceptscope_id integer NOT NULL,
1687
    locationevent_id integer,
1688
    project_id integer
1689
);
1690

  
1691

  
1692
--
1693
-- Name: plantconceptscope_plantconceptscope_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1694
--
1695

  
1696
CREATE SEQUENCE plantconceptscope_plantconceptscope_id_seq
1697
    START WITH 1
1698
    INCREMENT BY 1
1699
    NO MINVALUE
1700
    NO MAXVALUE
1701
    CACHE 1;
1702

  
1703

  
1704
--
1705
-- Name: plantconceptscope_plantconceptscope_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1706
--
1707

  
1708
ALTER SEQUENCE plantconceptscope_plantconceptscope_id_seq OWNED BY plantconceptscope.plantconceptscope_id;
1709

  
1710

  
1711
SET default_with_oids = true;
1712

  
1713
--
1713 1714
-- Name: plantcorrelation; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1714 1715
--
1715 1716

  
......
1853 1854
CREATE TABLE plantstatus (
1854 1855
    plantstatus_id integer NOT NULL,
1855 1856
    plantconcept_id integer NOT NULL,
1857
    plantparent_id integer,
1858
    plantlevel text,
1856 1859
    reference_id integer,
1857 1860
    plantconceptstatus text DEFAULT 'undetermined'::text NOT NULL,
1858 1861
    plantpartycomments text,
1859 1862
    plantparentname text,
1860
    plantparentconcept_id integer,
1861
    plantparent_id integer,
1862
    plantlevel text,
1863 1863
    party_id integer,
1864 1864
    startdate timestamp with time zone,
1865 1865
    stopdate timestamp with time zone,
......
2741 2741
    revisions boolean,
2742 2742
    determinationdate timestamp with time zone,
2743 2743
    emb_taxondetermination integer,
2744
    accessioncode text,
2745
    morphospecies_id integer
2744
    accessioncode text
2746 2745
);
2747 2746

  
2748 2747

  
......
3621 3620

  
3622 3621

  
3623 3622
--
3624
-- Name: morphospecies_id; Type: DEFAULT; Schema: public; Owner: -
3625
--
3626

  
3627
ALTER TABLE morphospecies ALTER COLUMN morphospecies_id SET DEFAULT nextval('morphospecies_morphospecies_id_seq'::regclass);
3628

  
3629

  
3630
--
3631 3623
-- Name: namedplace_id; Type: DEFAULT; Schema: public; Owner: -
3632 3624
--
3633 3625

  
......
3684 3676

  
3685 3677

  
3686 3678
--
3679
-- Name: plantconceptscope_id; Type: DEFAULT; Schema: public; Owner: -
3680
--
3681

  
3682
ALTER TABLE plantconceptscope ALTER COLUMN plantconceptscope_id SET DEFAULT nextval('plantconceptscope_plantconceptscope_id_seq'::regclass);
3683

  
3684

  
3685
--
3687 3686
-- Name: plantcorrelation_id; Type: DEFAULT; Schema: public; Owner: -
3688 3687
--
3689 3688

  
......
4359 4358

  
4360 4359

  
4361 4360
--
4362
-- Name: morphospecies_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4363
--
4364

  
4365
ALTER TABLE ONLY morphospecies
4366
    ADD CONSTRAINT morphospecies_keys UNIQUE (locationevent_id, name);
4367

  
4368

  
4369
--
4370
-- Name: morphospecies_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4371
--
4372

  
4373
ALTER TABLE ONLY morphospecies
4374
    ADD CONSTRAINT morphospecies_pkey PRIMARY KEY (morphospecies_id);
4375

  
4376

  
4377
--
4378 4361
-- Name: namedplace_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4379 4362
--
4380 4363

  
......
4447 4430

  
4448 4431

  
4449 4432
--
4433
-- Name: plantconceptscope_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4434
--
4435

  
4436
ALTER TABLE ONLY plantconceptscope
4437
    ADD CONSTRAINT plantconceptscope_pkey PRIMARY KEY (plantconceptscope_id);
4438

  
4439

  
4440
--
4450 4441
-- Name: plantcorrelation_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4451 4442
--
4452 4443

  
......
5287 5278

  
5288 5279

  
5289 5280
--
5281
-- Name: fki_plantconcept_scope_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5282
--
5283

  
5284
CREATE INDEX fki_plantconcept_scope_id ON plantconcept USING btree (scope_id);
5285

  
5286

  
5287
--
5288
-- Name: fki_plantconceptscope_locationevent_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5289
--
5290

  
5291
CREATE INDEX fki_plantconceptscope_locationevent_id ON plantconceptscope USING btree (locationevent_id);
5292

  
5293

  
5294
--
5295
-- Name: fki_plantconceptscope_project_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5296
--
5297

  
5298
CREATE INDEX fki_plantconceptscope_project_id ON plantconceptscope USING btree (project_id);
5299

  
5300

  
5301
--
5290 5302
-- Name: fki_plantobservation_plant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5291 5303
--
5292 5304

  
......
5336 5348

  
5337 5349

  
5338 5350
--
5339
-- Name: fki_taxondetermination_morphospecies_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5340
--
5341

  
5342
CREATE INDEX fki_taxondetermination_morphospecies_id ON taxondetermination USING btree (morphospecies_id);
5343

  
5344

  
5345
--
5346 5351
-- Name: graphic_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5347 5352
--
5348 5353

  
......
5626 5631
-- Name: plantconcept_keys; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5627 5632
--
5628 5633

  
5629
CREATE UNIQUE INDEX plantconcept_keys ON plantconcept USING btree ((COALESCE(reference_id, 0)), plantname_id);
5634
CREATE UNIQUE INDEX plantconcept_keys ON plantconcept USING btree ((COALESCE(scope_id, 0)), (COALESCE(reference_id, 0)), plantname_id);
5630 5635

  
5631 5636

  
5632 5637
--
......
5644 5649

  
5645 5650

  
5646 5651
--
5652
-- Name: plantconceptscope_keys; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5653
--
5654

  
5655
CREATE UNIQUE INDEX plantconceptscope_keys ON plantconceptscope USING btree ((COALESCE(locationevent_id, 0)), (COALESCE(project_id, 0)));
5656

  
5657

  
5658
--
5647 5659
-- Name: plantcorrelation_plantconcept_id_x; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5648 5660
--
5649 5661

  
......
6564 6576

  
6565 6577

  
6566 6578
--
6567
-- Name: morphospecies_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6568
--
6569

  
6570
ALTER TABLE ONLY morphospecies
6571
    ADD CONSTRAINT morphospecies_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;
6572

  
6573

  
6574
--
6575 6579
-- Name: namedplace_reference_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6576 6580
--
6577 6581

  
......
6668 6672

  
6669 6673

  
6670 6674
--
6675
-- Name: plantconcept_scope_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6676
--
6677

  
6678
ALTER TABLE ONLY plantconcept
6679
    ADD CONSTRAINT plantconcept_scope_id FOREIGN KEY (scope_id) REFERENCES plantconceptscope(plantconceptscope_id) ON UPDATE CASCADE ON DELETE CASCADE;
6680

  
6681

  
6682
--
6683
-- Name: plantconceptscope_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6684
--
6685

  
6686
ALTER TABLE ONLY plantconceptscope
6687
    ADD CONSTRAINT plantconceptscope_locationevent_id FOREIGN KEY (locationevent_id) REFERENCES locationevent(locationevent_id) ON UPDATE CASCADE ON DELETE CASCADE;
6688

  
6689

  
6690
--
6691
-- Name: plantconceptscope_project_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6692
--
6693

  
6694
ALTER TABLE ONLY plantconceptscope
6695
    ADD CONSTRAINT plantconceptscope_project_id FOREIGN KEY (project_id) REFERENCES project(project_id) ON UPDATE CASCADE ON DELETE CASCADE;
6696

  
6697

  
6698
--
6671 6699
-- Name: plantcorrelation_plantconcept_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6672 6700
--
6673 6701

  
......
6980 7008

  
6981 7009

  
6982 7010
--
6983
-- Name: taxondetermination_morphospecies_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6984
--
6985

  
6986
ALTER TABLE ONLY taxondetermination
6987
    ADD CONSTRAINT taxondetermination_morphospecies_id FOREIGN KEY (morphospecies_id) REFERENCES morphospecies(morphospecies_id) ON UPDATE CASCADE ON DELETE CASCADE;
6988

  
6989

  
6990
--
6991 7011
-- Name: taxondetermination_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6992 7012
--
6993 7013

  

Also available in: Unified diff