Skip to content

One-to-many and many-to-many relationships, with examples

One-to-many and many-to-many with example tables: which side holds the link, what shows up on the other table, and when a connection needs its own table.

Updated November 2026

Every relationship in a working database has one of two shapes. Once you can tell which one you're looking at, most of the design work is done, and the rest is adding the fields.

A customer has many orders

Nour orders a monstera in March and two pothos in June. That's two orders and one customer, and no order was placed by two customers.

This is one-to-many, with one customer and many orders, and the difference between the two sides decides where the link goes. For each side, ask how many of the other could this record point at?

  • An order's answer is one. "Which customer placed this?" has a single answer, so the order can store it as a value, in one cell holding one customer.
  • The customer's answer is many, and there's no upper limit. In March the answer is one order, and by June it's three. You don't store a value that keeps growing on the record. You get it by asking the other table.

So the link goes on the many side. Each order points at its one customer, the way each booking points at its one guest, and the "one" side stores nothing at all.

The mirror

So how does Nour's record list her orders? The list comes from reading the same links backward. Every order that points at Nour is on her order list, and collecting them needs no second copy of anything.

Tools in this category show that list as a field. Open the customer and there's an Orders field holding every order that points at her. It looks like data, but it's one relationship, seen from its other end. Link an order to Nour and it shows up on her record right away. There is no second bookkeeping step and nothing that can disagree. You also can't edit the mirror into a contradiction, because the mirror and the link are the same fact.

Once the relationship exists, derived fields can use it, such as the customer's email shown on each order or the sum of order totals shown on the customer. Lookup vs rollup covers those. This page is about the relationship underneath.

An order holds many products

This is the second shape. Order ORD-1041 holds a monstera and a golden pothos, and the golden pothos also appears in thirty other orders. Ask the question from both sides. An order's answer is many products, and a product's answer is many orders.

Neither side is "the one," so the rule that put the link on the many side has no side to pick. This is many-to-many, and in a no-code database you build it the obvious way, with a link field that allows several, on either table. The order lists its plants, and each plant's mirror lists the orders it appears in. For relationships that work like tags (plants to care tags, articles to topics, people to committees), that's all the design you need.

When the connection itself has facts

A tidy many-to-many and a cramped one are one step apart. Say the order needs three pothos, and the price each was sold at. Where do those facts go? Not on the product, because 3 isn't a fact about pothos in general. Not on the order either, because it has a quantity per product. The quantity is a fact about the pairing of this product with this order.

When the connection has facts of its own, make it a table. Call it Order lines. Each record links one order and one product, and holds the quantity, the sold-at price and a line note. An order's contents are its lines, and a product's sales history is its lines. Nothing is crowded, and the sold-at price can differ from the current price, which an invoice needs sooner or later.

Database people call this a junction table. Whatever you call it, the habit to learn is that a relationship with facts of its own becomes a table. You'll know you need one when you catch yourself trying to write a quantity into a link.

Which shape is it

For any two tables A and B, ask three questions:

  1. Can an A point at many Bs, and a B at many As? → many-to-many.
  2. Otherwise, the link goes on the side that answers "one of the other." That's one-to-many, with the link on the many side.
  3. Does the connection itself carry facts? → give it a table, whatever shape it was.

How this works in Tabla

A linked record field is one relationship with both ends built in:

  • Creating the link creates its mirror. Add a Customer link on Orders and Tabla adds an Orders field to Customers in the same step. It's one relationship that you can read from both tables, and nobody maintains the two ends separately.
  • Allow many sets the shape. With it off, a cell links one record, like an order's customer. With it on, a cell links several, like an order's plants. The mirror always allows many, because single links add up when you read them from the other end. Fifty orders that each link to her show up as fifty on her mirror.
  • Single links stay single. Link an order to a new customer and it leaves the old customer's mirror, because a record can't be in two places when its own side links one. The picker tells you before it happens.
  • A junction table is an ordinary table with two single links on each record, as above. Lookups and rollups work over any of these links, and that's where the sums and the borrowed emails come from.

The customer, order and plant examples above come from the demo shop these guides share, which is built this way, with links in both directions and sums that use them. From tabs to tables covers the design step before this one.

About Tabla

Tabla is a no-code database with Postgres underneath. Every feature is on every plan, you get a million records per database, and you can export your whole database in one file any day.

More guides