Revision 12596
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/inputs/SALVIAS/validations.sql | ||
---|---|---|
146 | 146 |
|
147 | 147 |
|
148 | 148 |
-- |
149 |
-- Name: _plots_10a_aggregate_observation_individual_counts; Type: VIEW; Schema: SALVIAS; Owner: - |
|
150 |
-- |
|
151 |
|
|
152 |
CREATE VIEW _plots_10a_aggregate_observation_individual_counts AS |
|
153 |
SELECT p.project_name, |
|
154 |
(pm."SiteCode")::text AS plot_code, |
|
155 |
po."PlotObsID" AS individual_id, |
|
156 |
po."NoInd" AS individuals |
|
157 |
FROM ((projects p |
|
158 |
JOIN "plotMetadata" pm ON ((p.project_id = pm.project_id))) |
|
159 |
JOIN "plotObservations" po ON ((pm."PlotID" = po."PlotID"))) |
|
160 |
ORDER BY p.project_name, (pm."SiteCode")::text, po."PlotObsID"; |
|
161 |
|
|
162 |
|
|
163 |
-- |
|
164 |
-- Name: VIEW _plots_10a_aggregate_observation_individual_counts; Type: COMMENT; Schema: SALVIAS; Owner: - |
|
165 |
-- |
|
166 |
|
|
167 |
COMMENT ON VIEW _plots_10a_aggregate_observation_individual_counts IS ' |
|
168 |
Note 1: `individuals` should be NULL for plots which use percent cover or line-intercept methods. |
|
169 |
'; |
|
170 |
|
|
171 |
|
|
172 |
-- |
|
149 | 173 |
-- Name: _plots_11_count_of_stems_per_plot_in_each_project; Type: VIEW; Schema: SALVIAS; Owner: - |
150 | 174 |
-- |
151 | 175 |
|
trunk/schemas/vegbien.my.sql | ||
---|---|---|
259 | 259 |
|
260 | 260 |
|
261 | 261 |
-- |
262 |
-- Name: keys_~type._plots_10a_aggregate_observation_individual_counts; Type: TYPE; Schema: public_validations; Owner: - |
|
263 |
-- |
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
268 |
-- |
|
262 | 269 |
-- Name: keys_~type._plots_11_count_of_stems_per_plot_in_each_project; Type: TYPE; Schema: public_validations; Owner: - |
263 | 270 |
-- |
264 | 271 |
|
... | ... | |
413 | 420 |
|
414 | 421 |
|
415 | 422 |
-- |
423 |
-- Name: values__~type._plots_10a_aggregate_observation_individual_count; Type: TYPE; Schema: public_validations; Owner: - |
|
424 |
-- |
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
-- |
|
416 | 430 |
-- Name: values__~type._plots_11_count_of_stems_per_plot_in_each_project; Type: TYPE; Schema: public_validations; Owner: - |
417 | 431 |
-- |
418 | 432 |
|
... | ... | |
1272 | 1286 |
|
1273 | 1287 |
|
1274 | 1288 |
-- |
1289 |
-- Name: ~type._plots_10a_aggregate_observation_individual_counts; Type: TABLE; Schema: public_validations; Owner: -; Tablespace: |
|
1290 |
-- |
|
1291 |
|
|
1292 |
CREATE TABLE `~type._plots_10a_aggregate_observation_individual_counts` ( |
|
1293 |
project_name varchar(255), |
|
1294 |
plot_code varchar(255), |
|
1295 |
individual_id varchar(255), |
|
1296 |
individuals int(11) |
|
1297 |
); |
|
1298 |
|
|
1299 |
|
|
1300 |
-- |
|
1301 |
-- Name: keys(`~type._plots_10a_aggregate_observation_individual_counts`); Type: FUNCTION; Schema: public_validations; Owner: - |
|
1302 |
-- |
|
1303 |
|
|
1304 |
|
|
1305 |
|
|
1306 |
|
|
1307 |
-- |
|
1275 | 1308 |
-- Name: ~type._plots_11_count_of_stems_per_plot_in_each_project; Type: TABLE; Schema: public_validations; Owner: -; Tablespace: |
1276 | 1309 |
-- |
1277 | 1310 |
|
... | ... | |
1727 | 1760 |
|
1728 | 1761 |
|
1729 | 1762 |
-- |
1763 |
-- Name: values_(`~type._plots_10a_aggregate_observation_individual_counts`); Type: FUNCTION; Schema: public_validations; Owner: - |
|
1764 |
-- |
|
1765 |
|
|
1766 |
|
|
1767 |
|
|
1768 |
|
|
1769 |
-- |
|
1730 | 1770 |
-- Name: values_(`~type._plots_11_count_of_stems_per_plot_in_each_project`); Type: FUNCTION; Schema: public_validations; Owner: - |
1731 | 1771 |
-- |
1732 | 1772 |
|
... | ... | |
4478 | 4518 |
|
4479 | 4519 |
|
4480 | 4520 |
-- |
4521 |
-- Name: _plots_10a_aggregate_observation_individual_counts; Type: VIEW; Schema: public_validations; Owner: - |
|
4522 |
-- |
|
4523 |
|
|
4524 |
|
|
4525 |
|
|
4526 |
|
|
4527 |
-- |
|
4528 |
-- Name: VIEW _plots_10a_aggregate_observation_individual_counts; Type: COMMENT; Schema: public_validations; Owner: - |
|
4529 |
-- |
|
4530 |
|
|
4531 |
|
|
4532 |
|
|
4533 |
|
|
4534 |
-- |
|
4481 | 4535 |
-- Name: _plots_11_count_of_stems_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: - |
4482 | 4536 |
-- |
4483 | 4537 |
|
... | ... | |
7486 | 7540 |
|
7487 | 7541 |
|
7488 | 7542 |
-- |
7543 |
-- Data for Name: ~type._plots_10a_aggregate_observation_individual_counts; Type: TABLE DATA; Schema: public_validations; Owner: - |
|
7544 |
-- |
|
7545 |
|
|
7546 |
|
|
7547 |
|
|
7548 |
-- |
|
7489 | 7549 |
-- Data for Name: ~type._plots_11_count_of_stems_per_plot_in_each_project; Type: TABLE DATA; Schema: public_validations; Owner: - |
7490 | 7550 |
-- |
7491 | 7551 |
|
trunk/schemas/vegbien.sql | ||
---|---|---|
516 | 516 |
|
517 | 517 |
|
518 | 518 |
-- |
519 |
-- Name: keys_~type._plots_10a_aggregate_observation_individual_counts; Type: TYPE; Schema: public_validations; Owner: - |
|
520 |
-- |
|
521 |
|
|
522 |
CREATE TYPE "keys_~type._plots_10a_aggregate_observation_individual_counts" AS ( |
|
523 |
project_name text, |
|
524 |
plot_code text, |
|
525 |
individual_id text |
|
526 |
); |
|
527 |
|
|
528 |
|
|
529 |
-- |
|
519 | 530 |
-- Name: keys_~type._plots_11_count_of_stems_per_plot_in_each_project; Type: TYPE; Schema: public_validations; Owner: - |
520 | 531 |
-- |
521 | 532 |
|
... | ... | |
721 | 732 |
|
722 | 733 |
|
723 | 734 |
-- |
735 |
-- Name: values__~type._plots_10a_aggregate_observation_individual_count; Type: TYPE; Schema: public_validations; Owner: - |
|
736 |
-- |
|
737 |
|
|
738 |
CREATE TYPE "values__~type._plots_10a_aggregate_observation_individual_count" AS ( |
|
739 |
individuals integer |
|
740 |
); |
|
741 |
|
|
742 |
|
|
743 |
-- |
|
724 | 744 |
-- Name: values__~type._plots_11_count_of_stems_per_plot_in_each_project; Type: TYPE; Schema: public_validations; Owner: - |
725 | 745 |
-- |
726 | 746 |
|
... | ... | |
2502 | 2522 |
|
2503 | 2523 |
|
2504 | 2524 |
-- |
2525 |
-- Name: ~type._plots_10a_aggregate_observation_individual_counts; Type: TABLE; Schema: public_validations; Owner: -; Tablespace: |
|
2526 |
-- |
|
2527 |
|
|
2528 |
CREATE TABLE "~type._plots_10a_aggregate_observation_individual_counts" ( |
|
2529 |
project_name text, |
|
2530 |
plot_code text, |
|
2531 |
individual_id text, |
|
2532 |
individuals integer |
|
2533 |
); |
|
2534 |
|
|
2535 |
|
|
2536 |
-- |
|
2537 |
-- Name: keys("~type._plots_10a_aggregate_observation_individual_counts"); Type: FUNCTION; Schema: public_validations; Owner: - |
|
2538 |
-- |
|
2539 |
|
|
2540 |
CREATE FUNCTION keys(value "~type._plots_10a_aggregate_observation_individual_counts") RETURNS "keys_~type._plots_10a_aggregate_observation_individual_counts" |
|
2541 |
LANGUAGE sql IMMUTABLE |
|
2542 |
AS $_$ |
|
2543 |
SELECT ROW($1.project_name, $1.plot_code, $1.individual_id)::public_validations."keys_~type._plots_10a_aggregate_observation_individual_counts" |
|
2544 |
$_$; |
|
2545 |
|
|
2546 |
|
|
2547 |
-- |
|
2505 | 2548 |
-- Name: ~type._plots_11_count_of_stems_per_plot_in_each_project; Type: TABLE; Schema: public_validations; Owner: -; Tablespace: |
2506 | 2549 |
-- |
2507 | 2550 |
|
... | ... | |
3340 | 3383 |
|
3341 | 3384 |
|
3342 | 3385 |
-- |
3386 |
-- Name: values_("~type._plots_10a_aggregate_observation_individual_counts"); Type: FUNCTION; Schema: public_validations; Owner: - |
|
3387 |
-- |
|
3388 |
|
|
3389 |
CREATE FUNCTION values_(value "~type._plots_10a_aggregate_observation_individual_counts") RETURNS "values__~type._plots_10a_aggregate_observation_individual_count" |
|
3390 |
LANGUAGE sql IMMUTABLE |
|
3391 |
AS $_$ |
|
3392 |
SELECT ROW($1.individuals)::public_validations."values__~type._plots_10a_aggregate_observation_individual_count" |
|
3393 |
$_$; |
|
3394 |
|
|
3395 |
|
|
3396 |
-- |
|
3343 | 3397 |
-- Name: values_("~type._plots_11_count_of_stems_per_plot_in_each_project"); Type: FUNCTION; Schema: public_validations; Owner: - |
3344 | 3398 |
-- |
3345 | 3399 |
|
... | ... | |
7171 | 7225 |
|
7172 | 7226 |
|
7173 | 7227 |
-- |
7228 |
-- Name: _plots_10a_aggregate_observation_individual_counts; Type: VIEW; Schema: public_validations; Owner: - |
|
7229 |
-- |
|
7230 |
|
|
7231 |
CREATE VIEW _plots_10a_aggregate_observation_individual_counts AS |
|
7232 |
SELECT p.projectname AS project_name, |
|
7233 |
l.authorlocationcode AS plot_code, |
|
7234 |
ao.sourceaccessioncode AS individual_id, |
|
7235 |
ao.count AS individuals |
|
7236 |
FROM ((((((public.project p |
|
7237 |
JOIN public.source s ON ((p.source_id = s.source_id))) |
|
7238 |
JOIN public.place_visit ON ((p.project_id = place_visit.project_id))) |
|
7239 |
JOIN public.locationevent le ON ((place_visit.locationevent_id = le.place_visit_id))) |
|
7240 |
JOIN public.plot l ON ((place_visit.location_id = l.location_id))) |
|
7241 |
JOIN public.taxonoccurrence o ON ((le.locationevent_id = o.locationevent_id))) |
|
7242 |
JOIN public.aggregateoccurrence ao ON ((o.taxonoccurrence_id = ao.taxonoccurrence_id))) |
|
7243 |
WHERE (s.shortname = ("current_schema"())::text) |
|
7244 |
ORDER BY p.projectname, l.authorlocationcode, ao.sourceaccessioncode; |
|
7245 |
|
|
7246 |
|
|
7247 |
-- |
|
7248 |
-- Name: VIEW _plots_10a_aggregate_observation_individual_counts; Type: COMMENT; Schema: public_validations; Owner: - |
|
7249 |
-- |
|
7250 |
|
|
7251 |
COMMENT ON VIEW _plots_10a_aggregate_observation_individual_counts IS ' |
|
7252 |
Note 1: `individuals` should be NULL for plots which use percent cover or line-intercept methods. |
|
7253 |
'; |
|
7254 |
|
|
7255 |
|
|
7256 |
-- |
|
7174 | 7257 |
-- Name: _plots_11_count_of_stems_per_plot_in_each_project; Type: VIEW; Schema: public_validations; Owner: - |
7175 | 7258 |
-- |
7176 | 7259 |
|
... | ... | |
10339 | 10422 |
|
10340 | 10423 |
|
10341 | 10424 |
-- |
10425 |
-- Data for Name: ~type._plots_10a_aggregate_observation_individual_counts; Type: TABLE DATA; Schema: public_validations; Owner: - |
|
10426 |
-- |
|
10427 |
|
|
10428 |
|
|
10429 |
|
|
10430 |
-- |
|
10342 | 10431 |
-- Data for Name: ~type._plots_11_count_of_stems_per_plot_in_each_project; Type: TABLE DATA; Schema: public_validations; Owner: - |
10343 | 10432 |
-- |
10344 | 10433 |
|
Also available in: Unified diff
schemas/vegbien.sql, inputs/SALVIAS/validations.sql: added _plots_10a_aggregate_observation_individual_counts, for use in debugging diffs in _plots_10_count_of_individuals_per_plot_in_each_proj