Let us say that I am designing a database for a scenario where there exists a one-to-zero-or-one (1-0..1) relationship. For example:
- There is a set of Users, and some Users may also be Customers.
Thus, I created the two corresponding tables, users
and customers
, but…
…What is the best way to represent and implement this situation in a given SQL platform? I have considered two possible solutions:
In the
users
table, add thecustomer
column which may be either a FOREIGN KEY reference tocustomers
or aNULL
mark.In the
customers
table, include auser
column (set with aUNIQUE
constraint) which points to theusers
table.
I have already asked a similar question in some forums, but the answer was basically “whatever you need”, “whatever you think convenient”. I do not like this kind of answer. I want a serious piece of DB theory instead, a well founded answer. Where can I read about 1-0..1 relationships?