1
|
-- -------------------------------------------------------------------------
|
2
|
-- Quantitative validation queries on the BIEN database
|
3
|
--
|
4
|
-- Applies to any datasource with specimens
|
5
|
--
|
6
|
-- DB: vegbien
|
7
|
-- Host: vegbiendev.nceas.ucsb.edu
|
8
|
-- -------------------------------------------------------------------------
|
9
|
|
10
|
SET search_path TO validation;
|
11
|
|
12
|
-- -------------------------------
|
13
|
-- 1. Count of total records (specimens) in source db
|
14
|
-- Check: full join against equivalent query on BIEN3 db should return 1 row
|
15
|
-- -------------------------------
|
16
|
CREATE OR REPLACE VIEW specimens_1_count_of_total_records_specimens_in_source_db AS
|
17
|
|
18
|
-- -------------------------------
|
19
|
-- 2. Count of unique (verbatim) non-null families
|
20
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 1 row
|
21
|
-- -------------------------------
|
22
|
CREATE OR REPLACE VIEW specimens_2_count_of_unique_verbatim_non_null_families AS
|
23
|
|
24
|
-- -------------------------------
|
25
|
-- 3. List of verbatim families
|
26
|
-- Check: Full inner join to equivalent query on BIEN3 db should return same number of rows
|
27
|
-- -------------------------------
|
28
|
CREATE OR REPLACE VIEW specimens_3_list_of_verbatim_families AS
|
29
|
|
30
|
-- -------------------------------
|
31
|
-- 4. Count of unique (verbatim) non-null species, without author
|
32
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 1 row
|
33
|
-- -------------------------------
|
34
|
CREATE OR REPLACE VIEW specimens_4_count_of_unique_verbatim_non_null_species_without_author AS
|
35
|
|
36
|
-- -------------------------------
|
37
|
-- 5. List of verbatim species, excluding author
|
38
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 3335 rows
|
39
|
-- -------------------------------
|
40
|
CREATE OR REPLACE VIEW specimens_5_list_of_verbatim_species_excluding_author AS
|
41
|
|
42
|
-- -------------------------------
|
43
|
-- 6. Count of unique (verbatim) non-null subspecific taxa, without author
|
44
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 1 row
|
45
|
-- -------------------------------
|
46
|
CREATE OR REPLACE VIEW specimens_6_count_of_unique_verbatim_non_null_subspecific_taxa_without_author AS
|
47
|
|
48
|
-- -------------------------------
|
49
|
-- 7. List of verbatim subspecific taxa, without author
|
50
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 40145 rows
|
51
|
-- -------------------------------
|
52
|
CREATE OR REPLACE VIEW specimens_7_list_of_verbatim_subspecific_taxa_without_author AS
|
53
|
|
54
|
-- -------------------------------
|
55
|
-- 8. Count of unique (verbatim) taxa including author, for all taxa identified at least to genus
|
56
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 1 row
|
57
|
-- -------------------------------
|
58
|
CREATE OR REPLACE VIEW specimens_8_count_of_unique_verbatim_taxa_including_author_for_all_taxa_identified_at_least_to_genus AS
|
59
|
|
60
|
-- -------------------------------
|
61
|
-- 9. List of unique (verbatim) taxa including author, for all taxa identified at least to genus
|
62
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 45997 rows
|
63
|
-- -------------------------------
|
64
|
CREATE OR REPLACE VIEW specimens_9_list_of_unique_verbatim_taxa_including_author_for_all_taxa_identified_at_least_to_genus AS
|
65
|
|
66
|
-- -------------------------------
|
67
|
-- 10. Count number of records by institution
|
68
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 6 rows
|
69
|
-- Note: Majority should be from 'NY'; these are standard herbarium acronyms
|
70
|
-- -------------------------------
|
71
|
CREATE OR REPLACE VIEW specimens_10_count_number_of_records_by_institution AS
|
72
|
|
73
|
-- -------------------------------
|
74
|
-- 11. List of three standard political divisions
|
75
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 5232 rows
|
76
|
-- Note: character set issues may cause mis-matches. This query is a good way to reveal
|
77
|
-- character set issues, either in source db or in BIEN
|
78
|
-- -------------------------------
|
79
|
CREATE OR REPLACE VIEW specimens_11_list_of_three_standard_political_divisions AS
|
80
|
|
81
|
-- -------------------------------
|
82
|
-- 12. Check distinct Collector names + collection numbers + collection dates,
|
83
|
-- plus total records
|
84
|
-- Check: Full inner join to equivalent query on BIEN3 db should return 309396 rows
|
85
|
-- -------------------------------
|
86
|
CREATE OR REPLACE VIEW specimens_12_check_distinct_collector_names_collection_numbers_collection_dates_ AS
|
87
|
|
88
|
-- -------------------------------
|
89
|
-- 13. Count of all verbatim Latitude and Longitude values, as well as all
|
90
|
-- latitude and longitude values that are decimals numbers
|
91
|
-- Check: full join to equivalent query against BIEN3 should return 1 row
|
92
|
-- -------------------------------
|
93
|
CREATE OR REPLACE VIEW specimens_13_count_of_all_verbatim_latitude_and_longitude_values_as_well_as_all_ AS
|
94
|
|
95
|
-- -------------------------------
|
96
|
-- 14. Count of all verbatim Latitude and Longitude values that are not valid values
|
97
|
-- of decimal latitude or decimal longitude
|
98
|
-- Check: full join to equivalent query against BIEN3 should return 1 row
|
99
|
-- -------------------------------
|
100
|
CREATE OR REPLACE VIEW specimens_14_count_of_all_verbatim_latitude_and_longitude_values_that_are_not_valid_values AS
|
101
|
|
102
|
-- -------------------------------
|
103
|
-- 15. List distinct non-null locality descriptions
|
104
|
-- Check: full join to equivalent query against BIEN3 should return 125592 records
|
105
|
-- -------------------------------
|
106
|
CREATE OR REPLACE VIEW specimens_15_list_distinct_non_null_locality_descriptions AS
|
107
|
|
108
|
-- -------------------------------
|
109
|
-- 16. List distinct non-null specimen descriptions
|
110
|
-- Check: full join to equivalent query against BIEN3 should return 158460 records
|
111
|
-- Note: specimens descriptions in nybg extract is in column PlantFungusDescription
|
112
|
-- -------------------------------
|
113
|
CREATE OR REPLACE VIEW specimens_16_list_distinct_non_null_specimen_descriptions AS
|