I have a doubt in my data model in the Movements table, in that table I have an AffectedId field, which is going to relate to Sales, Purchases, Promotions, Prizes, Donations, Warehousing, etc.
In the Table TypeOperacion is where these operations that I just mentioned will go.
How can I control the referential integrity of AffectedId that is in Movements ?, would there be another modeling solution for this case?
This modeling could be another option.
In the table Operaciones
register the ID afectado
in which I indicate the type of operation, by TipoOpearacionId
and it would not be made with Compras
, Ventas
, Promocion
, etc. The referential integrity could be controlled by a Triggers.