1 <-> 0..1 relationship
From: Victor Porton <porton_at_narod.ru>
Date: Tue, 13 Dec 2011 06:40:48 -0800 (PST)
Message-ID: <7404547f-a354-4fe0-96fc-69e9697ea155_at_z12g2000yqm.googlegroups.com>
I have "1 <-> 0..1 relationship". For example:
Date: Tue, 13 Dec 2011 06:40:48 -0800 (PST)
Message-ID: <7404547f-a354-4fe0-96fc-69e9697ea155_at_z12g2000yqm.googlegroups.com>
I have "1 <-> 0..1 relationship". For example:
There is a set of users. Some users are customers.
Thus we have two tables: the table `users` and the table `customers`.
What is the best way to express this in a relational database:
- In the table `users` add the `customer` field which may be either a ref to `users` or NULL.
- In the table `customers` add UNIQUE `user` field which refers to `users` table.
I have already asked a similar question in some forums, but the answer was basically "whatever you need", "whatever you think convenient". I don't like this kind of answer. I want a serious piece of DB theory
instead, a well founded answer. Where to read about 1 <-> 0..1 relationships? Received on Tue Dec 13 2011 - 15:40:48 CET