I have 2 tables,Table 1 & 2. Table 1 contains a List of Values ( LOV ) referencing in list Table2 2. Question surround maintaining data integrity.
Example
Table1
ROW_ID NVARCHAR2, 10
Affected_LOV NVARHAR2, 20
Example data
1,1:2:3
2,1:3
Table2
ROW_ID NVARCHAR2, 10
Affected_Desc NVARCHAR2, 20
Example data
1,Affected 1
2,Affected 2
3,Affected 3
Actions
For Table 1
Modify LOV from 1:2:3 to 1:3
Actions
Revised row Table 1
1,1:3
Check data integrity of Table 2, As Row 2 is no longer referenced, delete
2,Affected 2
For Table 2, Try to delete Row 1. As Row 1 is referenced in LOV in table 1 in Rows 1 & 2, deny delete as a foreign key constraint
If the above makes sense, is it best implemented in apex code or data model ?