Consider the following design:
LEGAL_CASE table (columns)
--------------------------------
LEGAL_CASE_ID
APPELLATE_CRT_ID
DISTRICT_CRT_ID
TRIAL_CRT_ID
with all courts being defined in a lookup table
COURT table (data)
--------------------------------------------
CRT_ID CRT_TYPE CRT_NAME
--------------------------------------------
1 A APPELLATE COURT 1
2 A APPELLATE COURT 2
3 D DISTRICT COURT 1
4 D DISTRICT COURT 2
5 T TRIAL COURT 1
6 T TRIAL COURT 2
The standard way of doing it, I suppose, would be to have a separate lookup table for each court type but I prefer dumping them all in a single one under different codes, for compactness and elegance. So then I would like to have some form of referential integrity constraint (if the above rules out FK) that will enforce that all it can go into APPELLATE_CRT_ID are the CRT_ID values from the COURT table but only where CRT_TYPE = 'A' etc. A regular FK would allow Ds and Ts as well but I would like to make it more restrictive.
Is there a way to formulate a FK that would restrict a range of values in the primary key table or should I just go with a RULE
or another type of CONSTRAINT
?