Project

General

Profile

« Previous | Next » 

Revision 5849

schemas/vegbien.sql: Added aggregated_analytical_db_view and materialized table aggregated_analytical_db (synced using sync_aggregated_analytical_db_to_view())

View differences:

schemas/vegbien.my.sql
250 250

  
251 251

  
252 252
--
253
-- Name: sync_aggregated_analytical_db_to_view(); Type: FUNCTION; Schema: public; Owner: -
254
--
255

  
256

  
257

  
258

  
259
--
253 260
-- Name: sync_analytical_db_to_view(); Type: FUNCTION; Schema: public; Owner: -
254 261
--
255 262

  
......
463 470

  
464 471

  
465 472
--
473
-- Name: aggregated_analytical_db; Type: TABLE; Schema: public; Owner: -; Tablespace: 
474
--
475

  
476
CREATE TABLE aggregated_analytical_db (
477
    `institutionCode` text,
478
    country text,
479
    `stateProvince` text,
480
    county text,
481
    `decimalLatitude` double precision,
482
    `decimalLongitude` double precision,
483
    `plotName` text,
484
    `elevationInMeters` double precision,
485
    `plotArea_ha` double precision,
486
    `samplingProtocol` text,
487
    `dateCollected` date,
488
    family text,
489
    genus text,
490
    `speciesBinomial` text,
491
    `scientificName` text,
492
    `scientificNameAuthorship` text,
493
    `scientificNameWithMorphospecies` text,
494
    `individualCount` text,
495
    `individualCount_1_to_2_5cm` text,
496
    `individualCount_2_5_to_10cm` text,
497
    `individualCount_10cm_or_more` text
498
);
499

  
500

  
501
--
502
-- Name: analytical_db; Type: TABLE; Schema: public; Owner: -; Tablespace: 
503
--
504

  
505
CREATE TABLE analytical_db (
506
    `institutionCode` text,
507
    country text,
508
    `stateProvince` text,
509
    county text,
510
    `decimalLatitude` double precision,
511
    `decimalLongitude` double precision,
512
    `plotName` text,
513
    `elevationInMeters` double precision,
514
    `plotArea_ha` double precision,
515
    `samplingProtocol` text,
516
    `dateCollected` date,
517
    family text,
518
    genus text,
519
    `speciesBinomial` text,
520
    `scientificName` text,
521
    `scientificNameAuthorship` text,
522
    `scientificNameWithMorphospecies` text,
523
    `identifiedBy` text,
524
    `growthForm` text,
525
    cultivated int(1),
526
    `cultivatedBasis` text,
527
    `coverPercent` double precision,
528
    `diameterBreastHeight_cm` double precision,
529
    height_m double precision,
530
    tag text,
531
    `organismX_m` double precision,
532
    `organismY_m` double precision,
533
    `recordedBy` text,
534
    `recordNumber` text
535
);
536

  
537

  
538
--
539
-- Name: aggregated_analytical_db_view; Type: VIEW; Schema: public; Owner: -
540
--
541

  
542

  
543

  
544

  
545
--
466 546
-- Name: aggregateoccurrence; Type: TABLE; Schema: public; Owner: -; Tablespace: 
467 547
--
468 548

  
......
523 603

  
524 604

  
525 605
--
526
-- Name: analytical_db; Type: TABLE; Schema: public; Owner: -; Tablespace: 
527
--
528

  
529
CREATE TABLE analytical_db (
530
    `institutionCode` text,
531
    country text,
532
    `stateProvince` text,
533
    county text,
534
    `decimalLatitude` double precision,
535
    `decimalLongitude` double precision,
536
    `plotName` text,
537
    `elevationInMeters` double precision,
538
    `plotArea_ha` double precision,
539
    `samplingProtocol` text,
540
    `dateCollected` date,
541
    family text,
542
    genus text,
543
    `speciesBinomial` text,
544
    `scientificName` text,
545
    `scientificNameAuthorship` text,
546
    `scientificNameWithMorphospecies` text,
547
    `identifiedBy` text,
548
    `growthForm` text,
549
    cultivated int(1),
550
    `cultivatedBasis` text,
551
    `coverPercent` double precision,
552
    `diameterBreastHeight_cm` double precision,
553
    height_m double precision,
554
    tag text,
555
    `organismX_m` double precision,
556
    `organismY_m` double precision,
557
    `recordedBy` text,
558
    `recordNumber` text
559
);
560

  
561

  
562
--
563 606
-- Name: location; Type: TABLE; Schema: public; Owner: -; Tablespace: 
564 607
--
565 608

  
schemas/vegbien.sql
556 556

  
557 557

  
558 558
--
559
-- Name: sync_aggregated_analytical_db_to_view(); Type: FUNCTION; Schema: public; Owner: -
560
--
561

  
562
CREATE FUNCTION sync_aggregated_analytical_db_to_view() RETURNS void
563
    LANGUAGE sql
564
    AS $$
565
DROP TABLE IF EXISTS aggregated_analytical_db;
566
CREATE TABLE aggregated_analytical_db AS SELECT * FROM aggregated_analytical_db_view;
567
$$;
568

  
569

  
570
--
559 571
-- Name: sync_analytical_db_to_view(); Type: FUNCTION; Schema: public; Owner: -
560 572
--
561 573

  
......
955 967

  
956 968

  
957 969
--
970
-- Name: aggregated_analytical_db; Type: TABLE; Schema: public; Owner: -; Tablespace: 
971
--
972

  
973
CREATE TABLE aggregated_analytical_db (
974
    "institutionCode" text,
975
    country text,
976
    "stateProvince" text,
977
    county text,
978
    "decimalLatitude" double precision,
979
    "decimalLongitude" double precision,
980
    "plotName" text,
981
    "elevationInMeters" double precision,
982
    "plotArea_ha" double precision,
983
    "samplingProtocol" text,
984
    "dateCollected" date,
985
    family text,
986
    genus text,
987
    "speciesBinomial" text,
988
    "scientificName" text,
989
    "scientificNameAuthorship" text,
990
    "scientificNameWithMorphospecies" text,
991
    "individualCount" bigint,
992
    "individualCount_1_to_2_5cm" bigint,
993
    "individualCount_2_5_to_10cm" bigint,
994
    "individualCount_10cm_or_more" bigint
995
);
996

  
997

  
998
--
999
-- Name: analytical_db; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1000
--
1001

  
1002
CREATE TABLE analytical_db (
1003
    "institutionCode" text,
1004
    country text,
1005
    "stateProvince" text,
1006
    county text,
1007
    "decimalLatitude" double precision,
1008
    "decimalLongitude" double precision,
1009
    "plotName" text,
1010
    "elevationInMeters" double precision,
1011
    "plotArea_ha" double precision,
1012
    "samplingProtocol" text,
1013
    "dateCollected" date,
1014
    family text,
1015
    genus text,
1016
    "speciesBinomial" text,
1017
    "scientificName" text,
1018
    "scientificNameAuthorship" text,
1019
    "scientificNameWithMorphospecies" text,
1020
    "identifiedBy" text,
1021
    "growthForm" growthform,
1022
    cultivated boolean,
1023
    "cultivatedBasis" text,
1024
    "coverPercent" double precision,
1025
    "diameterBreastHeight_cm" double precision,
1026
    height_m double precision,
1027
    tag text,
1028
    "organismX_m" double precision,
1029
    "organismY_m" double precision,
1030
    "recordedBy" text,
1031
    "recordNumber" text
1032
);
1033

  
1034

  
1035
--
1036
-- Name: aggregated_analytical_db_view; Type: VIEW; Schema: public; Owner: -
1037
--
1038

  
1039
CREATE VIEW aggregated_analytical_db_view AS
1040
    SELECT analytical_db."institutionCode", analytical_db.country, analytical_db."stateProvince", analytical_db.county, analytical_db."decimalLatitude", analytical_db."decimalLongitude", analytical_db."plotName", analytical_db."elevationInMeters", analytical_db."plotArea_ha", analytical_db."samplingProtocol", analytical_db."dateCollected", analytical_db.family, analytical_db.genus, analytical_db."speciesBinomial", analytical_db."scientificName", analytical_db."scientificNameAuthorship", analytical_db."scientificNameWithMorphospecies", count(analytical_db."diameterBreastHeight_cm") AS "individualCount", count(((analytical_db."diameterBreastHeight_cm" >= _cm_to_m((1)::double precision)) AND (analytical_db."diameterBreastHeight_cm" < _cm_to_m((2.5)::double precision)))) AS "individualCount_1_to_2_5cm", count(((analytical_db."diameterBreastHeight_cm" >= _cm_to_m((2.5)::double precision)) AND (analytical_db."diameterBreastHeight_cm" < _cm_to_m((10)::double precision)))) AS "individualCount_2_5_to_10cm", count((analytical_db."diameterBreastHeight_cm" >= _cm_to_m((10)::double precision))) AS "individualCount_10cm_or_more" FROM analytical_db WHERE (analytical_db."diameterBreastHeight_cm" IS NOT NULL) GROUP BY analytical_db."institutionCode", analytical_db.country, analytical_db."stateProvince", analytical_db.county, analytical_db."decimalLatitude", analytical_db."decimalLongitude", analytical_db."plotName", analytical_db."elevationInMeters", analytical_db."plotArea_ha", analytical_db."samplingProtocol", analytical_db."dateCollected", analytical_db.family, analytical_db.genus, analytical_db."speciesBinomial", analytical_db."scientificName", analytical_db."scientificNameAuthorship", analytical_db."scientificNameWithMorphospecies";
1041

  
1042

  
1043
--
958 1044
-- Name: aggregateoccurrence; Type: TABLE; Schema: public; Owner: -; Tablespace: 
959 1045
--
960 1046

  
......
1021 1107

  
1022 1108

  
1023 1109
--
1024
-- Name: analytical_db; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1025
--
1026

  
1027
CREATE TABLE analytical_db (
1028
    "institutionCode" text,
1029
    country text,
1030
    "stateProvince" text,
1031
    county text,
1032
    "decimalLatitude" double precision,
1033
    "decimalLongitude" double precision,
1034
    "plotName" text,
1035
    "elevationInMeters" double precision,
1036
    "plotArea_ha" double precision,
1037
    "samplingProtocol" text,
1038
    "dateCollected" date,
1039
    family text,
1040
    genus text,
1041
    "speciesBinomial" text,
1042
    "scientificName" text,
1043
    "scientificNameAuthorship" text,
1044
    "scientificNameWithMorphospecies" text,
1045
    "identifiedBy" text,
1046
    "growthForm" growthform,
1047
    cultivated boolean,
1048
    "cultivatedBasis" text,
1049
    "coverPercent" double precision,
1050
    "diameterBreastHeight_cm" double precision,
1051
    height_m double precision,
1052
    tag text,
1053
    "organismX_m" double precision,
1054
    "organismY_m" double precision,
1055
    "recordedBy" text,
1056
    "recordNumber" text
1057
);
1058

  
1059

  
1060
--
1061 1110
-- Name: location; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1062 1111
--
1063 1112

  

Also available in: Unified diff