We show how to model a customer
type with two mutually exclusive subtypes: person
and company
.
We want to express the following data integrity constraints:
- A
customer
cannot simultaneously be bothperson
andcompany
. - A
customer
is always also aperson
or acompany
. - Any
Person
and anycompany
must also be acustomer
.
We set up a conspiracy of primary keys, foreign keys, check constraints and uniqueness constraints, pulling together to achieve this goal.