Diagrams guide

Sketching a data model before anyone builds anything

A data model names the things a system stores, what it keeps about each and how they relate. Sketch it early, in plain words, with the people who know.

Diagrams · · 4 minute read

The short answer

  • List the things the business cares about, as nouns.
  • For each link, ask whether it is one or many, in both directions.
  • Agree it with the people who do the work, not just the developers.

A finished example

This is what the Data model template can look like once it is filled in. This one is for a bakery’s online orders.

An example made up for this guide. Your own board starts with the headings and prompts, and you add the notes.
Read the example as words
On the board
Customer: id, number, main ID; name, text; email, text
Order: id, number, main ID; customer_id, number, links to another table; placed, date; total, money
Product: id, number, main ID; name, text; price, money
Order line: id, number, main ID; order_id, number, links to another table; product_id, number, links to another table; quantity, number; price_paid, money
Questions
An order, even if a product is removed
The price paid at the time
How the boxes are joined
Customer places Order, one to many
Order has Order line, one to many
Product is on Order line, one to many

What a data model is

Every system that keeps records has a data model, whether or not anyone drew it. It is the answer to three questions. What things do we keep information about? What do we record about each? How are they connected?

A shop keeps information about customers, orders and products. About a customer, it records a name and an email. About an order, a date and a total. A customer places orders, and an order contains products. That is a data model.

Drawing it out, before building, is one of the most valuable steps in any project that involves data. Mistakes in the model are cheap to fix on a whiteboard. They are costly to fix once thousands of records exist.

The drawing is often called an entity relationship diagram. You do not need the jargon. Boxes for things, lines for links and a few words on each line are enough.

It applies as much to a spreadsheet or a filing system as to a database.

Things and what you keep

Start by listing the things. Listen to how people describe their work, and pick out the nouns. "A customer books an appointment with a stylist for a treatment." That gives customer, appointment, stylist and treatment.

Each thing becomes a box. Name it in the singular, in the words the business uses.

Then list what you need to record about each. For a customer, that may be name, email and phone number. Write these inside the box.

Record only what you need. Every extra piece of personal information is something to look after and protect. If you cannot say what it is for, leave it out.

Put each fact in one place only. A product's price belongs with the product. If it were copied onto every order, a change would have to be made in many places.

There is one exception. Sometimes you need the value as it was at the time. The price on an old order should not change when the product's price does.

How things relate

Now draw lines between things that are connected, and label each line.

For every line, ask two questions. Can one of these have many of those? And the other way round?

A customer can place many orders. An order belongs to one customer. That is a one-to-many link, and it is the most common kind.

An order can include many products. A product can appear on many orders. That is many-to-many. In practice, it needs a thing in the middle. Here that is an order line, which records one product on one order, with a quantity.

Occasionally a link is one-to-one, such as a person and their passport.

Write the link as a short phrase on the line: "places many", "has many", "is for one". Read it aloud as a sentence to check it. "A customer places many orders."

Getting these right matters more than anything else in the model. They decide what the system can and cannot do later.

Testing it, and the template

Test the model with real cases. Take an actual order from last week and walk it through. Can every part of it be recorded? Then try the awkward ones. A customer with two addresses. An order that was part refunded. A product that was withdrawn.

Ask the questions people will want answered. "Which customers bought this product last year?" Trace the lines to check the model can answer.

Involve the people who do the work. They know the exceptions that break tidy models.

The Data model template on doodleboard shows a sample for a shop. Customer, order, order line and product are each a data table, with a row for each field. A field is one piece of information you keep, such as a name or a date. The lines are labelled places, has and is on. A questions frame at the side starts with "What must never be lost?"

Each line ends in a mark that says how many. A short bar means one. Three small toes mean many. A small ring means the link can be empty. To change an end, select the line and pick One, One or none, Many or One or many.

Double-click a table to rename it and add or remove fields. Mark the main ID (PK), or a field that points to another table (FK). If a developer already has the database, they can paste its SQL onto the board, and each table appears already joined. Select the tables and choose Copy as code to take the model back out as SQL or Mermaid.

Questions people ask

Do I need to be technical to draw a data model?

No. At this stage it is about the business, not the technology. If you can describe what you keep records of and how those things connect, you can sketch a model. Developers turn it into a database later.

What is a many-to-many link?

It is where each of two things can connect to many of the other. Students and classes are an example. A student takes many classes, and a class has many students. It is handled by adding a linking thing, such as an enrolment.

How much detail should the first sketch have?

Enough to show the main things, a few key facts about each and how they link. Types such as number, text or date can wait until the shape is agreed. The aim is agreement on the shape before work begins.

Templates for diagrams and mapping

Put it on a shared whiteboard

Start for free with one board and up to three people, or try every feature for 7 days.

Start for freeSee pricing