liveBook · Manning

One-to-one relationship

As explained in Grokking Relational Database Design

A one-to-one relationship is a relationship in which each entity instance is associated with at most one instance of the other entity in both directions.

A one-to-one relationship connects each record in one entity to at most one record in the other entity, in both directions. Its maximum cardinality is one on both sides; each minimum cardinality may be zero or one. section 5.6

Use these practical rules when modeling the relationship:

  • Represent the relationship with two bars in a Crow’s Foot E-R diagram. section 5.10
  • Place the connecting foreign key on either side when both maximum cardinalities are one. section 5.10
  • If both minimum cardinalities are one, change one to zero when necessary so the tables can be populated. section 5.6

Departments and managers

Suppose every department has exactly one manager and every manager works for exactly one department. Putting foreign keys in both tables makes initial insertion impossible: entering either record first violates the other table’s foreign-key constraint. A workable design changes the rule to “a department has zero or one manager” while keeping “a manager works for one and only one department.” section 5.6

Use the E-R diagram to inspect how the department-manager relationship and its cardinalities are represented. section 5.6

How Grokking Relational Database Design covers it

How deep it goes
Explains maximum and minimum cardinalities, notation, foreign-key placement, and insertion constraints.
Examples
Uses department-manager and dealer-address relationships to illustrate one-to-one associations.
What it assumes
Assumes entity relationships and requirements gathering while establishing cardinality and foreign-key concepts through examples.
What you can do after
Apply it to choose cardinalities, place a foreign key, and adjust optionality for workable data entry.
How it connects
Connects cardinality, E-R diagrams, foreign keys, and weak entities with one-to-many and many-to-many relationships.

Also explained in

Compare how 3 books explain one-to-one relationship →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Relational Database Design. The section links point to the parts of the book it draws on.