From d782667305229d4e1b3ae0e7b174b3aa3f7ca888 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Fri, 19 Jun 2026 18:09:21 +0000 Subject: [PATCH] Create, document, index, and trigger COLOBUS --- db/schemas/lib/triggers/Makefile | 3 +- db/schemas/lib/triggers/create/colobus.m4 | 148 +++++ db/schemas/lib/triggers/create/events.m4 | 3 +- db/schemas/lib/triggers/create/roles.m4 | 6 +- db/schemas/lib/triggers/drop/colobus.m4 | 23 + db/schemas/sokwedb/indexes/Makefile | 3 +- db/schemas/sokwedb/indexes/create/colobus.m4 | 49 ++ db/schemas/sokwedb/indexes/drop/colobus.m4 | 34 ++ db/schemas/sokwedb/tables/Makefile | 3 +- db/schemas/sokwedb/tables/create/colobus.m4 | 66 ++ db/schemas/sokwedb/tables/create/events.m4 | 1 + doc/diagrams/events2.svg | 611 ++++++++++++++++++- doc/src/epilog.inc.m4 | 52 ++ doc/src/tables.m4 | 1 + doc/src/tables/colobus.m4 | 428 +++++++++++++ doc/src/tables/events.m4 | 32 + include/global_constants.m4 | 2 + 17 files changed, 1456 insertions(+), 9 deletions(-) create mode 100644 db/schemas/lib/triggers/create/colobus.m4 create mode 100644 db/schemas/lib/triggers/drop/colobus.m4 create mode 100644 db/schemas/sokwedb/indexes/create/colobus.m4 create mode 100644 db/schemas/sokwedb/indexes/drop/colobus.m4 create mode 100644 db/schemas/sokwedb/tables/create/colobus.m4 create mode 100644 doc/src/tables/colobus.m4 diff --git a/db/schemas/lib/triggers/Makefile b/db/schemas/lib/triggers/Makefile index 09ff188..f617f3a 100644 --- a/db/schemas/lib/triggers/Makefile +++ b/db/schemas/lib/triggers/Makefile @@ -46,7 +46,8 @@ ORDER := comm_ids \ repro_states \ pantgrunts \ pantgrunts_view \ - brecord_notes + brecord_notes \ + colobus DROP_EXISTING := true diff --git a/db/schemas/lib/triggers/create/colobus.m4 b/db/schemas/lib/triggers/create/colobus.m4 new file mode 100644 index 0000000..fbf397e --- /dev/null +++ b/db/schemas/lib/triggers/create/colobus.m4 @@ -0,0 +1,148 @@ +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 colobus table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl +include(`constants.m4')dnl +include(`macros.m4')dnl + + +RAISE INFO 'colobus_func'; +CREATE OR REPLACE FUNCTION colobus_func () + RETURNS trigger + LANGUAGE plpgsql + sdb_function_set_search_path + AS $$ + BEGIN + -- Function for colobus insert and update triggers + -- + -- AGPL_notice(` --', `2026', + `The Meme Factory, Inc., www.karlpinc.com') + + IF TG_OP = 'UPDATE' THEN + cannot_change(`COLOBUS', `EID') + END IF; + + -- The EVENTS.Behavior must be sdb_colobus + IF TG_OP = 'INSERT' THEN + DECLARE + -- EVENTS + a_behavior events.behavior%TYPE; + a_start events.start%TYPE; + a_stop events.stop%TYPE; + -- WATCHES + a_wid watches.wid%TYPE; + a_focal watches.focal%TYPE; + a_date watches.date%TYPE; + + BEGIN + SELECT events.behavior, events.start, events.stop + , watches.wid, watches.focal, watches.date + INTO a_behavior , a_start , a_stop + , a_wid , a_focal , a_date + FROM events + JOIN watches ON (watches.wid = events.wid) + WHERE events.eid = NEW.eid + AND events.behavior <> 'sdb_colobus'; + IF FOUND THEN + RAISE EXCEPTION integrity_constraint_violation USING + MESSAGE = 'Error on ' || TG_OP || ' of COLOBUS' + , DETAIL = 'Colobus hunt detail can only be related to an event' + || ' with an EVENTS.Behavior value of (sdb_colobus)' + || ': Key (EID = (' + || NEW.eid + || '): Value (StartMap) = (' + || NEW.startmap + || '): Value (Hunt) = (' + || NEW.hunt + || '): Value (Hunters) = (' + || NEW.hunters + || '): Value (HuntCert) = (' + || NEW.huntcert + || '): Value (MaleHunt) = (' + || NEW.malehunt + || '): Value (FemaleHunt) = (' + || NEW.FemaleHunt + || '): Value (FocalHunt) = (' + || NEW.focalhunt + || '): Value (FocalHuntCert) = (' + || NEW.focalhuntcert + || '): Value (Kill) = (' + || NEW.kill + || '): Value (Killers) = (' + || NEW.killers + || '): Value (NumKills) = (' + || NEW.NumKills + || '): Value (MaleNumKills) = (' + || NEW.malenumkills + || '): Value (FemaleNumKills) = (' + || NEW.femalenumkills + || '): Value (FocalMaleNumKills) = (' + || textualize(`NEW.focalmalenumkills') + || '): Value (FocalFemaleNumKills) = (' + || textualize(`NEW.focalfemalenumkills') + || '): Value (VictimsAges) = (' + || NEW.victimsages + || '): Value (InfantsKilled) = (' + || NEW.infantskilled + || '): Value (JuvenilesKilled) = (' + || NEW.juvenileskilled + || '): Value (AdultsKilled) = (' + || NEW.adultskilled + || '): Value (NoAgeKilled) = (' + || NEW.noagekilled + || '): Value (GroupSize) = (' + || NEW.groupsize + || '): Value (Details) = (' + || NEW.detail + || '): Value (Vegetation) = (' + || NEW.vegetation + || '): Value (FailureDetails) = (' + || NEW.failuredetails + || '): Value (Description) = (' + || NEW.description + || '): Key (EVENTS.EID) = (' + || NEW.eid + || '): Value (EVENTS.Behavior) = (' + || a_behavior + || '), Value (EVENTS.Start) = (' + || a_start + || '), Value (EVENTS.Stop) = (' + || a_stop + || '): Key (WATCHES.WID) = (' + || a_wid + || '), Value (WATCHES.Focal) = (' + || a_focal + || '), Value (WATCHES.Date) = (' + || a_date + || ')'; + END IF; + END; + END IF; + + RETURN NULL; + END; +$$; + + +RAISE INFO 'colobus_trigger'; +CREATE TRIGGER colobus_trigger + AFTER INSERT OR UPDATE + ON colobus FOR EACH ROW + EXECUTE PROCEDURE colobus_func(); diff --git a/db/schemas/lib/triggers/create/events.m4 b/db/schemas/lib/triggers/create/events.m4 index 41daf89..1e2a8fd 100644 --- a/db/schemas/lib/triggers/create/events.m4 +++ b/db/schemas/lib/triggers/create/events.m4 @@ -83,7 +83,8 @@ CREATE OR REPLACE FUNCTION events_func () ,'sdb_food' ,'sdb_grooming' ,'sdb_groom_scan' - ,'sdb_other_species') THEN + ,'sdb_other_species' + ,'sdb_colobus') THEN -- The event must be related to a follow. watch_type := 'sdb_follow'; ELSIF NEW.behavior IN ('sdb_arrival_a' diff --git a/db/schemas/lib/triggers/create/roles.m4 b/db/schemas/lib/triggers/create/roles.m4 index 7aa8d63..25a580a 100644 --- a/db/schemas/lib/triggers/create/roles.m4 +++ b/db/schemas/lib/triggers/create/roles.m4 @@ -71,10 +71,12 @@ CREATE OR REPLACE FUNCTION roles_func () WHERE events.eid = NEW.eid; END IF; - -- The event may not be a sdb_other_species, or sdb_brec_note, type of event + -- The event may not be a sdb_other_species, or sdb_brec_note, + -- or sdb_colobus type of event IF TG_OP = 'INSERT' AND (a_behavior = 'sdb_other_species' - OR a_behavior = 'sdb_brec_note') THEN + OR a_behavior = 'sdb_brec_note' + OR a_behavior = 'sdb_colobus') THEN DECLARE a_focal watches.focal%TYPE; a_date watches.date%TYPE; diff --git a/db/schemas/lib/triggers/drop/colobus.m4 b/db/schemas/lib/triggers/drop/colobus.m4 new file mode 100644 index 0000000..b2a9ae4 --- /dev/null +++ b/db/schemas/lib/triggers/drop/colobus.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 colobus table +dnl +dnl Karl O. Pinc + +dnl m4 includes +include(`copyright.m4')dnl + +DROP FUNCTION IF EXISTS colobus_func() CASCADE; diff --git a/db/schemas/sokwedb/indexes/Makefile b/db/schemas/sokwedb/indexes/Makefile index c122efa..cb7fc0e 100644 --- a/db/schemas/sokwedb/indexes/Makefile +++ b/db/schemas/sokwedb/indexes/Makefile @@ -23,7 +23,8 @@ ORDER := biography_data biography_log comm_membs comm_memb_log \ watches follow_observers follow_studies events roles arrivals \ swelling_sources swelling_states aggression_event_log sightings \ aggressions food_events groomings attendance \ - arrivals_a species_present repro_states locations_gps locations_map + arrivals_a species_present repro_states locations_gps locations_map \ + colobus ## ## CAUTION: This Makefile is not designed to be run directly. It is normally diff --git a/db/schemas/sokwedb/indexes/create/colobus.m4 b/db/schemas/sokwedb/indexes/create/colobus.m4 new file mode 100644 index 0000000..4d63b50 --- /dev/null +++ b/db/schemas/sokwedb/indexes/create/colobus.m4 @@ -0,0 +1,49 @@ +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 INDEX IF NOT EXISTS colobus_startmap ON colobus + (startmap); +CREATE INDEX IF NOT EXISTS colobus_numkills ON colobus + (numkills); +CREATE INDEX IF NOT EXISTS colobus_malenumkills ON colobus + (malenumkills); +CREATE INDEX IF NOT EXISTS colobus_femalenumkills ON colobus + (femalenumkills); +CREATE INDEX IF NOT EXISTS colobus_focalmalenumkills ON colobus + (focalmalenumkills) + WHERE focalmalenumkills IS NOT NULL; +CREATE INDEX IF NOT EXISTS colobus_focalfemalenumkills ON colobus + (focalfemalenumkills) + WHERE focalfemalenumkills IS NOT NULL; +CREATE INDEX IF NOT EXISTS colobus_numkills ON colobus + (numkills); +CREATE INDEX IF NOT EXISTS colobus_infantskilled ON colobus + (infantskilled); +CREATE INDEX IF NOT EXISTS colobus_juvenileskilled ON colobus + (juvenileskilled); +CREATE INDEX IF NOT EXISTS colobus_adultskilled ON colobus + (adultskilled); +CREATE INDEX IF NOT EXISTS colobus_noagekilled ON colobus + (noagekilled); + + diff --git a/db/schemas/sokwedb/indexes/drop/colobus.m4 b/db/schemas/sokwedb/indexes/drop/colobus.m4 new file mode 100644 index 0000000..41c6aba --- /dev/null +++ b/db/schemas/sokwedb/indexes/drop/colobus.m4 @@ -0,0 +1,34 @@ +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 colobus_startmap; +DROP INDEX IF EXISTS colobus_numkills; +DROP INDEX IF EXISTS colobus_malenumkills; +DROP INDEX IF EXISTS colobus_femalenumkills; +DROP INDEX IF EXISTS colobus_focalmalenumkills; +DROP INDEX IF EXISTS colobus_focalfemalenumkills; +DROP INDEX IF EXISTS colobus_numkills; +DROP INDEX IF EXISTS colobus_infantskilled; +DROP INDEX IF EXISTS colobus_juvenileskilled; +DROP INDEX IF EXISTS colobus_adultskilled; +DROP INDEX IF EXISTS colobus_noagekilled; diff --git a/db/schemas/sokwedb/tables/Makefile b/db/schemas/sokwedb/tables/Makefile index 657b42a..51c5e20 100644 --- a/db/schemas/sokwedb/tables/Makefile +++ b/db/schemas/sokwedb/tables/Makefile @@ -47,7 +47,8 @@ ORDER := biography_data \ locations_gps \ locations_map \ pantgrunts \ - brecord_notes + brecord_notes \ + colobus ## ## 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/colobus.m4 b/db/schemas/sokwedb/tables/create/colobus.m4 new file mode 100644 index 0000000..a5e0ef7 --- /dev/null +++ b/db/schemas/sokwedb/tables/create/colobus.m4 @@ -0,0 +1,66 @@ +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 colobus ( + eid INTEGER NOT NULL + REFERENCES events + ,startmap TIME WITHOUT TIME ZONE NOT NULL + ,hunt BOOLEAN NOT NULL + ,hunters TEXT NOT NULL + notonlyspaces_check(`Hunters') + ,huntcert BOOLEAN NOT NULL + ,malehunt BOOLEAN NOT NULL + ,femalehunt BOOLEAN NOT NULL + ,focalhunt BOOLEAN NOT NULL + ,focalhuntcert BOOLEAN NOT NULL + ,kill BOOLEAN NOT NULL + ,killers TEXT NOT NULL + notonlyspaces_check(`Killers') + ,numkills INTEGER NOT NULL + ,malenumkills INTEGER NOT NULL + ,femalenumkills INTEGER NOT NULL + ,focalmalenumkills INTEGER + ,focalfemalenumkills INTEGER + ,victimsages TEXT NOT NULL + notonlyspaces_check(`VictimsAges') + ,infantskilled INTEGER NOT NULL + ,juvenileskilled INTEGER NOT NULL + ,adultskilled INTEGER NOT NULL + ,noagekilled INTEGER NOT NULL + ,groupsize TEXT NOT NULL + REFERENCES colobus_group_sizes + ,details TEXT NOT NULL + notonlyspaces_check(`Details') + ,vegetation TEXT NOT NULL + notonlyspaces_check(`Vegetation') + ,failuredetails TEXT NOT NULL + notonlyspaces_check(`FailureDetails') + ,description TEXT NOT NULL + notonlyspaces_check(`Description') +); + +eid_primary_key(`COLOBUS') + +grant_priv(`COLOBUS') diff --git a/db/schemas/sokwedb/tables/create/events.m4 b/db/schemas/sokwedb/tables/create/events.m4 index 39c2830..33011b3 100644 --- a/db/schemas/sokwedb/tables/create/events.m4 +++ b/db/schemas/sokwedb/tables/create/events.m4 @@ -109,6 +109,7 @@ CREATE TABLE events ( _behavior_certain(`sdb_gps') _behavior_certain(`sdb_map') _behavior_certain(`sdb_brec_note') + _behavior_certain(`sdb_colobus') ); grant_priv(`EVENTS') diff --git a/doc/diagrams/events2.svg b/doc/diagrams/events2.svg index 17fada2..589e824 100644 --- a/doc/diagrams/events2.svg +++ b/doc/diagrams/events2.svg @@ -868,6 +868,34 @@ ry="0.900998" /> + + + + + + information + Colobusmonkeyhunteventinformation + Colobusmonkeyhuntdetail + COLOBUS + + StartMap + + Hunt + + Hunters + + HuntCert + + MaleHunt + + FemaleHunt + + EID + + + FocalHunt + + Kill + + FocalHuntCert + + Killers + + MaleNumKills + + FemaleNumKills + + FocalMaleNumKills ∅ + + FocalFemaleNumKills ∅ + + VictimsAges + + InfantsKilled + + NumKills + + + JuvenilesKilled + + NoAgeKilled + + AdultsKilled + + + GroupSize * + + Vegetation + + FailureDetails + + Description + + Details + + diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index cfa2038..07f1231 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -247,6 +247,58 @@ sdb_generated_rst()dnl .. |CERTAINTIES.Description| replace:: :ref:`Description ` +.. |COLOBUS| replace:: :ref:`COLOBUS ` +.. |COLOBUS.EID| replace:: + :ref:`EID ` +.. |COLOBUS.StartMap| replace:: + :ref:`StartMap ` +.. |COLOBUS.Hunt| replace:: + :ref:`Hunt ` +.. |COLOBUS.Hunters| replace:: + :ref:`Hunters ` +.. |COLOBUS.HuntCert| replace:: + :ref:`HuntCert ` +.. |COLOBUS.MaleHunt| replace:: + :ref:`MaleHunt ` +.. |COLOBUS.FemaleHunt| replace:: + :ref:`FemaleHunt ` +.. |COLOBUS.FocalHunt| replace:: + :ref:`FocalHunt ` +.. |COLOBUS.FocalHuntCert| replace:: + :ref:`FocalHuntCert ` +.. |COLOBUS.Kill| replace:: + :ref:`Kill ` +.. |COLOBUS.Killers| replace:: + :ref:`Killers ` +.. |COLOBUS.NumKills| replace:: + :ref:`NumKills ` +.. |COLOBUS.MaleNumKills| replace:: + :ref:`MaleNumKills ` +.. |COLOBUS.FocalMaleNumKills| replace:: + :ref:`FocalMaleNumKills ` +.. |COLOBUS.FocalFemaleNumKills| replace:: + :ref:`FocalFemaleNumKills ` +.. |COLOBUS.VictimsAges| replace:: + :ref:`VictimsAges ` +.. |COLOBUS.InfantsKilled| replace:: + :ref:`InfantsKilled ` +.. |COLOBUS.JuvenilesKilled| replace:: + :ref:`JuvenilesKilled ` +.. |COLOBUS.AdultsKilled| replace:: + :ref:`AdultsKilled ` +.. |COLOBUS.NoAgeKilled| replace:: + :ref:`NoAgeKilled ` +.. |COLOBUS.GroupSize| replace:: + :ref:`GroupSize ` +.. |COLOBUS.Details| replace:: + :ref:`Details ` +.. |COLOBUS.Vegetation| replace:: + :ref:`Vegetation ` +.. |COLOBUS.FailureDetails| replace:: + :ref:`FailureDetails ` +.. |COLOBUS.Description| replace:: + :ref:`Description ` + .. |COLOBUS_GROUP_SIZES| replace:: :ref:`COLOBUS_GROUP_SIZES ` .. |COLOBUS_GROUP_SIZES.Size| replace:: diff --git a/doc/src/tables.m4 b/doc/src/tables.m4 index 4e32581..443330e 100644 --- a/doc/src/tables.m4 +++ b/doc/src/tables.m4 @@ -39,6 +39,7 @@ and are therefore the result of at least a rudimentary analytical process. tables/biography_data.rst tables/biography_log.rst tables/brecord_notes.rst + tables/colobus.rst tables/comm_membs.rst tables/comm_memb_log.rst tables/swelling_sources.rst diff --git a/doc/src/tables/colobus.m4 b/doc/src/tables/colobus.m4 new file mode 100644 index 0000000..e7d1eab --- /dev/null +++ b/doc/src/tables/colobus.m4 @@ -0,0 +1,428 @@ +.. 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 + +.. _COLOBUS: + +COLOBUS (COLOBUS hunts) +----------------------- + +.. |COLOBUS_summary| replace:: + Each row, taken together with the related |EVENTS| row, represents + a record of colobus monkey hunting recorded during a follow. + +|COLOBUS_summary| + +The related |EVENTS| row must be a colobus monkey hunting event; it +must have an |EVENTS|.\ |EVENTS.Behavior| value of ``sdb_colobus``. +This related |EVENTS| row supplies the start and stop times for the +hunt, as well as comments and/or a description of the hunt. + +There should be only one colobus monkey hunting event occurring at any +given time, in any given follow. +This means that the system will generate a warning when there are two +EVENTS rows with the same |EVENTS.WID| value and the |EVENTS.Start| of +the first is equal to or before the |EVENTS.Start| of the second, and +the |EVENTS.Stop| of the first is equal to or after the |EVENTS.Start| +of the second. + +If the |COLOBUS.FocalMaleNumKills| column is not |null|, and not +``0``, the focal of the follow should be male. +The system will generate a warning when there are kills recorded for +the focal male and the focal is not male -- when the +|BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.Sex| column has a value other than +``sdb_male``. + +If the |COLOBUS.FocalFemaleNumKills| column is not |null|, and not +``0``, the focal of the follow should be female. +The system will generate a warning when there are kills recorded for +the focal female and the focal is not female -- when the +|BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.Sex| column has a value other than +``sdb_female``. + +The |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID|\ s in the +|COLOBUS.Hunters| column's text should be separated by commas. +The system will generate a warning if the comma-separated components +of this column are not |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID| +values. + +The |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID|\ s in the +|COLOBUS.Killers| column's text should be separated by commas. +The system will generate a warning if the comma-separated components +of this column are not |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID| +values. + +For further information, including additional data integrity rules, +see the documentation of the :ref:`EVENTS ` +table. + +.. contents:: + :depth: 2 + + +.. _COLOBUS.EID: + +EID (Event ID) +`````````````` + +.. |COLOBUS.EID_summary| replace:: + |idcol| + The |EVENTS|.\ |EVENTS.EID| identifying the colobus monkey hunting event. + +|COLOBUS.EID_summary| +The related event contains information on hunt start and stop times, +and notes. + +|notnull| + + +.. _COLOBUS.StartMap: + +StartMap (START time rounded to MAPping interval) +````````````````````````````````````````````````` + +.. |COLOBUS.StartMap_summary| replace:: + The start time of the encounter rounded to the nearest 15 minute interval. + +|COLOBUS.StartMap_summary| +Rounding is down, when the start time is after the 15 minute interval +by 7 minutes or less. +Otherwise rounding is up. + +The gloal is to have a time which corresponds to the location times of +the |LOCATIONS_MAP| rows. [#f1]_ +In some cases, changes were made based on notes. + +|notnull| + +.. _COLOBUS.Hunt: + +Hunt (was there a HUNT?) +```````````````````````` + +.. |COLOBUS.Hunt_summary| replace:: + A |boolean|, |true| when at least one chimpanzee hunted. + +|COLOBUS.Hunt_summary| |notnull| + + +.. _COLOBUS.Hunters: + +Hunters +``````` + +.. |COLOBUS.Hunters_summary| replace:: + Text listing the |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID|\ s of the + individuals that were seen to climb in pursuit of monkeys. + +|COLOBUS.Hunters_summary| + +|notonlyspaces| +|notnull| + + +.. _COLOBUS.HuntCert: + +HuntCert (HUNT CERTantity) +`````````````````````````` + +.. |COLOBUS.HuntCert_summary| replace:: + A |boolean|, |true| when the notes were of sufficient detail to + determine if at least one chimp climbed in pursuit. + + +|COLOBUS.HuntCert_summary| +|notnull| + + +.. _COLOBUS.MaleHunt: + +MaleHunt (did a MALE HUNT?) +``````````````````````````` + +.. |COLOBUS.MaleHunt_summary| replace:: + A |boolean|, |true| when a male (of any age) climbed in pursuit. + +|COLOBUS.MaleHunt_summary| +|notnull| + + +.. _COLOBUS.FemaleHunt: + +FemaleHunt (did a FEMALE HUNT?) +``````````````````````````````` + +.. |COLOBUS.FemaleHunt_summary| replace:: + A |boolean|, |true| when a female (of any age) climbed in pursuit. + +|COLOBUS.FemaleHunt_summary| +|notnull| + + +.. _COLOBUS.FocalHunt: + +FocalHunt (did the FOCAL HUNT?) +``````````````````````````````` + +.. |COLOBUS.FocalHunt_summary| replace:: + A |boolean|, |true| when the focal chimpanzee climbed in pursuit. + +|COLOBUS.FocalHunt_summary| +|notnull| + + +.. _COLOBUS.FocalHuntCert: + +FocalHuntCert (is it CERTain the FOCAL HUNTed?) +``````````````````````````````````````````````` + +.. |COLOBUS.FocalHuntCert_summary| replace:: + A |boolean|, |true| when the notes were of sufficient detail to + determine that the focal chimp climbed in pursuit. + +|COLOBUS.FocalHuntCert_summary| + +This column may be |null| when there is no information. + + +.. _COLOBUS.Kill: + +Kill +```` + +.. |COLOBUS.Kill_summary| replace:: + A |boolean|, |true| when a monkey was killed by any chimpanzee. + +|COLOBUS.Kill_summary| +|notnull| + + +.. _COLOBUS.Killers: + +Killers +``````` + +.. |COLOBUS.Killers_summary| replace:: + Text listing the |BIOGRAPHY_DATA|.\ |BIOGRAPHY_DATA.AnimID|\ s of the + individuals that were seen to kill a monkey. + +|COLOBUS.Killers_summary| + +|notonlyspaces| +|notnull| + + +.. _COLOBUS.NumKills: + +NumKills +```````` + +.. |COLOBUS.NumKills_summary| replace:: + The total number of colobus killed. + +|COLOBUS.NumKills_summary| +|notnull| + + +.. _COLOBUS.MaleNumKills: + +MaleNumKills +```````````` + +.. |COLOBUS.MaleNumKills_summary| replace:: + The total number of colobus killed by males. + +|COLOBUS.MaleNumKills_summary| +|notnull| + + +.. _COLOBUS.FocalMaleNumKills: + +FocalMaleNumKills +````````````````` + +.. |COLOBUS.FocalMaleNumKills_summary| replace:: + The total number of colobus killed by the focal male. + +|COLOBUS.FocalMaleNumKills_summary| + +This column may be |null| when there is no information. + + +.. _COLOBUS.FocalFemaleNumKills: + +FocalFemaleNumKills +``````````````````` + +.. |COLOBUS.FocalFemaleNumKills_summary| replace:: + The total number of colobus killed by the focal female. + +|COLOBUS.FocalFemaleNumKills_summary| + +This column may be |null| when there is no information. + + +.. _COLOBUS.VictimsAges: + +VictimsAges +``````````` + +.. |COLOBUS.VictimsAges_summary| replace:: + Text recording the age of each colobus killed, if known. + +|COLOBUS.VictimsAges_summary| +|notonlyspaces| +|notnull| + + +.. _COLOBUS.InfantsKilled: + +InfantsKilled (by males) +```````````````````````` + +.. |COLOBUS.InfantsKilled_summary| replace:: + The number of colobus infants killed **by** **males**. + +|COLOBUS.InfantsKilled_summary| +|notnull| + + +.. _COLOBUS.JuvenilesKilled: + +JuvenilesKilled (by males) +`````````````````````````` + +.. |COLOBUS.JuvenilesKilled_summary| replace:: + The number of colobus juveniles killed **by** **males**. + +|COLOBUS.JuvenilesKilled_summary| +|notnull| + + +.. _COLOBUS.AdultsKilled: + +AdultsKilled (by males) +``````````````````````` + +.. |COLOBUS.AdultsKilled_summary| replace:: + The number of colobus adults killed **by** **males**. + +|COLOBUS.AdultsKilled_summary| +|notnull| + + +.. _COLOBUS.NoAgeKilled: + +NoAgeKilled (by males) +`````````````````````` + +.. |COLOBUS.NoAgeKilled_summary| replace:: + The number of colobus for which there was no age data killed **by** + **males**. + +|COLOBUS.NoAgeKilled_summary| +|notnull| + + +.. _COLOBUS.GroupSize: + +GroupSize +````````` + +.. |COLOBUS.GroupSize_summary| replace:: + A code indicating the size of the colobus group. + A |COLOBUS_GROUP_SIZES|.\ |COLOBUS_GROUP_SIZES.Size| value. + +|COLOBUS.GroupSize_summary| +|notnull| + + +.. _COLOBUS.Details: + +Details (colobus troop DETAILS) +``````````````````````````````` + +.. |COLOBUS.Details_summary| replace:: + Specific information regarding the colobus troop. + +|COLOBUS.Details_summary| +|notonlyspaces| +|notnull| + + +.. _COLOBUS.Vegetation: + +Vegetation (details of the area's VEGETATION) +````````````````````````````````````````````` + +.. |COLOBUS.Vegetation_summary| replace:: + Text consisting of specific information regarding the vegetation + type in which the encounter occurred. + +|COLOBUS.Vegetation_summary| +|notonlyspaces| +|notnull| + + +.. _COLOBUS.FailureDetails: + +FailureDetails (hunt FAILURE DETAILS) +````````````````````````````````````` + +.. |COLOBUS.FailureDetails_summary| replace:: + Text consisting of specific information regarding why the hunt failed. + +|COLOBUS.FailureDetails_summary| +|notonlyspaces| +|notnull| + + +.. _COLOBUS.Description: + +Description +``````````` + +.. |COLOBUS.Description_summary| replace:: + Description of hunt, if it occurred, usually copied directly from the + translation. + +|COLOBUS.Description_summary| +|notonlyspaces| +|notnull| + + +.. rubric:: Footnotes + +.. [#f1] + + A way to round, to the nearest 15 minute interval, is to use an + expression like:: + + ``DATE_BIN('15 minutes' + , '1960-07-04'::DATE + events.start + '8 minutes'::INTERVAL + , '1960-07-04 00:00')::TIME WITHOUT TIME ZONE`` + + This expression rounds down when the start time is after the 15 + minute interval by 7 minutes or less, and otherwise rounds up. + (The date ``1960-07-04`` is an arbitrary choice. + It does not affect the result.) + + Should this be useful it can be made into a :ref:`function + `. diff --git a/doc/src/tables/events.m4 b/doc/src/tables/events.m4 index f5aea66..9c36c2e 100644 --- a/doc/src/tables/events.m4 +++ b/doc/src/tables/events.m4 @@ -266,6 +266,38 @@ The following table lists these rules and implications: is not the empty string. +.. _EVENTS_colobus_code: + +``sdb_colobus`` (COLOBUS monkey hunt data) + There is one row for each record of colobus monkey hunting. + + The EVENTS row must be associated with a follow. + This means the |EVENTS.WID| column must reference a |WATCHES| row + with a |WATCHES|.\ |WATCHES.Type| value of ``sdb_follow``. + + A related row should exist on |COLOBUS|; there should be a row on + |COLOBUS| with an |COLOBUS|.\ |COLOBUS.EID| value of the + event's |EVENTS.EID|. + There may be at most one of these related |COLOBUS| rows. + The system will generate a warning when there is no |COLOBUS| row + related to the colobus hunt. + + There can be no |ROLES| rows related to the event. + + The EVENTS.\ |EVENTS.Start| column contains the time the colobus + monkey hunting encounter began. + + The EVENTS.\ |EVENTS.Stop| column contains the time the colobus + monkey hunting encounter ended. + If a kill was made, this is the time that the first kill was made. + + For colobus monkey hunting events, the EVENTS.\ |EVENTS.Certainty| + column must be ``sdb_identity_certain``. + + For colobus monkey hunting events, the EVENTS.\ |EVENTS.Notes| + column contains comments and/or a description of the encounter. + + .. _EVENTS_food_code: ``sdb_food`` (Food) diff --git a/include/global_constants.m4 b/include/global_constants.m4 index 263acf9..55546dd 100644 --- a/include/global_constants.m4 +++ b/include/global_constants.m4 @@ -123,6 +123,8 @@ dnl The arrival event define(`sdb_arrival', `ARR') dnl B-Record note taking define(`sdb_brec_note', `BREC') +dnl Colobus hunts +define(`sdb_colobus', `COL') dnl The food/eating event define(`sdb_food', `FOOD') dnl The recording of a GPS location -- 2.34.1