Revision 12221
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/inputs/bien2_traits/validations.sql | ||
---|---|---|
1 |
-- |
|
2 |
-- PostgreSQL database dump |
|
3 |
-- |
|
4 |
|
|
5 |
SET statement_timeout = 0; |
|
6 |
SET lock_timeout = 0; |
|
7 |
SET client_encoding = 'UTF8'; |
|
8 |
SET standard_conforming_strings = on; |
|
9 |
SET check_function_bodies = false; |
|
10 |
SET client_min_messages = warning; |
|
11 |
|
|
12 |
SET search_path = bien2_traits, pg_catalog; |
|
13 |
|
|
14 |
-- |
|
15 |
-- Name: traits_01_count_records; Type: VIEW; Schema: bien2_traits; Owner: - |
|
16 |
-- |
|
17 |
|
|
18 |
CREATE VIEW traits_01_count_records AS |
|
19 |
SELECT count(*) AS totalrecords |
|
20 |
FROM "TraitObservation" |
|
21 |
WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text)); |
|
22 |
|
|
23 |
|
|
24 |
-- |
|
25 |
-- Name: traits_02_count_trait_names; Type: VIEW; Schema: bien2_traits; Owner: - |
|
26 |
-- |
|
27 |
|
|
28 |
CREATE VIEW traits_02_count_trait_names AS |
|
29 |
SELECT count(DISTINCT "TraitObservation"."measurementName") AS traits |
|
30 |
FROM "TraitObservation" |
|
31 |
WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text)); |
|
32 |
|
|
33 |
|
|
34 |
-- |
|
35 |
-- Name: traits_03_list_trait_names; Type: VIEW; Schema: bien2_traits; Owner: - |
|
36 |
-- |
|
37 |
|
|
38 |
CREATE VIEW traits_03_list_trait_names AS |
|
39 |
SELECT DISTINCT "TraitObservation"."measurementName" AS trait |
|
40 |
FROM "TraitObservation" |
|
41 |
WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text)) |
|
42 |
ORDER BY "TraitObservation"."measurementName"; |
|
43 |
|
|
44 |
|
|
45 |
-- |
|
46 |
-- Name: traits_04_count_records_per_trait; Type: VIEW; Schema: bien2_traits; Owner: - |
|
47 |
-- |
|
48 |
|
|
49 |
CREATE VIEW traits_04_count_records_per_trait AS |
|
50 |
SELECT "TraitObservation"."measurementName" AS trait, |
|
51 |
count(*) AS measurements |
|
52 |
FROM "TraitObservation" |
|
53 |
WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text)) |
|
54 |
GROUP BY "TraitObservation"."measurementName" |
|
55 |
ORDER BY "TraitObservation"."measurementName"; |
|
56 |
|
|
57 |
|
|
58 |
-- |
|
59 |
-- Name: traits_05_count_taxa; Type: VIEW; Schema: bien2_traits; Owner: - |
|
60 |
-- |
|
61 |
|
|
62 |
CREATE VIEW traits_05_count_taxa AS |
|
63 |
SELECT count(DISTINCT btrim(concat_ws(' '::text, util.ifnull("TraitObservation"."taxonName", ''::text), util.ifnull("TraitObservation"."scientificNameAuthorship", ''::text)))) AS taxa |
|
64 |
FROM "TraitObservation" |
|
65 |
WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text)); |
|
66 |
|
|
67 |
|
|
68 |
-- |
|
69 |
-- Name: traits_06_list_distinct_taxa; Type: VIEW; Schema: bien2_traits; Owner: - |
|
70 |
-- |
|
71 |
|
|
72 |
CREATE VIEW traits_06_list_distinct_taxa AS |
|
73 |
SELECT DISTINCT btrim(concat_ws(' '::text, util.ifnull("TraitObservation"."taxonName", ''::text), util.ifnull("TraitObservation"."scientificNameAuthorship", ''::text))) AS taxonwithauthor |
|
74 |
FROM "TraitObservation" |
|
75 |
WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text)) |
|
76 |
ORDER BY btrim(concat_ws(' '::text, util.ifnull("TraitObservation"."taxonName", ''::text), util.ifnull("TraitObservation"."scientificNameAuthorship", ''::text))); |
|
77 |
|
|
78 |
|
|
79 |
-- |
|
80 |
-- Name: traits_07_trait_value_and_units; Type: VIEW; Schema: bien2_traits; Owner: - |
|
81 |
-- |
|
82 |
|
|
83 |
CREATE VIEW traits_07_trait_value_and_units AS |
|
84 |
SELECT "TraitObservation"."measurementName" AS trait, |
|
85 |
"TraitObservation"."measurementValue" AS value, |
|
86 |
"TraitObservation"."measurementUnit" AS units |
|
87 |
FROM "TraitObservation" |
|
88 |
WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text)) |
|
89 |
ORDER BY "TraitObservation"."measurementName", "TraitObservation"."measurementValue", "TraitObservation"."measurementUnit"; |
|
90 |
|
|
91 |
|
|
92 |
-- |
|
93 |
-- Name: traits_08_taxonname_trait_and_value_for_first_5000_records; Type: VIEW; Schema: bien2_traits; Owner: - |
|
94 |
-- |
|
95 |
|
|
96 |
CREATE VIEW traits_08_taxonname_trait_and_value_for_first_5000_records AS |
|
97 |
SELECT btrim(concat_ws(' '::text, util.ifnull("TraitObservation"."taxonName", ''::text), util.ifnull("TraitObservation"."scientificNameAuthorship", ''::text))) AS taxonwithauthor, |
|
98 |
"TraitObservation"."measurementName" AS trait, |
|
99 |
"TraitObservation"."measurementValue" AS value |
|
100 |
FROM "TraitObservation" |
|
101 |
WHERE (((("TraitObservation"."taxonName" IS NOT NULL) AND ("TraitObservation"."taxonName" <> ''::text)) AND ("TraitObservation"."measurementName" IS NOT NULL)) AND ("TraitObservation"."measurementName" <> ''::text)) |
|
102 |
ORDER BY btrim(concat_ws(' '::text, util.ifnull("TraitObservation"."taxonName", ''::text), util.ifnull("TraitObservation"."scientificNameAuthorship", ''::text))), "TraitObservation"."measurementName", "TraitObservation"."measurementValue"; |
|
103 |
|
|
104 |
|
|
105 |
-- |
|
106 |
-- PostgreSQL database dump complete |
|
107 |
-- |
|
108 |
|
Also available in: Unified diff
added inputs/bien2_traits/validations.sql, from validation/aggregating/traits/BIEN2_traits/bien3_validations_traits_original_mysql.VegCore.sql