Project

General

Profile

« Previous | Next » 

Revision 6885

schemas/vegbien.sql: Added taxon_trait materialized view

View differences:

schemas/vegbien.my.sql
437 437

  
438 438

  
439 439
--
440
-- Name: sync_taxon_trait_to_view(); Type: FUNCTION; Schema: public; Owner: -
441
--
442

  
443

  
444

  
445

  
446
--
440 447
-- Name: taxondetermination_set_iscurrent(); Type: FUNCTION; Schema: public; Owner: -
441 448
--
442 449

  
......
3038 3045

  
3039 3046

  
3040 3047
--
3048
-- Name: taxon_trait; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3049
--
3050

  
3051
CREATE TABLE taxon_trait (
3052
    `scientificName` varchar(255) NOT NULL,
3053
    `measurementType` varchar(255) NOT NULL,
3054
    `measurementValue` varchar(255),
3055
    `measurementUnit` varchar(255)
3056
);
3057

  
3058

  
3059
--
3060
-- Name: trait; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3061
--
3062

  
3063
CREATE TABLE trait (
3064
    trait_id int(11) NOT NULL,
3065
    taxonoccurrence_id int(11) NOT NULL,
3066
    name varchar(255) NOT NULL,
3067
    value varchar(255),
3068
    units varchar(255)
3069
);
3070

  
3071

  
3072
--
3073
-- Name: taxon_trait_view; Type: VIEW; Schema: public; Owner: -
3074
--
3075

  
3076

  
3077

  
3078

  
3079
--
3041 3080
-- Name: taxonalt; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3042 3081
--
3043 3082

  
......
3369 3408

  
3370 3409

  
3371 3410
--
3372
-- Name: trait; Type: TABLE; Schema: public; Owner: -; Tablespace: 
3373
--
3374

  
3375
CREATE TABLE trait (
3376
    trait_id int(11) NOT NULL,
3377
    taxonoccurrence_id int(11) NOT NULL,
3378
    name varchar(255) NOT NULL,
3379
    value varchar(255),
3380
    units varchar(255)
3381
);
3382

  
3383

  
3384
--
3385 3411
-- Name: trait_trait_id_seq; Type: SEQUENCE; Schema: public; Owner: -
3386 3412
--
3387 3413

  
......
4270 4296

  
4271 4297

  
4272 4298
--
4299
-- Data for Name: taxon_trait; Type: TABLE DATA; Schema: public; Owner: -
4300
--
4301

  
4302

  
4303

  
4304
--
4273 4305
-- Data for Name: taxonalt; Type: TABLE DATA; Schema: public; Owner: -
4274 4306
--
4275 4307

  
......
4832 4864

  
4833 4865

  
4834 4866
--
4867
-- Name: taxon_trait_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4868
--
4869

  
4870
ALTER TABLE taxon_trait
4871
    ADD CONSTRAINT taxon_trait_pkey PRIMARY KEY (`scientificName`, `measurementType`);
4872

  
4873

  
4874
--
4835 4875
-- Name: taxonalt_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
4836 4876
--
4837 4877

  
......
7247 7287

  
7248 7288

  
7249 7289
--
7290
-- Name: taxon_trait; Type: ACL; Schema: public; Owner: -
7291
--
7292

  
7293

  
7294

  
7295

  
7296

  
7297

  
7298

  
7299
--
7300
-- Name: trait; Type: ACL; Schema: public; Owner: -
7301
--
7302

  
7303

  
7304

  
7305

  
7306

  
7307

  
7308

  
7309
--
7310
-- Name: taxon_trait_view; Type: ACL; Schema: public; Owner: -
7311
--
7312

  
7313

  
7314

  
7315

  
7316

  
7317

  
7318

  
7319
--
7250 7320
-- Name: taxonalt; Type: ACL; Schema: public; Owner: -
7251 7321
--
7252 7322

  
......
7337 7407

  
7338 7408

  
7339 7409
--
7340
-- Name: trait; Type: ACL; Schema: public; Owner: -
7341
--
7342

  
7343

  
7344

  
7345

  
7346

  
7347

  
7348

  
7349
--
7350 7410
-- Name: userdefined; Type: ACL; Schema: public; Owner: -
7351 7411
--
7352 7412

  
schemas/vegbien.sql
1011 1011

  
1012 1012

  
1013 1013
--
1014
-- Name: sync_taxon_trait_to_view(); Type: FUNCTION; Schema: public; Owner: -
1015
--
1016

  
1017
CREATE FUNCTION sync_taxon_trait_to_view() RETURNS void
1018
    LANGUAGE sql
1019
    AS $$
1020
DROP TABLE IF EXISTS taxon_trait;
1021
CREATE TABLE taxon_trait AS SELECT * FROM taxon_trait_view LIMIT 0;
1022

  
1023
GRANT SELECT ON TABLE taxon_trait TO bien_read;
1024
GRANT SELECT ON TABLE taxon_trait_view TO bien_read;
1025

  
1026
ALTER TABLE taxon_trait ADD PRIMARY KEY ("scientificName", "measurementType");
1027
$$;
1028

  
1029

  
1030
--
1014 1031
-- Name: taxondetermination_set_iscurrent(); Type: FUNCTION; Schema: public; Owner: -
1015 1032
--
1016 1033

  
......
4081 4098

  
4082 4099

  
4083 4100
--
4101
-- Name: taxon_trait; Type: TABLE; Schema: public; Owner: -; Tablespace: 
4102
--
4103

  
4104
CREATE TABLE taxon_trait (
4105
    "scientificName" text NOT NULL,
4106
    "measurementType" text NOT NULL,
4107
    "measurementValue" text,
4108
    "measurementUnit" text
4109
);
4110

  
4111

  
4112
--
4113
-- Name: trait; Type: TABLE; Schema: public; Owner: -; Tablespace: 
4114
--
4115

  
4116
CREATE TABLE trait (
4117
    trait_id integer NOT NULL,
4118
    taxonoccurrence_id integer NOT NULL,
4119
    name text NOT NULL,
4120
    value text,
4121
    units text
4122
);
4123

  
4124

  
4125
--
4126
-- Name: taxon_trait_view; Type: VIEW; Schema: public; Owner: -
4127
--
4128

  
4129
CREATE VIEW taxon_trait_view AS
4130
    SELECT accepted_taxonlabel.taxonomicname AS "scientificName", trait.name AS "measurementType", trait.value AS "measurementValue", trait.name AS "measurementUnit" FROM (((((trait LEFT JOIN taxonoccurrence USING (taxonoccurrence_id)) LEFT JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN taxonverbatim datasource_taxonverbatim USING (taxonverbatim_id)) LEFT JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) LEFT JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) WHERE COALESCE(taxondetermination.iscurrent, true);
4131

  
4132

  
4133
--
4084 4134
-- Name: taxonalt; Type: TABLE; Schema: public; Owner: -; Tablespace: 
4085 4135
--
4086 4136

  
......
4466 4516

  
4467 4517

  
4468 4518
--
4469
-- Name: trait; Type: TABLE; Schema: public; Owner: -; Tablespace: 
4470
--
4471

  
4472
CREATE TABLE trait (
4473
    trait_id integer NOT NULL,
4474
    taxonoccurrence_id integer NOT NULL,
4475
    name text NOT NULL,
4476
    value text,
4477
    units text
4478
);
4479

  
4480

  
4481
--
4482 4519
-- Name: trait_trait_id_seq; Type: SEQUENCE; Schema: public; Owner: -
4483 4520
--
4484 4521

  
......
5382 5419

  
5383 5420

  
5384 5421
--
5422
-- Data for Name: taxon_trait; Type: TABLE DATA; Schema: public; Owner: -
5423
--
5424

  
5425

  
5426

  
5427
--
5385 5428
-- Data for Name: taxonalt; Type: TABLE DATA; Schema: public; Owner: -
5386 5429
--
5387 5430

  
......
5944 5987

  
5945 5988

  
5946 5989
--
5990
-- Name: taxon_trait_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
5991
--
5992

  
5993
ALTER TABLE ONLY taxon_trait
5994
    ADD CONSTRAINT taxon_trait_pkey PRIMARY KEY ("scientificName", "measurementType");
5995

  
5996

  
5997
--
5947 5998
-- Name: taxonalt_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
5948 5999
--
5949 6000

  
......
8407 8458

  
8408 8459

  
8409 8460
--
8461
-- Name: taxon_trait; Type: ACL; Schema: public; Owner: -
8462
--
8463

  
8464
REVOKE ALL ON TABLE taxon_trait FROM PUBLIC;
8465
REVOKE ALL ON TABLE taxon_trait FROM bien;
8466
GRANT ALL ON TABLE taxon_trait TO bien;
8467
GRANT SELECT ON TABLE taxon_trait TO bien_read;
8468

  
8469

  
8470
--
8471
-- Name: trait; Type: ACL; Schema: public; Owner: -
8472
--
8473

  
8474
REVOKE ALL ON TABLE trait FROM PUBLIC;
8475
REVOKE ALL ON TABLE trait FROM bien;
8476
GRANT ALL ON TABLE trait TO bien;
8477
GRANT SELECT ON TABLE trait TO bien_read;
8478

  
8479

  
8480
--
8481
-- Name: taxon_trait_view; Type: ACL; Schema: public; Owner: -
8482
--
8483

  
8484
REVOKE ALL ON TABLE taxon_trait_view FROM PUBLIC;
8485
REVOKE ALL ON TABLE taxon_trait_view FROM bien;
8486
GRANT ALL ON TABLE taxon_trait_view TO bien;
8487
GRANT SELECT ON TABLE taxon_trait_view TO bien_read;
8488

  
8489

  
8490
--
8410 8491
-- Name: taxonalt; Type: ACL; Schema: public; Owner: -
8411 8492
--
8412 8493

  
......
8497 8578

  
8498 8579

  
8499 8580
--
8500
-- Name: trait; Type: ACL; Schema: public; Owner: -
8501
--
8502

  
8503
REVOKE ALL ON TABLE trait FROM PUBLIC;
8504
REVOKE ALL ON TABLE trait FROM bien;
8505
GRANT ALL ON TABLE trait TO bien;
8506
GRANT SELECT ON TABLE trait TO bien_read;
8507

  
8508

  
8509
--
8510 8581
-- Name: userdefined; Type: ACL; Schema: public; Owner: -
8511 8582
--
8512 8583

  

Also available in: Unified diff