Mandatory Relations
Mandatory relationships are the general rule in database design. Mandatory relationships occur when the foreign key column or set of columns are also not null constrained.
A foreign key constraint only guarantees that the value in the column will be a value found in a list values in another column. A foreign key constrained column also can hold a null value unless you also make the foreign key column a not null constrained column.
This ERD shows you the relationships between four tables:
If you follow the logic of the Entity Relationship Diagram (ERD), the columns with a filled red diamond are mandatory relations. The model depicts the mandatory relations qualified in the bullet points:
- The
member
table:- A
credit_card_type
column value must be found in the valid list of thecommon_lookup
table’s primary key column and must be not null constrained. - A
member_type
column value must be found in the valid list of thecommon_lookup
table’s primary key, but the column initially accepts a null value because it isn’t constrained by aNOT NULL
constraint.
- A
- The
contact
table:- A
member_id
column value must be found in the valid list of themember
table’s primary keymember_id
column; and themember_id
column also must be constrained by a not null constraint.
- A
- The
address
table:- A
contact_id
column value must be found in the valid list of thecontact
table’s primary keycontact_id
column; and thecontact_id
column also must be constrained by a not null constraint.
- A
- The
telephone
table:- A
contact_id
column value must be found in the valid list of thecontact
table’s primary keycontact_id
column; and thecontact_id
column also must be constrained by a not null constraint. - A
address_id
column value must be found in the valid list of theaddress
table’s primary keyaddress_id
column; and theaddress_id
column is unconstrained or null allowed.
- A
You should notice that most of the foreign key columns are red, which means they are not null constrained. That’s the general pattern when a row can’t exist in a dependent table without a mandatory relationship to the table holding the primary key value.