From 488fcdf0eacd52afba5ed6efab0931537fab2f8e Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Fri, 5 Jun 2026 18:45:20 +0000 Subject: [PATCH] Remove FOOD_EVENTS.FEID and use EID as the primary key --- db/schemas/lib/triggers/create/food_events.m4 | 33 ++++++++----------- .../sokwedb/tables/create/food_events.m4 | 3 +- doc/diagrams/events.svg | 26 +++------------ doc/src/epilog.inc.m4 | 2 -- doc/src/tables/food_events.m4 | 10 ------ 5 files changed, 19 insertions(+), 55 deletions(-) diff --git a/db/schemas/lib/triggers/create/food_events.m4 b/db/schemas/lib/triggers/create/food_events.m4 index 918842e..6b38dfe 100644 --- a/db/schemas/lib/triggers/create/food_events.m4 +++ b/db/schemas/lib/triggers/create/food_events.m4 @@ -36,12 +36,11 @@ CREATE OR REPLACE FUNCTION food_events_func () `The Meme Factory, Inc., www.karlpinc.com') IF TG_OP = 'UPDATE' THEN - cannot_change(`FOOD_EVENTS', `FEID') + cannot_change(`FOOD_EVENTS', `EID') END IF; -- The EVENTS.Behavior must be sdb_food - 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 food_events_func () MESSAGE = 'Error on ' || TG_OP || ' of FOOD_EVENTS' , DETAIL = 'Food events can only be related to an event with an' || ' EVENTS.Behavior value of (sdb_food)' - || ': Key (FEID = (' - || NEW.feid + || ': Key (EID = (' + || NEW.eid || '): Value (FoodPart) = (' || NEW.foodpart || '): Value (FoodName) = (' @@ -122,7 +121,6 @@ CREATE OR REPLACE FUNCTION food_events_commit_func () sdb_function_set_search_path AS $$ DECLARE - a_feid food_events.feid%TYPE; a_foodpart food_events.foodpart%TYPE; a_foodname food_events.foodname%TYPE; a_seq food_events.seq%TYPE; @@ -137,9 +135,9 @@ CREATE OR REPLACE FUNCTION food_events_commit_func () IF TG_OP = 'INSERT' OR NEW.seq <> OLD.seq THEN - SELECT food_events.feid, food_events.foodpart, food_events.foodname + SELECT food_events.foodpart, food_events.foodname , food_events.seq - INTO a_feid , a_foodpart , a_foodname + INTO a_foodpart , a_foodname , a_seq FROM food_events WHERE food_events.eid = NEW.eid @@ -150,7 +148,7 @@ CREATE OR REPLACE FUNCTION food_events_commit_func () WHERE previous.eid = NEW.eid AND previous.seq = food_events.seq - 1) -- Produce a consistent error message - ORDER BY food_events.seq, food_events.feid; + ORDER BY food_events.seq, food_events.eid; IF FOUND THEN DECLARE @@ -189,8 +187,8 @@ CREATE OR REPLACE FUNCTION food_events_commit_func () || ' with a Seq of (' || a_seq - 1 || ') to pair with the following FOOD_EVENTS row:' - || ' Key (FEID = (' - || a_feid + || ' Key (EID = (' + || NEW.eid || '): Value (FoodPart) = (' || a_foodpart || '): Value (FoodName) = (' @@ -234,7 +232,6 @@ CREATE OR REPLACE FUNCTION food_events_delete_commit_func () sdb_function_set_search_path AS $$ DECLARE - a_feid food_events.feid%TYPE; a_foodpart food_events.foodpart%TYPE; a_foodname food_events.foodname%TYPE; a_seq food_events.seq%TYPE; @@ -246,10 +243,8 @@ CREATE OR REPLACE FUNCTION food_events_delete_commit_func () `The Meme Factory, Inc., www.karlpinc.com') -- The Seq can't have gaps - SELECT food_events.feid, food_events.foodpart, food_events.foodname - , food_events.seq - INTO a_feid , a_foodpart , a_foodname - , a_seq + SELECT food_events.foodpart, food_events.foodname, food_events.seq + INTO a_foodpart , a_foodname , a_seq FROM food_events WHERE food_events.eid = OLD.eid AND food_events.seq = OLD.seq + 1 @@ -259,7 +254,7 @@ CREATE OR REPLACE FUNCTION food_events_delete_commit_func () WHERE this_slot.eid = OLD.eid AND this_slot.seq = OLD.seq) -- Produce a consistent error message - ORDER BY food_events.feid; + ORDER BY food_events.eid; IF FOUND THEN DECLARE @@ -298,8 +293,8 @@ CREATE OR REPLACE FUNCTION food_events_delete_commit_func () || ' with a Seq of (' || a_seq - 1 || ') to pair with the following FOOD_EVENTS row:' - || ' Key (FEID = (' - || a_feid + || ' Key (EID = (' + || OLD.eid || '): Value (FoodPart) = (' || a_foodpart || '): Value (FoodName) = (' diff --git a/db/schemas/sokwedb/tables/create/food_events.m4 b/db/schemas/sokwedb/tables/create/food_events.m4 index 1492726..ccaed2f 100644 --- a/db/schemas/sokwedb/tables/create/food_events.m4 +++ b/db/schemas/sokwedb/tables/create/food_events.m4 @@ -24,8 +24,7 @@ include(`grants.m4')dnl dnl CREATE TABLE food_events ( - key_column(`FOOD_EVENTS', `FEID', INTEGER) - ,eid INTEGER NOT NULL + eid INTEGER PRIMARY KEY NOT NULL REFERENCES events ,foodpart TEXT NOT NULL CONSTRAINT "FoodPart must be a FOOD_PARTS.Part" diff --git a/doc/diagrams/events.svg b/doc/diagrams/events.svg index 68aaadb..0917590 100644 --- a/doc/diagrams/events.svg +++ b/doc/diagrams/events.svg @@ -822,7 +822,7 @@ inkscape:pageshadow="2" inkscape:zoom="3.6096384" inkscape:cx="242.68359" - inkscape:cy="327.04107" + inkscape:cy="570.8328" inkscape:document-units="mm" inkscape:current-layer="layer3" inkscape:document-rotation="0" @@ -2814,13 +2814,13 @@ 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.634758" - y="171.36386" + y="175.06039" id="text2064-5-2" transform="scale(0.99793288,1.0020714)">FOOD_EVENTS - FEID - + y="172.74182" /> ` .. |FOOD_EVENTS| replace:: :ref:`FOOD_EVENTS ` -.. |FOOD_EVENTS.FEID| replace:: - :ref:`FEID ` .. |FOOD_EVENTS.EID| replace:: :ref:`EID ` .. |FOOD_EVENTS.FoodPart| replace:: diff --git a/doc/src/tables/food_events.m4 b/doc/src/tables/food_events.m4 index 5e0b81b..ef36240 100644 --- a/doc/src/tables/food_events.m4 +++ b/doc/src/tables/food_events.m4 @@ -75,16 +75,6 @@ table. :depth: 2 -.. _FOOD_EVENTS.FEID: - -FEID (Food Event IDentifier) -```````````````````````````` - -.. |FOOD_EVENTS.FEID_summary| replace:: |idcol| - -|FOOD_EVENTS.FEID_summary| |notnull| - - .. _FOOD_EVENTS.EID: EID (Event ID) -- 2.34.1