Can FK be nullable/optional by design?
Date: 30 Nov 2003 11:14:52 -0800
Message-ID: <edb90340.0311301114.19718061_at_posting.google.com>
Hi All!
General statement: FK should not be nullabe to avoid orphans in DB.
Real life:
Business rule says that not every record will have a parent. It is
It works, and it is simpler.
Example: There are clients. A client might belong to only one group.
Case A.
The design that satisfy business rule and FK not null can be
implemented but it will be more complicated.
Group(GroupID PK, Name,Code…)
Client(ClientID PK, Name, GroupID FK NULL)
Case B(more cleaner)
Group(GroupID PK, Name, GroupCode…)
Client (ClientID PK, Name, ….)
There is one more entity in Case B and it will require an additional
join in compare with caseA
Subtype:
GroupedClient (PersonID PK/FK, GroupID FK NOT NULL)
Example: Select all clients that belongs to any group
Summary Q: Is it worth to go with CaseB?
Thank you in advance Received on Sun Nov 30 2003 - 20:14:52 CET