--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

SET search_path = bien2_traits, pg_catalog;

--
-- Name: _traits_01_count_records; Type: VIEW; Schema: bien2_traits; Owner: -
--

CREATE VIEW _traits_01_count_records AS
 SELECT count(*) AS totalrecords
   FROM "TraitObservation"
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text));


--
-- Name: _traits_02_count_trait_names; Type: VIEW; Schema: bien2_traits; Owner: -
--

CREATE VIEW _traits_02_count_trait_names AS
 SELECT count(DISTINCT "TraitObservation"."measurementName") AS traits
   FROM "TraitObservation"
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text));


--
-- Name: _traits_03_list_trait_names; Type: VIEW; Schema: bien2_traits; Owner: -
--

CREATE VIEW _traits_03_list_trait_names AS
 SELECT DISTINCT "TraitObservation"."measurementName" AS trait
   FROM "TraitObservation"
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text))
  ORDER BY "TraitObservation"."measurementName";


--
-- Name: _traits_04_count_records_per_trait; Type: VIEW; Schema: bien2_traits; Owner: -
--

CREATE VIEW _traits_04_count_records_per_trait AS
 SELECT "TraitObservation"."measurementName" AS trait, 
    count(*) AS measurements
   FROM "TraitObservation"
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text))
  GROUP BY "TraitObservation"."measurementName"
  ORDER BY "TraitObservation"."measurementName";


--
-- Name: _traits_05_count_taxa; Type: VIEW; Schema: bien2_traits; Owner: -
--

CREATE VIEW _traits_05_count_taxa AS
 SELECT count(DISTINCT btrim(concat_ws(' '::text, ifnull("TraitObservation"."taxonName", ''::text), ifnull("TraitObservation"."scientificNameAuthorship", ''::text)))) AS taxa
   FROM "TraitObservation"
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text));


--
-- Name: _traits_06_list_distinct_taxa; Type: VIEW; Schema: bien2_traits; Owner: -
--

CREATE VIEW _traits_06_list_distinct_taxa AS
 SELECT DISTINCT btrim(concat_ws(' '::text, ifnull("TraitObservation"."taxonName", ''::text), ifnull("TraitObservation"."scientificNameAuthorship", ''::text))) AS taxonwithauthor
   FROM "TraitObservation"
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text))
  ORDER BY btrim(concat_ws(' '::text, ifnull("TraitObservation"."taxonName", ''::text), ifnull("TraitObservation"."scientificNameAuthorship", ''::text)));


--
-- Name: _traits_07_trait_value_and_units; Type: VIEW; Schema: bien2_traits; Owner: -
--

CREATE VIEW _traits_07_trait_value_and_units AS
 SELECT "TraitObservation"."measurementName" AS trait, 
    "TraitObservation"."measurementValue" AS value, 
    "TraitObservation"."measurementUnit" AS units
   FROM "TraitObservation"
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text))
  ORDER BY "TraitObservation"."measurementName", "TraitObservation"."measurementValue", "TraitObservation"."measurementUnit";


--
-- Name: _traits_08_taxonname_trait_and_value_for_first_5000_records; Type: VIEW; Schema: bien2_traits; Owner: -
--

CREATE VIEW _traits_08_taxonname_trait_and_value_for_first_5000_records AS
 SELECT btrim(concat_ws(' '::text, ifnull("TraitObservation"."taxonName", ''::text), ifnull("TraitObservation"."scientificNameAuthorship", ''::text))) AS taxonwithauthor, 
    "TraitObservation"."measurementName" AS trait, 
    "TraitObservation"."measurementValue" AS value
   FROM "TraitObservation"
  WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text))
  ORDER BY btrim(concat_ws(' '::text, ifnull("TraitObservation"."taxonName", ''::text), ifnull("TraitObservation"."scientificNameAuthorship", ''::text))), "TraitObservation"."measurementName", "TraitObservation"."measurementValue";


--
-- PostgreSQL database dump complete
--

