Check attribute table referenced foreign key I have two tables a and b like this:

a: id, type
b: a_id, ...


There is a limitation for which the references of a in b can only be those which have type equal to a limited set of values.

Is it possible to include a CHECK for an attribute of the referenced table or do you have a better design idea?
It's possible to add a_type to b, and have check constraint on b.a_type.  Breaking normalization a bit allows enforcing storing details in proper table . In Oracle you can have 2 constrains supported by the same index, for instance PK on a.id, and UNIQUE on (a.id,a.type) , then some tables that require proper type may have FK to (a.id,a.type), and other tables that don't care about type can refer to a.id .