One-to-One Relationship in ERD Design

How to model a one-to-one (1:1) relationship in an ER diagram. Covers when to split tables, foreign key placement with UNIQUE constraint, and practical examples.

Relationship Types

Detailed Explanation

When One Record Pairs with Exactly One Other

A one-to-one (1:1) relationship means that each record in table A is associated with at most one record in table B, and vice versa. This is less common than one-to-many but important in specific design scenarios.

Why Split into Two Tables?

You might wonder: "If it's one-to-one, why not put everything in one table?" There are several valid reasons:

  1. Performance: Separate rarely-accessed columns (e.g., user profile details) from frequently-accessed ones (e.g., login credentials)
  2. Security: Isolate sensitive data (e.g., SSN, payment info) into a separate table with different access controls
  3. Optional data: When the related data doesn't exist for every record (e.g., not every user has a profile)
  4. Legacy integration: When merging data from different systems

Implementation

The foreign key goes in the "dependent" table (the one that can't exist without the other), and it must have a UNIQUE constraint:

CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  email VARCHAR(320) NOT NULL UNIQUE
);

CREATE TABLE user_profiles (
  id SERIAL PRIMARY KEY,
  user_id INT NOT NULL UNIQUE,
  bio TEXT,
  avatar_url VARCHAR(512),
  FOREIGN KEY (user_id) REFERENCES users(id)
);

The UNIQUE constraint on user_id is what enforces the "one" on the profile side. Without it, the relationship would be one-to-many (one user could have multiple profiles).

Alternative: Shared Primary Key

Another pattern uses the same primary key value in both tables:

CREATE TABLE user_profiles (
  user_id INT PRIMARY KEY,
  bio TEXT,
  FOREIGN KEY (user_id) REFERENCES users(id)
);

Here user_id is both the primary key and the foreign key, guaranteeing a strict 1:1 mapping.

In the ERD Editor

Create both entities, then add a one-to-one relationship between them. The diagram shows single line markers on both sides of the relationship line, visually distinct from the crow's foot used in one-to-many relationships.

Use Case

You are designing a system where user accounts need separate profile tables, or where sensitive data like payment details should be isolated from the main entity for security purposes. One-to-one relationships are also common when extending an existing schema without modifying the original table.

Try It — ERD Editor

Open full tool