Files
vpd-permission-poc/database/adb/78_sgmp_game_alias_logical_joins.sql
2026-08-03 12:31:47 +09:00

37 lines
2.0 KiB
SQL

-- Logical game-alias join guidance for Select AI.
--
-- COMN_GAME_ALIAS_BAS intentionally has multiple alias rows per GAME_ID, so
-- GAME_ID cannot be modelled as a physical foreign key to that table. These
-- annotations describe the safe semantic relationship without asserting a
-- false database constraint or creating fan-out aggregation errors.
DECLARE v_result VARCHAR2(4000); BEGIN
v_result := sgmp_set_annotation(
'SGMP_POC', 'TABLE', 'COMN_SALES_TXN', NULL,
'Logical game filter: COMN_SALES_TXN.GAME_ID is resolved through COMN_GAME_ALIAS_BAS. GAME_ID is not unique in the alias table because one game can have multiple aliases. For a game-name filter, use EXISTS against active aliases or join a DISTINCT GAME_ID alias subquery. Do not directly join all alias rows before SUM or COUNT because that can multiply fact rows.',
'GAME_ALIAS_JOIN'
);
dbms_output.put_line(v_result);
END;
/
DECLARE v_result VARCHAR2(4000); BEGIN
v_result := sgmp_set_annotation(
'SGMP_POC', 'TABLE', 'COMN_REFUND_TXN', NULL,
'Logical game filter: COMN_REFUND_TXN.GAME_ID is resolved through COMN_GAME_ALIAS_BAS. GAME_ID is not unique in the alias table because one game can have multiple aliases. For a game-name filter, use EXISTS against active aliases or join a DISTINCT GAME_ID alias subquery. Do not directly join all alias rows before SUM or COUNT because that can multiply fact rows.',
'GAME_ALIAS_JOIN'
);
dbms_output.put_line(v_result);
END;
/
DECLARE v_result VARCHAR2(4000); BEGIN
v_result := sgmp_set_annotation(
'SGMP_POC', 'TABLE', 'COMN_SALES_PRODUCT_DISP_BAS', NULL,
'Logical product scope: COMN_SALES_PRODUCT_DISP_BAS is keyed by GAME_ID and PRODUCT_ID. Resolve a natural-language game through COMN_GAME_ALIAS_BAS using EXISTS or a DISTINCT GAME_ID alias subquery before joining product data to transaction facts. The alias table has multiple aliases per GAME_ID and is not a physical foreign-key parent.',
'GAME_ALIAS_JOIN'
);
dbms_output.put_line(v_result);
END;
/