From 1265912993f8123f9d2bfe4da1ccf65f9fdceedb Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 1 Jun 2026 20:29:59 +0000 Subject: [PATCH] Create, document, index, and trigger ARRIVALS_A This is the feeding station arrival and departure "event detail" table, that goes with the ATTENDANCE table. The per-presence, per-date, information has moved to this table. --- db/schemas/lib/triggers/Makefile | 3 +- db/schemas/lib/triggers/create/arrivals_a.m4 | 117 +++++++++ db/schemas/lib/triggers/create/roles.m4 | 72 ++++-- db/schemas/lib/triggers/drop/arrivals_a.m4 | 23 ++ db/schemas/sokwedb/indexes/Makefile | 3 +- .../sokwedb/indexes/create/arrivals_a.m4 | 35 +++ db/schemas/sokwedb/indexes/drop/arrivals_a.m4 | 27 +++ db/schemas/sokwedb/tables/Makefile | 3 +- .../sokwedb/tables/create/arrivals_a.m4 | 58 +++++ db/schemas/sokwedb/tables/create/events.m4 | 4 + doc/src/epilog.inc.m4 | 23 ++ doc/src/tables.m4 | 1 + doc/src/tables/arrivals_a.m4 | 226 ++++++++++++++++++ doc/src/tables/attendance.m4 | 7 + doc/src/tables/events.m4 | 51 ++++ include/global_constants.m4 | 2 + 16 files changed, 632 insertions(+), 23 deletions(-) create mode 100644 db/schemas/lib/triggers/create/arrivals_a.m4 create mode 100644 db/schemas/lib/triggers/drop/arrivals_a.m4 create mode 100644 db/schemas/sokwedb/indexes/create/arrivals_a.m4 create mode 100644 db/schemas/sokwedb/indexes/drop/arrivals_a.m4 create mode 100644 db/schemas/sokwedb/tables/create/arrivals_a.m4 create mode 100644 doc/src/tables/arrivals_a.m4 diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index 60476bf..09619ff 100644 --- a/db/schemas/lib/triggers/Makefile +++ b/db/schemas/lib/triggers/Makefile @@ -38,7 +38,8 @@ ORDER := comm_ids \ food_events \ groomings \ groom_scans_b \ - attendance + attendance \ + arrivals_a DROP_EXISTING := true diff --git a/db/schemas/lib/triggers/create/arrivals_a.m4 b/db/schemas/lib/triggers/create/arrivals_a.m4 new file mode 100644 index 0000000..379654c --- /dev/null +++ b/db/schemas/lib/triggers/create/arrivals_a.m4 @@ -0,0 +1,117 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify it +dnl under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Triggers for the follows table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + + +RAISE INFO 'arrivals_a_func'; +CREATE OR REPLACE FUNCTION arrivals_a_func () + RETURNS trigger + LANGUAGE plpgsql + sdb_function_set_search_path + AS $$ + BEGIN + -- Function for arrivals_a insert and update triggers + -- + -- AGPL_notice(` --', `2026', + `The Meme Factory, Inc., www.karlpinc.com') + + IF TG_OP = 'UPDATE' THEN + cannot_change(`ARRIVALS_A', `ArAID') + END IF; + + -- The EVENTS.Behavior must be sdb_arrival + IF TG_OP = 'INSERT' + OR NEW.EID <> OLD.EID THEN + DECLARE + -- EVENTS + a_behavior events.behavior%TYPE; + a_start events.start%TYPE; + a_stop events.stop%TYPE; + -- FOLLOWS + a_fid follows.fid%TYPE; + a_focal follows.focal%TYPE; + a_date follows.date%TYPE; + -- ROLES + a_pid roles.pid%TYPE; + a_role roles.role%TYPE; + a_participant roles.participant%TYPE; + + BEGIN + SELECT events.behavior, events.start, events.stop + , follows.fid, follows.focal, follows.date + , roles.pid, roles.role, roles.participant + INTO a_behavior , a_start , a_stop + , a_fid , a_focal , a_date + , a_pid , a_role , a_participant + FROM events + JOIN follows ON (follows.fid = events.fid) + LEFT OUTER JOIN roles ON (roles.eid = events.eid) + WHERE events.eid = NEW.eid + AND events.behavior <> 'sdb_arrival_a'; + IF FOUND THEN + RAISE EXCEPTION integrity_constraint_violation USING + MESSAGE = 'Error on ' || TG_OP || ' of ARRIVALS_A' + , DETAIL = 'Arrivals at the feeding station can only be related' + || ' to an event with an' + || ' EVENTS.Behavior value of (sdb_arrival_a)' + || ': Key (ArID = (' + || NEW.arid + || '): Value (Cycle) = (' + || NEW.cycle + || '): Value (DataSource) = (' + || NEW.datasource + || '): Key (ROLES.PID) = (' + || textualize(`a_pid') + || '), Value (ROLES.Role) = (' + || textualize(`a_role') + || '), Value (ROLES.Participant) = (' + || textualize(`a_participant') + || '): Key (EVENTS.EID) = (' + || NEW.eid + || '): Value (EVENTS.Behavior) = (' + || a_behavior + || '), Value (EVENTS.Start) = (' + || a_start + || '), Value (EVENTS.Stop) = (' + || a_stop + || '): Key (FOLLOWS.FID) = (' + || a_fid + || '), Value (FOLLOWS.Focal) = (' + || a_focal + || '), Value (FOLLOWS.Date) = (' + || a_date + || ')'; + END IF; + END; + END IF; + + RETURN NULL; + END; +$$; + + +RAISE INFO 'arrivals_a_trigger'; +CREATE TRIGGER arrivals_a_trigger + AFTER INSERT OR UPDATE + ON arrivals_a FOR EACH ROW + EXECUTE PROCEDURE arrivals_a_func(); diff --git a/db/schemas/lib/triggers/create/roles.m4 b/db/schemas/lib/triggers/create/roles.m4 index 5aad51a..4fd98c2 100644 --- a/db/schemas/lib/triggers/create/roles.m4 +++ b/db/schemas/lib/triggers/create/roles.m4 @@ -34,6 +34,7 @@ CREATE OR REPLACE FUNCTION roles_func () a_start events.start%TYPE; a_stop events.stop%TYPE; a_fid events.fid%TYPE; + a_atid events.atid%TYPE; BEGIN -- Function for roles insert and update triggers @@ -65,8 +66,8 @@ CREATE OR REPLACE FUNCTION roles_func () -- Get the event information so we have the behavior and -- don't select the same data multiple times. -- (An over-optimization -- the benefit is to keep the code simple.) - SELECT events.behavior ,events.start, events.stop, events.fid - INTO a_behavior , a_start , a_stop , a_fid + SELECT events.behavior ,events.start, events.stop, events.fid, events.atid + INTO a_behavior , a_start , a_stop , a_fid , a_atid FROM events WHERE events.eid = NEW.eid; END IF; @@ -165,33 +166,71 @@ CREATE OR REPLACE FUNCTION roles_func () END; END IF; - -- There can be at most one related row on ROLES for arrival and food events + -- There can be at most one related row on ROLES for arrival, feeding + -- station arrival, and food events IF TG_OP = 'INSERT' AND (a_behavior = 'sdb_arrival' + OR a_behavior = 'sdb_arrival_a' OR a_behavior = 'sdb_food') THEN DECLARE a_pid roles.pid%TYPE; a_role roles.role%TYPE; a_participant roles.participant%TYPE; + a_focal follows.focal%TYPE; - a_date follows.date%TYPE; - a_commid follows.commid%TYPE; + a_animid attendance.animid%TYPE; + + a_date DATE; + a_commid comm_ids.commid%TYPE; + + observation_msg TEXT; -- Report of the animal, date, and community BEGIN SELECT roles.pid, roles.role, roles.participant - , follows.focal, follows.date, follows.commid INTO a_pid , a_role , a_participant - , a_focal , a_date , a_commid FROM roles - , follows WHERE roles.eid = NEW.eid - AND roles.pid <> NEW.pid - AND follows.fid = a_fid; + AND roles.pid <> NEW.pid; + IF FOUND THEN + IF a_behavior = 'sdb_arrival_a' THEN + SELECT attendance.animid, attendance.date, attendance.commid + INTO a_animid , a_date , a_commid + FROM attendance + WHERE attendance.atid = a_atid; + + observation_msg := 'Value (ATTENDANCE.AtID) = (' + || a_atid + || '), Value (ATTENDANCE.AnimID) = (' + || a_animid + || '), Value (ATTENDANCE.Date) = (' + || a_date + || '), Value (ATTENDANCE.CommID) = (' + || a_commid + || ')'; + ELSE -- a_behavior is sdb_arrival or sdb_food + SELECT follows.focal, follows.date, follows.commid + INTO a_focal , a_date , a_commid + FROM follows + WHERE follows.fid = a_fid; + + observation_msg := 'Value (FOLLOWS.FID) = (' + || a_fid + || '), Value (FOLLOWS.Focal) = (' + || a_focal + || '), Value (FOLLOWS.Date) = (' + || a_date + || '), Value (FOLLOWS.CommID) = (' + || a_commid + || ')'; + END IF; + RAISE EXCEPTION integrity_constraint_violation USING MESSAGE = 'Error on INSERT of ROLES' , DETAIL = 'There can be only one related row on ROLES for an' - || ' event with a EVENTS.Behavior of (sdb_arrival):' + || ' event with a EVENTS.Behavior of (' + || a_behavior + || '):' || ' Inserting: Key (PID) = (' || NEW.pid || '), Value (EID) = (' @@ -213,15 +252,8 @@ CREATE OR REPLACE FUNCTION roles_func () || a_start || '), Value (EVENTS.Stop) = (' || a_stop - || '), Value (FOLLOWS.FID) = (' - || a_fid - || '), Value (FOLLOWS.Focal) = (' - || a_focal - || '), Value (FOLLOWS.Date) = (' - || a_date - || '), Value (FOLLOWS.CommID) = (' - || a_commid - || ')'; + || '), ' + || observation_msg; END IF; END; END IF; diff --git a/db/schemas/lib/triggers/drop/arrivals_a.m4 b/db/schemas/lib/triggers/drop/arrivals_a.m4 new file mode 100644 index 0000000..9ee3559 --- /dev/null +++ b/db/schemas/lib/triggers/drop/arrivals_a.m4 @@ -0,0 +1,23 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Drop triggers for arrivals_a table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl + +DROP FUNCTION IF EXISTS arrivals_a_func() CASCADE; diff --git a/db/schemas/sokwedb/indexes/Makefile b/db/schemas/sokwedb/indexes/Makefile index c78464f..a4399ec 100644 --- a/db/schemas/sokwedb/indexes/Makefile +++ b/db/schemas/sokwedb/indexes/Makefile @@ -22,7 +22,8 @@ ORDER := biography_data biography_log comm_membs comm_memb_log \ follows follow_observers follow_studies events roles arrivals \ swelling_sources swelling_states aggression_event_log sightings \ - aggressions food_events groomings groom_scans_b attendance + aggressions food_events groomings groom_scans_b attendance \ + arrivals_a ## ## CAUTION: This Makefile is not designed to be run directly. It is normally diff --git a/db/schemas/sokwedb/indexes/create/arrivals_a.m4 b/db/schemas/sokwedb/indexes/create/arrivals_a.m4 new file mode 100644 index 0000000..8d8c9c3 --- /dev/null +++ b/db/schemas/sokwedb/indexes/create/arrivals_a.m4 @@ -0,0 +1,35 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`indexmacros.m4')dnl + +CREATE UNIQUE INDEX IF NOT EXISTS + "ARRIVALS_A has, at most, a 1-to-1 relationship with EVENTS" + ON arrivals_a + (eid); + +CREATE INDEX IF NOT EXISTS arrivals_a_swelling ON arrivals_a + (swelling); + +-- Don't index Seq, Bananas, ArrivalDegree, DepartureDegree, Recorder, +-- Observer2, or CycleOld because we don't expect to search on them. + + diff --git a/db/schemas/sokwedb/indexes/drop/arrivals_a.m4 b/db/schemas/sokwedb/indexes/drop/arrivals_a.m4 new file mode 100644 index 0000000..912e732 --- /dev/null +++ b/db/schemas/sokwedb/indexes/drop/arrivals_a.m4 @@ -0,0 +1,27 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`indexmacros.m4')dnl + +DROP INDEX IF EXISTS + "ARRIVALS_A has, at most, a 1-to-1 relationship with EVENTS"; + +DROP INDEX IF EXISTS arrivals_a_swelling; diff --git a/db/schemas/sokwedb/tables/Makefile b/db/schemas/sokwedb/tables/Makefile index 917c9e8..254caac 100644 --- a/db/schemas/sokwedb/tables/Makefile +++ b/db/schemas/sokwedb/tables/Makefile @@ -41,7 +41,8 @@ ORDER := biography_data \ non_brec_sighting_sources \ food_events \ groomings \ - groom_scans_b + groom_scans_b \ + arrivals_a ## ## CAUTION: This Makefile is not designed to be run directly. It is normally ## invoked by another Makefile. diff --git a/db/schemas/sokwedb/tables/create/arrivals_a.m4 b/db/schemas/sokwedb/tables/create/arrivals_a.m4 new file mode 100644 index 0000000..03f28eb --- /dev/null +++ b/db/schemas/sokwedb/tables/create/arrivals_a.m4 @@ -0,0 +1,58 @@ +dnl Copyright (C) 2026 The Meme Factory, Inc., http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`tablemacros.m4')dnl +include(`grants.m4')dnl +dnl + +CREATE TABLE arrivals_a ( + key_column(`ARRIVALS_A', `ArAID', INTEGER) + ,eid INTEGER NOT NULL + REFERENCES events + ,seq INTEGER NOT NULL + positive_check(`Seq') + ,swelling TEXT NOT NULL + REFERENCES cycle_states + ,bananas INTEGER + nonnegative_check(`Bananas') + CONSTRAINT "Bananas must be <= sdb_max_bananas" + CHECK (bananas <= sdb_max_bananas) + ,arrivaldegree INTEGER + CONSTRAINT "ArrivalDegree must be >= sdb_min_degree and <= sdb_max_degree" + CHECK (sdb_min_degree <= arrivaldegree + AND arrivaldegree <= sdb_max_degree) + ,departuredegree INTEGER + CONSTRAINT + "DepartureDegree must be >= sdb_min_degree and <= sdb_max_degree" + CHECK (sdb_min_degree <= departuredegree + AND departuredegree <= sdb_max_degree) + ,recorder TEXT NOT NULL + REFERENCES people + ,observer2 TEXT NOT NULL + REFERENCES people + ,cycleold TEXT NOT NULL + notonlyspaces_check(`CycleOld') + + CONSTRAINT "The Recorder value may not equal the Observer2 value" + CHECK(recorder <> observer2) +); + +grant_priv(`ARRIVALS_A') diff --git a/db/schemas/sokwedb/tables/create/events.m4 b/db/schemas/sokwedb/tables/create/events.m4 index b26bf1b..fc29e5d 100644 --- a/db/schemas/sokwedb/tables/create/events.m4 +++ b/db/schemas/sokwedb/tables/create/events.m4 @@ -93,6 +93,7 @@ CREATE TABLE events ( CONSTRAINT "Behavior must be one of the allowed special values" CHECK (behavior IN ('sdb_aggression' , 'sdb_arrival' + , 'sdb_arrival_a' , 'sdb_food' , 'sdb_grooming' , 'sdb_groom_scan' @@ -125,6 +126,9 @@ CREATE TABLE events ( _pair_behavior_source(`sdb_grooming', `FID') _pair_behavior_source(`sdb_groom_scan', `FID') + _pair_behavior_source(`sdb_arrival_a', `AtID') + + _behavior_certain(`sdb_arrival_a') _behavior_certain(`sdb_groom_scan') ); diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index 436bd0a..1f33122 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -139,6 +139,29 @@ sdb_generated_rst()dnl replace:: :ref:`Cycle ` .. |ARRIVALS.DataSource| replace:: :ref:`DataSource ` + +.. |ARRIVALS_A| + replace:: :ref:`ARRIVALS_A ` +.. |ARRIVALS_A.ArAID| + replace:: :ref:`ArAID ` +.. |ARRIVALS_A.EID| + replace:: :ref:`EID ` +.. |ARRIVALS_A.Seq| + replace:: :ref:`Seq ` +.. |ARRIVALS_A.Swelling| + replace:: :ref:`Swelling ` +.. |ARRIVALS_A.Bananas| + replace:: :ref:`Bananas ` +.. |ARRIVALS_A.ArrivalDegree| + replace:: :ref:`ArrivalDegree ` +.. |ARRIVALS_A.DepartureDegree| + replace:: :ref:`DepartureDegree ` +.. |ARRIVALS_A.Recorder| + replace:: :ref:`Recorder ` +.. |ARRIVALS_A.Observer2| + replace:: :ref:`Observer2 ` +.. |ARRIVALS_A.CycleOld| + replace:: :ref:`CycleOld ` .. |ARRIVAL_SOURCES| replace:: :ref:`ARRIVAL_SOURCES ` diff --git a/doc/src/tables.m4 b/doc/src/tables.m4 index 1a4c6c7..6f01a3e 100644 --- a/doc/src/tables.m4 +++ b/doc/src/tables.m4 @@ -35,6 +35,7 @@ and are therefore the result of at least a rudimentary analytical process. tables/aggression_event_log.rst tables/aggressions.rst tables/arrivals.rst + tables/arrivals_a.rst tables/attendance.rst tables/biography_data.rst tables/biography_log.rst diff --git a/doc/src/tables/arrivals_a.m4 b/doc/src/tables/arrivals_a.m4 new file mode 100644 index 0000000..71ac5b8 --- /dev/null +++ b/doc/src/tables/arrivals_a.m4 @@ -0,0 +1,226 @@ +.. Copyright (C) 2026 The Meme Factory, Inc. www.karlpinc.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +.. M4 setup +include(constants.m4)dnl +include(macros.m4)dnl +sdb_rst_quotes(`on')dnl +sdb_generated_rst()dnl + +.. _ARRIVALS_A: + +ARRIVALS_A +---------- + +.. |ARRIVALS_A_summary| replace:: + Each row represents an interval during which a single chimpanzee + was present at the feeding station. + +|ARRIVALS_A_summary| + +The system will generate a warning if the ``sdb_male_swelling`` code +is assigned to a female, an individual with a |BIOGRAPHY_DATA|.\ +|BIOGRAPHY_DATA.Sex| value of ``sdb_female``. + +The system will generate a warning if any code other than the +``sdb_male_swelling`` code is assigned to an individual who is not a +female, an individual with a |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.Sex| +value that is not ``sdb_female``. + +Except for the unknown female individuals, those with a +|BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID| of ``sdb_stranger_female``, +or ``sdb_stranger_female2``, or ``sdb_stranger_female3``, the system +will generate a warning if the ``sdb_adolescent_swelling`` code is +assigned to a female less than ``sdb_min_adolescent_age`` +sdb_min_adolescent_age_units old or more than +``sdb_max_adolescent_age`` sdb_max_adolescent_age_units old. + +Except for the unknown female individuals, those with a +|BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID| of ``sdb_stranger_female``, +or ``sdb_stranger_female2``, or ``sdb_stranger_female3``, the system +will generate a warning if a code that is not one of +``sdb_male_swelling``, ``sdb_adolescent_swelling``, +``sdb_no_swelling``, and ``sdb_missing_swelling`` is assigned to a +female that is at least ``sdb_min_swelling_age`` +sdb_min_swelling_age_units old and less than or equal to +``sdb_max_swelling_age`` sdb_max_swelling_age_units old. + +The |ARRIVALS_A.Recorder| value may not be the same as the +|ARRIVALS_A.Observer2| value. + +.. contents:: + :depth: 2 + + +.. _ARRIVALS_A.ArAID: + +ArAID (Arrivals_A ID) +````````````````````` + +.. |ARRIVALS_A.ArAID_summary| replace:: |idcol| + +|ARRIVALS_A.ArAID_summary| |notnull| + + +.. _ARRIVALS_A.EID: + +EID (Event ID) +`````````````` + +.. |ARRIVALS_A.EID_summary| replace:: + + The |EVENTS|.\ |EVENTS.EID| identifying the feeding station arrival + event that is related to the arrival and departure. + +|ARRIVALS_A.EID_summary| +The related event contains information on arrival and departure times. + +|notnull| + + +.. _ARRIVALS_A.Seq: + +Seq (Sequence) +`````````````` + +.. |ARRIVALS_A.Seq_summary| replace:: + An integer indicating the order in which an individual arrived, in + the sequence of arrivals of a given individual, in a given feeding + station attendance event. + +|ARRIVALS_A.Seq_summary| +This means the order of the arrival, per individual, per day. + +This column records the ordering of the arrivals of a single +individual, within a given given day, at the feeding station. + +The values should start with ``1`` and increase without gaps, each +successive arrival of an individual incrementing by one the value of +the previous arrival. +The system will generate a warning, per condition, if either of these +2 conditions are not met. + +.. So, each of these conditions has its own warning in the warning system. + +|notnull| + + +.. _ARRIVALS_A.Swelling: + +Swelling +```````` + +.. |ARRIVALS_A.Swelling_summary| replace:: + A code indicating the degree of the individual's sexual swelling. + A |CYCLE_STATES|.\ |CYCLE_STATES.Code| value. + +|ARRIVALS_A.Swelling_summary| +|notnull| + + +.. _ARRIVALS_A.Bananas: + +Bananas +``````` + +.. |ARRIVALS_A.Bananas_summary| replace:: + + An integer, the number of bananas that were given to the + individual. + +|ARRIVALS_A.Bananas_summary| +This value must be a positive number, less than or equal to +``sdb_max_bananas``. + +This column may be |null| when there is no record of whether or not +bananas were given. + + +.. _ARRIVALS_A.ArrivalDegree: + +ArrivalDegree +````````````` + +.. |ARRIVALS_A.ArrivalDegree_summary| replace:: + + The direction from which the individual arrived, on a 360 degree + circle with ``0`` being north. + +|ARRIVALS_A.ArrivalDegree_summary| +The value of this column must be an integer between ``sdb_min_degree`` +and ``sdb_max_degree``, inclusive. + +This column may be |null| when there is no record of the direction +from which the individual arrived. + + +.. _ARRIVALS_A.DepartureDegree: + +DepartureDegree +``````````````` + +.. |ARRIVALS_A.DepartureDegree_summary| replace:: + + The direction toward which the individual traveled when they + departed, on a 360 degree circle with ``0`` being north. + +|ARRIVALS_A.DepartureDegree_summary| +The value of this column must be an integer between ``sdb_min_degree`` +and ``sdb_max_degree``, inclusive. + +This column may be |null| when there is no record of the direction +toward which the individual traveled when they departed. + + +.. _ARRIVALS_A.Recorder: + +Recorder +```````` + +.. |ARRIVALS_A.Recorder_summary| replace:: + + The observer who recorded the arrivals_a record. + A |PEOPLE|.\ |PEOPLE.Person| value. + +|ARRIVALS_A.Recorder_summary| |notnull| + + +.. _ARRIVALS_A.Observer2: + +Observer2 +````````` + +.. |ARRIVALS_A.Observer2_summary| replace:: + + A second observer who was present when the arrivals_a was recorded. + A |PEOPLE|.\ |PEOPLE.Person| value. + +|ARRIVALS_A.Observer2_summary| +|notnull| + + +.. _ARRIVALS_A.CycleOld: + +CycleOld +```````` + +.. |ARRIVALS_A.CycleOld_summary| replace:: + + Text comprising the initial digitization of information related to + the individuals sexual swelling. + +|ARRIVALS_A.CycleOld_summary| + +|notonlyspaces| |notnull| diff --git a/doc/src/tables/attendance.m4 b/doc/src/tables/attendance.m4 index 5ff6508..578f971 100644 --- a/doc/src/tables/attendance.m4 +++ b/doc/src/tables/attendance.m4 @@ -36,6 +36,13 @@ This means that for any given |ATTENDANCE.AnimID|, for any given |ATTENDANCE.Date|, that there may not be another ATTENDANCE row for the given individual. +The system will generate a warning when an ATTENDANCE row does not +have a |ARRIVALS_A| related row that records the presence of the +individual: does not have a related |EVENTS| row where the +|EVENTS.Behavior| code is ``sdb_arrival_a``, and a |ROLES| row, +related to the event, where the |ROLES|.\ |ROLES.Participant| has the +same value as the attendance record's |ATTENDANCE.AnimID| column. + The |ATTENDANCE.Date| must be during a period when the arriving individual was under study. This means that the |ATTENDANCE.Date| must be on or after the arriving diff --git a/doc/src/tables/events.m4 b/doc/src/tables/events.m4 index 6ced5f3..77387b3 100644 --- a/doc/src/tables/events.m4 +++ b/doc/src/tables/events.m4 @@ -60,6 +60,54 @@ retain data validity, and what each code implies about the meaning of related data. The following table lists these rules and implications: +.. _EVENTS_arrival_a_code: + +``sdb_arrival_a`` (Arrival at the feeding station) + The EVENTS row must be associated with a record of attendance at + the feeding station. + This means the |EVENTS.AtID| column must not be |null|. + + A related row should exist on |ARRIVALS_A|; there should be a row + on |ARRIVALS_A| with an |ARRIVALS_A|.\ |ARRIVALS_A.EID| value of + the event's |EVENTS.EID|. + There may be at most one of these related |ARRIVALS_A| rows. + The system will generate a warning when there is no |ARRIVALS_A| + row related to the arrival event. + + The |ROLES| row related to the event, the row with a |ROLES|.\ + |ROLES.EID| value equal to the EVENTS.\ |EVENTS.EID| value, + designates the arriving/departing individual. + There may be at most one |ROLES| row related to the arrival event. + The system will generate a warning when there is no |ROLES| row + related to the arrival event. + + The EVENTS.\ |EVENTS.Start| column contains the arrival time of + the individual identified in the related |ROLES| row. + + The |EVENTS|.\ |EVENTS.Stop| column contains the departure time of + the the individual identified in the related |ROLES| row. + + For records of attendance at the feeding station, the |EVENTS|.\ + |EVENTS.Certainty| column must be ``sdb_identity_certain``. + + An individual should not be recorded as being at the feeding + station more than once during any given time period. + This means that for any given EVENTS row, with a given (non-|null|) + |EVENTS.AtID| value, there should not be another EVENTS row with + that |EVENTS.AtID| value, with an |EVENTS.Start| value less than or + equal to the given EVENTS row's start time, when the other row's + |EVENTS.Stop| value is greater than or equal to the given + EVENTS row's start time. + A similar rule applies to the given EVENTS row's stop time. + Which means, for any given EVENTS row, with a given (non-|null|) + |EVENTS.AtID| value, there should not be another EVENTS row with + that |EVENTS.AtID| value, with an |EVENTS.Start| value less than or + equal to the given EVENTS row's stop time, when the other row's + |EVENTS.Stop| value is greater than or equal to the given + EVENTS row's stop time. + The system will generate a warning when there are overlaps in an + individual's presence at the feeding station. + .. _EVENTS_aggression_code: ``sdb_aggression`` (Aggression) @@ -332,6 +380,9 @@ information about the event. The following list summarizes the available codes: +``sdb_arrival_a`` (Arrival at the feeding station) + A row must exist on ARRIVALS_A + ``sdb_aggression`` (Aggression) A row must exist on |AGGRESSIONS|. diff --git a/include/global_constants.m4 b/include/global_constants.m4 index 5d516f2..622e515 100644 --- a/include/global_constants.m4 +++ b/include/global_constants.m4 @@ -113,6 +113,8 @@ define(`sdb_dad_prelim', `Prelim') dnl dnl EVENTS dnl +dnl The arrival at the feeding station event +define(`sdb_arrival_a', `AARR') dnl The aggression event define(`sdb_aggression', `AGG') dnl The arrival event -- 2.34.1