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.
| Pattern | Structure | Guarantee | Typical use |
|---|---|---|---|
| Shared primary key | Child primary key is also the foreign key | Strict one-to-one | Table splitting, subtypes |
| Unique foreign key | Separate key plus unique foreign key column | At most one child per parent | Independent identities |
| Single combined table | All attributes in one table | Trivially one-to-one | Mandatory, small attributes |
| Nullable unique column | Optional foreign key on the parent side | Zero or one link | Optional associations |
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.
| Variant | Notation | Meaning | Example |
|---|---|---|---|
| Mandatory on both sides | 1 : 1 | Neither row exists without the other | Order and its single invoice header |
| Optional on one side | 1 : 0..1 | Parent may lack a child | User and optional profile photo |
| Optional on both sides | 0..1 : 0..1 | Either row may exist alone | Parking spot and assigned car |
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.
| Cardinality | Rule | Relational implementation | Example |
|---|---|---|---|
| One-to-one | Each side has at most one partner | Unique foreign key or shared key | Person and national ID record |
| One-to-many | One parent, several children | Plain foreign key on the child | Customer and orders |
| Many-to-many | Several partners on both sides | Junction table with two foreign keys | Students and courses |
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
partylinks one-to-one to subtypes such aspersonororganization. - 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.
| Mistake | Consequence | Fix |
|---|---|---|
| Foreign key without unique constraint | Duplicate children appear silently | Add a unique constraint or shared key |
| Foreign keys on both tables | Circular dependency and inconsistent links | Keep the key on the dependent side only |
| Split without a reason | Extra joins and slower writes | Merge into one table |
| Assumed one-to-one from sample data | Schema breaks when a second partner appears | Confirm the rule with domain experts |
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.