One-to-one

Also known as: one-to-one relationship

On this page 7

A one-to-one relationship is a link between two entities in which each instance of the first entity corresponds to at most one instance of the second, and each instance of the second corresponds to at most one instance of the first. In data modeling, one-to-one is one of the three basic cardinality types, alongside one-to-many and many-to-many.

Typical examples include a person and a passport record, an employee and a company laptop assignment, or a customer account and its single billing profile. In relational databases, a one-to-one relationship is enforced with a foreign key that is also unique, and it is often used to split a table for reasons of security, performance or optional data.

How a one-to-one relationship is implemented

A one-to-one relationship is implemented by placing a foreign key in one table and declaring it unique, so no two rows can reference the same parent. Without the uniqueness constraint, the same structure would silently allow one-to-many data, which is the most frequent modeling error with this cardinality.

The cleanest pattern is the shared primary key: the dependent table uses the parent’s primary key as its own primary key and as a foreign key at the same time. For example, employee_badge.employee_id is both the primary key of the badge table and a reference to employee.employee_id. This guarantees uniqueness without an extra index and makes joins straightforward.

The following table compares the main physical implementation options and what each one guarantees.

PatternStructureGuaranteeTypical use
Shared primary keyChild primary key is also the foreign keyStrict one-to-oneTable splitting, subtypes
Unique foreign keySeparate key plus unique foreign key columnAt most one child per parentIndependent identities
Single combined tableAll attributes in one tableTrivially one-to-oneMandatory, small attributes
Nullable unique columnOptional foreign key on the parent sideZero or one linkOptional associations
Implementation patterns for one-to-one relationships

Optionality and cardinality notation

A one-to-one relationship has two independent properties: the maximum cardinality, which is one on both sides, and the minimum cardinality, which states whether a link is mandatory. Strictly mandatory on both sides is rare in practice; most real relationships are one-to-zero-or-one, written 1:0..1.

In an ER diagram drawn with Crow’s foot notation, a one-to-one relationship shows a single bar on each end for exactly one, or a circle and bar for zero or one. UML class diagrams express the same idea with multiplicities such as 1 and 0..1.

VariantNotationMeaningExample
Mandatory on both sides1 : 1Neither row exists without the otherOrder and its single invoice header
Optional on one side1 : 0..1Parent may lack a childUser and optional profile photo
Optional on both sides0..1 : 0..1Either row may exist aloneParking spot and assigned car
Optionality variants of one-to-one

A mandatory-on-both-sides rule is hard to enforce in SQL, because one row must be inserted before the other. Engines that support deferred constraints, such as PostgreSQL and Oracle, can check both foreign keys at commit time; elsewhere the rule is usually enforced in application logic.

One-to-one compared with other cardinalities

One-to-one is the most restrictive cardinality and the least common in normalized schemas. One-to-many is the workhorse of relational design, and many-to-many requires a junction table. Recognizing which one applies depends on the business rule, not on current data.

CardinalityRuleRelational implementationExample
One-to-oneEach side has at most one partnerUnique foreign key or shared keyPerson and national ID record
One-to-manyOne parent, several childrenPlain foreign key on the childCustomer and orders
Many-to-manySeveral partners on both sidesJunction table with two foreign keysStudents and courses
Comparison of relationship cardinalities

A frequent trap is modeling a relationship as one-to-one because today’s data happens to show one partner. If a customer could ever have two billing addresses, the correct model is one-to-many, and a later change becomes a costly migration.

When to use a separate one-to-one table

Because a one-to-one relationship could always be merged into a single table, a separate table needs a concrete justification. Normalization alone does not require the split, since attributes that depend only on the same key belong together in third normal form.

  • Security isolation: sensitive columns such as salary or medical data sit in a table with stricter permissions.
  • Vertical partitioning: rarely read or very large columns move out so the main table stays narrow and cache-friendly.
  • Optional data: attributes present for a small share of rows avoid many null columns.
  • Subtype modeling: a supertype such as party links one-to-one to subtypes such as person or organization.
  • Different lifecycles: data owned by another team or system is updated, archived or replicated separately.

The split has costs. Every query that needs both sides requires a join, insert logic becomes two statements, and the uniqueness constraint must be maintained. For small, always-present attributes, a single table is usually the better design.

Common modeling errors

Most problems with one-to-one relationships come from missing constraints or misread business rules. The following table lists typical symptoms and their fixes.

MistakeConsequenceFix
Foreign key without unique constraintDuplicate children appear silentlyAdd a unique constraint or shared key
Foreign keys on both tablesCircular dependency and inconsistent linksKeep the key on the dependent side only
Split without a reasonExtra joins and slower writesMerge into one table
Assumed one-to-one from sample dataSchema breaks when a second partner appearsConfirm the rule with domain experts
Mistakes in one-to-one modeling

Understanding it simply

A one-to-one relationship is like a house and its street address. Each house has exactly one address, and each address points to exactly one house. You never find two houses sharing the same number, and one house never has two official addresses.

Databases sometimes keep such matching information in two separate lists, for example to lock away private details. The key takeaway is that each entry in one list may match only one entry in the other, and the database is told to enforce that rule.

Applied in practice

A hospital system stores about 2 million patient records in a patient table used by scheduling, billing and reception staff. Clinical identifiers such as genetic test results and psychiatric flags must be visible only to authorized clinicians. The data architects create a patient_sensitive table whose primary key is also a foreign key to `patient.patient_id`, giving a strict one-to-zero-or-one relationship.

Database roles grant reception staff access to patient only, while clinicians receive both tables. Because only about 15% of patients have sensitive entries, the separate table also avoids millions of null values.

The result is simpler access auditing and a narrower main table: routine scheduling queries read fewer pages, and a security review confirmed that no general-purpose report could expose the protected columns.