Project

General

Profile

« Previous | Next » 

Revision 1058

vegbien.sql: Renamed planttag to stemtag and made it a child of stemobservation. Removed trait table from ERD because it's not used for the purpose we want to use traits for.

View differences:

schemas/vegbien.my.sql
1736 1736

  
1737 1737

  
1738 1738

  
1739

  
1740

  
1741 1739
--
1742
-- Name: planttag; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1743
--
1744

  
1745
CREATE TABLE planttag (
1746
    planttag_id int(11) NOT NULL,
1747
    plantobservation_id int(11) NOT NULL,
1748
    tag text NOT NULL,
1749
    iscurrent int(1) DEFAULT true NOT NULL
1750
);
1751

  
1752

  
1753
--
1754
-- Name: planttag_planttag_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1755
--
1756

  
1757

  
1758

  
1759

  
1760
--
1761
-- Name: planttag_planttag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
1762
--
1763

  
1764

  
1765

  
1766

  
1767

  
1768

  
1769
--
1770 1740
-- Name: plantusage; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1771 1741
--
1772 1742

  
......
2333 2303

  
2334 2304

  
2335 2305

  
2306

  
2307

  
2336 2308
--
2309
-- Name: stemtag; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2310
--
2311

  
2312
CREATE TABLE stemtag (
2313
    stemtag_id int(11) NOT NULL,
2314
    stemobservation_id int(11) NOT NULL,
2315
    tag text NOT NULL,
2316
    iscurrent int(1) DEFAULT true NOT NULL
2317
);
2318

  
2319

  
2320
--
2321
-- Name: stemtag_stemtag_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2322
--
2323

  
2324

  
2325

  
2326

  
2327
--
2328
-- Name: stemtag_stemtag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2329
--
2330

  
2331

  
2332

  
2333

  
2334

  
2335

  
2336
--
2337 2337
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2338 2338
--
2339 2339

  
......
3307 3307

  
3308 3308

  
3309 3309
--
3310
-- Name: planttag_id; Type: DEFAULT; Schema: public; Owner: -
3311
--
3312

  
3313

  
3314

  
3315

  
3316
--
3317 3310
-- Name: plantusage_id; Type: DEFAULT; Schema: public; Owner: -
3318 3311
--
3319 3312

  
......
3426 3419

  
3427 3420

  
3428 3421
--
3422
-- Name: stemtag_id; Type: DEFAULT; Schema: public; Owner: -
3423
--
3424

  
3425

  
3426

  
3427

  
3428
--
3429 3429
-- Name: stratum_id; Type: DEFAULT; Schema: public; Owner: -
3430 3430
--
3431 3431

  
......
4030 4030

  
4031 4031

  
4032 4032
--
4033
-- Name: planttag_current_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4034
--
4035

  
4036
ALTER TABLE planttag
4037
    ADD CONSTRAINT planttag_current_unique UNIQUE (plantobservation_id, iscurrent);
4038

  
4039

  
4040
--
4041
-- Name: planttag_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4042
--
4043

  
4044
ALTER TABLE planttag
4045
    ADD CONSTRAINT planttag_keys UNIQUE (plantobservation_id, tag);
4046

  
4047

  
4048
--
4049
-- Name: planttag_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4050
--
4051

  
4052
ALTER TABLE planttag
4053
    ADD CONSTRAINT planttag_pkey PRIMARY KEY (planttag_id);
4054

  
4055

  
4056
--
4057 4033
-- Name: plantusage_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4058 4034
--
4059 4035

  
......
4238 4214

  
4239 4215

  
4240 4216
--
4217
-- Name: stemtag_current_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4218
--
4219

  
4220
ALTER TABLE stemtag
4221
    ADD CONSTRAINT stemtag_current_unique UNIQUE (stemobservation_id, iscurrent);
4222

  
4223

  
4224
--
4225
-- Name: stemtag_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4226
--
4227

  
4228
ALTER TABLE stemtag
4229
    ADD CONSTRAINT stemtag_keys UNIQUE (stemobservation_id, tag);
4230

  
4231

  
4232
--
4233
-- Name: stemtag_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4234
--
4235

  
4236
ALTER TABLE stemtag
4237
    ADD CONSTRAINT stemtag_pkey PRIMARY KEY (stemtag_id);
4238

  
4239

  
4240
--
4241 4241
-- Name: stratum_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4242 4242
--
4243 4243

  
......
4869 4869

  
4870 4870

  
4871 4871
--
4872
-- Name: fki_planttag_plant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4873
--
4874

  
4875
CREATE INDEX fki_planttag_plant_id ON planttag  (plantobservation_id);
4876

  
4877

  
4878
--
4879
-- Name: fki_planttag_plantobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4880
--
4881

  
4882
CREATE INDEX fki_planttag_plantobservation_id ON planttag  (plantobservation_id);
4883

  
4884

  
4885
--
4886 4872
-- Name: fki_plotmethod_reference_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4887 4873
--
4888 4874

  
......
4918 4904

  
4919 4905

  
4920 4906
--
4907
-- Name: fki_stemtag_plant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4908
--
4909

  
4910
CREATE INDEX fki_stemtag_plant_id ON stemtag  (stemobservation_id);
4911

  
4912

  
4913
--
4914
-- Name: fki_stemtag_plantobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4915
--
4916

  
4917
CREATE INDEX fki_stemtag_plantobservation_id ON stemtag  (stemobservation_id);
4918

  
4919

  
4920
--
4921
-- Name: fki_stemtag_stemobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4922
--
4923

  
4924
CREATE INDEX fki_stemtag_stemobservation_id ON stemtag  (stemobservation_id);
4925

  
4926

  
4927
--
4921 4928
-- Name: graphic_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
4922 4929
--
4923 4930

  
......
6330 6337

  
6331 6338

  
6332 6339
--
6333
-- Name: planttag_plantobservation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6334
--
6335

  
6336
ALTER TABLE planttag
6337
    ADD CONSTRAINT planttag_plantobservation_id FOREIGN KEY (plantobservation_id) REFERENCES plantobservation(plantobservation_id) ON UPDATE CASCADE ON DELETE CASCADE;
6338

  
6339

  
6340
--
6341 6340
-- Name: plantusage_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6342 6341
--
6343 6342

  
......
6516 6515

  
6517 6516

  
6518 6517
--
6518
-- Name: stemtag_stemobservation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6519
--
6520

  
6521
ALTER TABLE stemtag
6522
    ADD CONSTRAINT stemtag_stemobservation_id FOREIGN KEY (stemobservation_id) REFERENCES stemobservation(stemobservation_id) ON UPDATE CASCADE ON DELETE CASCADE;
6523

  
6524

  
6525
--
6519 6526
-- Name: stratum_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6520 6527
--
6521 6528

  
schemas/vegbien_empty.sql
49 49
TRUNCATE plantname CASCADE;
50 50
TRUNCATE plantobservation CASCADE;
51 51
TRUNCATE plantstatus CASCADE;
52
TRUNCATE planttag CASCADE;
53 52
TRUNCATE plantusage CASCADE;
54 53
TRUNCATE plotmethod CASCADE;
55 54
TRUNCATE project CASCADE;
......
66 65
TRUNCATE specimen CASCADE;
67 66
TRUNCATE specimenreplicate CASCADE;
68 67
TRUNCATE stemobservation CASCADE;
68
TRUNCATE stemtag CASCADE;
69 69
TRUNCATE stratum CASCADE;
70 70
TRUNCATE taxonalt CASCADE;
71 71
TRUNCATE taxondetermination CASCADE;
schemas/vegbien.sql
1997 1997
ALTER SEQUENCE plantstatus_plantstatus_id_seq OWNED BY plantstatus.plantstatus_id;
1998 1998

  
1999 1999

  
2000
SET default_with_oids = false;
2001

  
2002 2000
--
2003
-- Name: planttag; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2004
--
2005

  
2006
CREATE TABLE planttag (
2007
    planttag_id integer NOT NULL,
2008
    plantobservation_id integer NOT NULL,
2009
    tag text NOT NULL,
2010
    iscurrent boolean DEFAULT true NOT NULL
2011
);
2012

  
2013

  
2014
--
2015
-- Name: planttag_planttag_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2016
--
2017

  
2018
CREATE SEQUENCE planttag_planttag_id_seq
2019
    START WITH 1
2020
    INCREMENT BY 1
2021
    NO MINVALUE
2022
    NO MAXVALUE
2023
    CACHE 1;
2024

  
2025

  
2026
--
2027
-- Name: planttag_planttag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2028
--
2029

  
2030
ALTER SEQUENCE planttag_planttag_id_seq OWNED BY planttag.planttag_id;
2031

  
2032

  
2033
SET default_with_oids = true;
2034

  
2035
--
2036 2001
-- Name: plantusage; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2037 2002
--
2038 2003

  
......
2679 2644
ALTER SEQUENCE stemobservation_stemobservation_id_seq OWNED BY stemobservation.stemobservation_id;
2680 2645

  
2681 2646

  
2647
SET default_with_oids = false;
2648

  
2682 2649
--
2650
-- Name: stemtag; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2651
--
2652

  
2653
CREATE TABLE stemtag (
2654
    stemtag_id integer NOT NULL,
2655
    stemobservation_id integer NOT NULL,
2656
    tag text NOT NULL,
2657
    iscurrent boolean DEFAULT true NOT NULL
2658
);
2659

  
2660

  
2661
--
2662
-- Name: stemtag_stemtag_id_seq; Type: SEQUENCE; Schema: public; Owner: -
2663
--
2664

  
2665
CREATE SEQUENCE stemtag_stemtag_id_seq
2666
    START WITH 1
2667
    INCREMENT BY 1
2668
    NO MINVALUE
2669
    NO MAXVALUE
2670
    CACHE 1;
2671

  
2672

  
2673
--
2674
-- Name: stemtag_stemtag_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
2675
--
2676

  
2677
ALTER SEQUENCE stemtag_stemtag_id_seq OWNED BY stemtag.stemtag_id;
2678

  
2679

  
2680
SET default_with_oids = true;
2681

  
2682
--
2683 2683
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace: 
2684 2684
--
2685 2685

  
......
3753 3753

  
3754 3754

  
3755 3755
--
3756
-- Name: planttag_id; Type: DEFAULT; Schema: public; Owner: -
3757
--
3758

  
3759
ALTER TABLE planttag ALTER COLUMN planttag_id SET DEFAULT nextval('planttag_planttag_id_seq'::regclass);
3760

  
3761

  
3762
--
3763 3756
-- Name: plantusage_id; Type: DEFAULT; Schema: public; Owner: -
3764 3757
--
3765 3758

  
......
3872 3865

  
3873 3866

  
3874 3867
--
3868
-- Name: stemtag_id; Type: DEFAULT; Schema: public; Owner: -
3869
--
3870

  
3871
ALTER TABLE stemtag ALTER COLUMN stemtag_id SET DEFAULT nextval('stemtag_stemtag_id_seq'::regclass);
3872

  
3873

  
3874
--
3875 3875
-- Name: stratum_id; Type: DEFAULT; Schema: public; Owner: -
3876 3876
--
3877 3877

  
......
4476 4476

  
4477 4477

  
4478 4478
--
4479
-- Name: planttag_current_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4480
--
4481

  
4482
ALTER TABLE ONLY planttag
4483
    ADD CONSTRAINT planttag_current_unique UNIQUE (plantobservation_id, iscurrent);
4484

  
4485

  
4486
--
4487
-- Name: planttag_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4488
--
4489

  
4490
ALTER TABLE ONLY planttag
4491
    ADD CONSTRAINT planttag_keys UNIQUE (plantobservation_id, tag);
4492

  
4493

  
4494
--
4495
-- Name: planttag_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4496
--
4497

  
4498
ALTER TABLE ONLY planttag
4499
    ADD CONSTRAINT planttag_pkey PRIMARY KEY (planttag_id);
4500

  
4501

  
4502
--
4503 4479
-- Name: plantusage_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4504 4480
--
4505 4481

  
......
4684 4660

  
4685 4661

  
4686 4662
--
4663
-- Name: stemtag_current_unique; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4664
--
4665

  
4666
ALTER TABLE ONLY stemtag
4667
    ADD CONSTRAINT stemtag_current_unique UNIQUE (stemobservation_id, iscurrent);
4668

  
4669

  
4670
--
4671
-- Name: stemtag_keys; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4672
--
4673

  
4674
ALTER TABLE ONLY stemtag
4675
    ADD CONSTRAINT stemtag_keys UNIQUE (stemobservation_id, tag);
4676

  
4677

  
4678
--
4679
-- Name: stemtag_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4680
--
4681

  
4682
ALTER TABLE ONLY stemtag
4683
    ADD CONSTRAINT stemtag_pkey PRIMARY KEY (stemtag_id);
4684

  
4685

  
4686
--
4687 4687
-- Name: stratum_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4688 4688
--
4689 4689

  
......
5315 5315

  
5316 5316

  
5317 5317
--
5318
-- Name: fki_planttag_plant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5319
--
5320

  
5321
CREATE INDEX fki_planttag_plant_id ON planttag USING btree (plantobservation_id);
5322

  
5323

  
5324
--
5325
-- Name: fki_planttag_plantobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5326
--
5327

  
5328
CREATE INDEX fki_planttag_plantobservation_id ON planttag USING btree (plantobservation_id);
5329

  
5330

  
5331
--
5332 5318
-- Name: fki_plotmethod_reference_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5333 5319
--
5334 5320

  
......
5364 5350

  
5365 5351

  
5366 5352
--
5353
-- Name: fki_stemtag_plant_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5354
--
5355

  
5356
CREATE INDEX fki_stemtag_plant_id ON stemtag USING btree (stemobservation_id);
5357

  
5358

  
5359
--
5360
-- Name: fki_stemtag_plantobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5361
--
5362

  
5363
CREATE INDEX fki_stemtag_plantobservation_id ON stemtag USING btree (stemobservation_id);
5364

  
5365

  
5366
--
5367
-- Name: fki_stemtag_stemobservation_id; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5368
--
5369

  
5370
CREATE INDEX fki_stemtag_stemobservation_id ON stemtag USING btree (stemobservation_id);
5371

  
5372

  
5373
--
5367 5374
-- Name: graphic_accessioncode_index; Type: INDEX; Schema: public; Owner: -; Tablespace: 
5368 5375
--
5369 5376

  
......
6796 6803

  
6797 6804

  
6798 6805
--
6799
-- Name: planttag_plantobservation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6800
--
6801

  
6802
ALTER TABLE ONLY planttag
6803
    ADD CONSTRAINT planttag_plantobservation_id FOREIGN KEY (plantobservation_id) REFERENCES plantobservation(plantobservation_id) ON UPDATE CASCADE ON DELETE CASCADE;
6804

  
6805

  
6806
--
6807 6806
-- Name: plantusage_party_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6808 6807
--
6809 6808

  
......
6988 6987

  
6989 6988

  
6990 6989
--
6990
-- Name: stemtag_stemobservation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6991
--
6992

  
6993
ALTER TABLE ONLY stemtag
6994
    ADD CONSTRAINT stemtag_stemobservation_id FOREIGN KEY (stemobservation_id) REFERENCES stemobservation(stemobservation_id) ON UPDATE CASCADE ON DELETE CASCADE;
6995

  
6996

  
6997
--
6991 6998
-- Name: stratum_locationevent_id; Type: FK CONSTRAINT; Schema: public; Owner: -
6992 6999
--
6993 7000

  

Also available in: Unified diff