Library / Data & backend / Relationship
No. 049·noun·also called relation, foreign key, one-to-many

Relationship

How two kinds of data connect, like one customer having many orders.

SPECIMEN · DIAGRAM · COMPARE

One-to-many

  • A customer has many orders
  • Each order has one customer

Many-to-many

  • Students take many courses
  • Courses have many students
Definition

What it is

A relationship describes how records in one table link to records in another. The common kinds are one-to-one (a user has one profile), one-to-many (a customer has many orders), and many-to-many (students take many courses; courses have many students).

Getting these right is one of the most important decisions in an app, because it's hard to change later. "Can a task have more than one assignee?" sounds small but changes the data model.

Always state the "how many" in both directions.

Say it like a builder

How to ask for it

Vague

“Tasks have people on them.”

Precise

“Tasks and people have a many-to-many relationship: a task can have several assignees, and a person can be assigned to many tasks. Show assignees as avatars on each task.”

Why it works

"Have people on them" doesn't say how many; naming the relationship type in both directions avoids a costly rebuild later.

In the wild

You've seen this in

  • SOrders linked to a customer in Shopify
  • NTags on Notion pages
  • ALinked records in Airtable
Usage note

Often confused with