From fa5e539658375557c2cd8daa7c876f513587811d Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Fri, 5 Jun 2026 17:55:49 +0000 Subject: [PATCH] Remove AGGRESSIONS.AgID and use EID as the primary key --- db/schemas/lib/triggers/create/aggressions.m4 | 9 +++--- .../sokwedb/indexes/create/aggressions.m4 | 5 ---- .../sokwedb/indexes/drop/aggressions.m4 | 3 -- .../sokwedb/tables/create/aggressions.m4 | 5 ++-- doc/diagrams/events.svg | 28 ++++--------------- doc/src/epilog.inc.m4 | 2 -- doc/src/tables/aggressions.m4 | 11 +------- 7 files changed, 13 insertions(+), 50 deletions(-) diff --git a/db/schemas/lib/triggers/create/aggressions.m4 b/db/schemas/lib/triggers/create/aggressions.m4 index 18a8139..f65a674 100644 --- a/db/schemas/lib/triggers/create/aggressions.m4 +++ b/db/schemas/lib/triggers/create/aggressions.m4 @@ -36,12 +36,11 @@ CREATE OR REPLACE FUNCTION aggressions_func () `The Meme Factory, Inc., www.karlpinc.com') IF TG_OP = 'UPDATE' THEN - cannot_change(`AGGRESSIONS', `AgID') + cannot_change(`AGGRESSIONS', `EID') END IF; -- The EVENTS.Behavior must be sdb_aggression - IF TG_OP = 'INSERT' - OR NEW.EID <> OLD.EID THEN + IF TG_OP = 'INSERT' THEN DECLARE -- EVENTS a_behavior events.behavior%TYPE; @@ -73,8 +72,8 @@ CREATE OR REPLACE FUNCTION aggressions_func () MESSAGE = 'Error on ' || TG_OP || ' of AGGRESSIONS' , DETAIL = 'Aggressions can only be related to an event with an' || ' EVENTS.Behavior value of (sdb_aggression)' - || ': Key (AgID = (' - || NEW.agid + || ': Key (EID = (' + || NEW.eid || '): Value (Decided) = (' || NEW.Decided || '): Value (MultiAggressors) = (' diff --git a/db/schemas/sokwedb/indexes/create/aggressions.m4 b/db/schemas/sokwedb/indexes/create/aggressions.m4 index 06c488f..14bec3f 100644 --- a/db/schemas/sokwedb/indexes/create/aggressions.m4 +++ b/db/schemas/sokwedb/indexes/create/aggressions.m4 @@ -21,11 +21,6 @@ include(`copyright.m4')dnl include(`constants.m4')dnl include(`indexmacros.m4')dnl -CREATE UNIQUE INDEX IF NOT EXISTS - "AGGRESSIONS has, at most, a 1-to-1 relationship with EVENTS" - ON aggressions - (eid); - CREATE INDEX IF NOT EXISTS aggressions_commid ON aggressions (commid); -- There seems little point in indexing: diff --git a/db/schemas/sokwedb/indexes/drop/aggressions.m4 b/db/schemas/sokwedb/indexes/drop/aggressions.m4 index c0fe2c6..a65f942 100644 --- a/db/schemas/sokwedb/indexes/drop/aggressions.m4 +++ b/db/schemas/sokwedb/indexes/drop/aggressions.m4 @@ -21,7 +21,4 @@ include(`copyright.m4')dnl include(`constants.m4')dnl include(`indexmacros.m4')dnl -DROP INDEX IF EXISTS - "AGGRESSIONS has, at most, a 1-to-1 relationship with EVENTS"; - DROP INDEX IF EXISTS aggressions_commid; diff --git a/db/schemas/sokwedb/tables/create/aggressions.m4 b/db/schemas/sokwedb/tables/create/aggressions.m4 index 93ff361..c3fdcf9 100644 --- a/db/schemas/sokwedb/tables/create/aggressions.m4 +++ b/db/schemas/sokwedb/tables/create/aggressions.m4 @@ -24,8 +24,7 @@ include(`grants.m4')dnl dnl CREATE TABLE aggressions ( - key_column(`AGGRESSIONS', `AgID', INTEGER) - ,eid INTEGER NOT NULL + eid INTEGER NOT NULL REFERENCES events ,decided BOOLEAN NOT NULL ,multiaggressors BOOLEAN NOT NULL @@ -52,4 +51,6 @@ CREATE TABLE aggressions ( REFERENCES people ); +eid_primary_key(`AGGRESSIONS') + grant_priv(`AGGRESSIONS') diff --git a/doc/diagrams/events.svg b/doc/diagrams/events.svg index ea05465..68aaadb 100644 --- a/doc/diagrams/events.svg +++ b/doc/diagrams/events.svg @@ -821,8 +821,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="3.6096384" - inkscape:cx="244.89988" - inkscape:cy="570.8328" + inkscape:cx="242.68359" + inkscape:cy="327.04107" inkscape:document-units="mm" inkscape:current-layer="layer3" inkscape:document-rotation="0" @@ -2232,36 +2232,18 @@ xml:space="preserve" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.81672px;line-height:125%;font-family:Sans;-inkscape-font-specification:'Sans, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264067px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" x="29.4939" - y="67.4832" + y="71.179733" id="text2064-5-6" - transform="scale(0.99793287,1.0020714)">AGGRESSIONS - AgID - diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index 34cc9f1..7f4e034 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -87,8 +87,6 @@ sdb_generated_rst()dnl .. |AGGRESSIONS| replace:: :ref:`AGGRESSIONS ` -.. |AGGRESSIONS.AgID| - replace:: :ref:`AgID ` .. |AGGRESSIONS.EID| replace:: :ref:`EID ` .. |AGGRESSIONS.Decided| diff --git a/doc/src/tables/aggressions.m4 b/doc/src/tables/aggressions.m4 index 0c22ca0..fc8cbf1 100644 --- a/doc/src/tables/aggressions.m4 +++ b/doc/src/tables/aggressions.m4 @@ -78,16 +78,6 @@ table. :depth: 2 -.. _AGGRESSIONS.AgID: - -AgID (Aggression ID) -```````````````````` - -.. |AGGRESSIONS.AgID_summary| replace:: |idcol| - -|AGGRESSIONS.AgID_summary| |notnull| - - .. _AGGRESSIONS.EID: EID (Event ID) @@ -95,6 +85,7 @@ EID (Event ID) .. |AGGRESSIONS.EID_summary| replace:: The |EVENTS|.\ |EVENTS.EID| identifying the aggression event. + |idcol| |AGGRESSIONS.EID_summary| The related event contains information on the time of the aggression -- 2.34.1