I have some related tables:
Application - stores a list of applications
ApplicationInstall - for each application, multiple installations are present (I have a foreign key
SecurityPrincipal - for each
ApplicationInstall I have many principals (I have a foreign key
I have also a table
SecurityPrincipalType, linked to
Application through a 1-to-many.
I would like to have a rule that guarantees that when I insert a record in
SecurityPrincipal its Type comes from a
SecurityPrincipalType linked to the correct
I didn't rename the tables because I usually prefer to have names to think about. But I think the following scenario is equivalent:
Table A n..1
Table B 1..n
And I want to enforce that a column in
C contains only values coming from
A, but linked via
- foreign keys?
- application level checks (but I would prefer to have some check at the db level)
What should I do?