Analyst Bootcamp Join on TelegramJoin
Junior+ · BA + SA

Data basics: entities, keys and a readable ERD

🕥 10 min read🧭 Both tracks📅 updated 2026-11-04Читать на русском

Enough data modelling to stop losing arguments with developers: what an entity is, why keys matter more than fields, how to read and draw a simple ERD, and the four questions that find the bugs in any data model.

Why an analyst needs this

"Just add a field for the second e-mail" sounds harmless until you learn that the customer table is copied into three reporting systems, the field name is already used for something else in the CRM export, and some customers have four e-mails. Data decisions are the ones that outlive every screen. An analyst who can read a data model asks these questions before the ticket is written, not after the migration.

You do not need to design databases. You need to speak the language: entity, attribute, key, relationship, cardinality. Five words.

Entities and attributes

An entity is a thing the business keeps track of and can count: Customer, Order, Product, Invoice. An attribute is a fact about one entity: the customer's e-mail, the order's total.

The first test of a model is the noun test. Underline the nouns in the requirement; each one is either an entity, an attribute of an entity, or a value (a status, a type). "A customer places orders; each order has several lines, each line is one product with a quantity":

The usual Junior+ mistake is making an attribute into an entity ("Email" as a table) or an entity into an attribute ("product name" typed into the order line). Rule of thumb: if the business can ask "how many of these do we have?" or "show me the history of this one", it is an entity.

Keys: the part developers care about most

A primary key identifies exactly one row and never changes. A foreign key is a column that holds another table's primary key, which is how relationships exist in a database. A natural key is a business identifier (e-mail, order number, VAT id); a surrogate key is a generated id with no meaning.

Why this matters to you: every "what if" in your ticket is a key question in disguise.

Your questionKey question underneath
Can a customer change their e-mail?Then e-mail cannot be the primary key; use a surrogate id
Can the same product appear twice in one order?Then (order_id, product_id) is not unique; the line needs its own id
Can two branches have the same order number?Then order number is unique only together with branch
What happens to orders when a customer is deleted?Foreign key behaviour: block, cascade, or keep with "deleted" flag

Ask these during refinement and you will be the analyst developers want in the room.

Relationships and cardinality

A relationship connects two entities, and cardinality says how many of one go with one of the other. Three shapes cover almost everything:

The second question is optionality: must every order have a customer (yes), must every customer have an order (no). Draw it; it decides whether a column can be empty.

Reading an ERD

An entity-relationship diagram is a picture of tables and their keys. Here is the model from the noun test above:

Four entities; the order line table is the many-to-many between orders and products and carries its own attributes.
Four entities; the order line table is the many-to-many between orders and products and carries its own attributes.

Reading it left to right: a customer has an id and an e-mail; an order points at a customer and has a status and a total; an order line points at both an order and a product and remembers the price at the time, because product prices change and old orders must not. That last point is a business rule hidden in a column, and spotting it is the whole skill.

Three things a readable ERD has, and a bad one lacks:

  1. Every table has a primary key marked and every relationship a foreign key you can find.
  2. Fewer than ten tables per picture. Split by area (orders, catalogue, billing) if there are more.
  3. Business names. "order_items" is fine; "tbl_ord_itm_x" needs a legend, and a legend means nobody will read it.

The four questions that find data bugs

Run these against any model, yours or a developer's, in refinement:

  1. What is the history? When a price, address or status changes, do we need the old value? If yes, the model needs a dated row (price history) or a copy at the time (price on the order line).
  2. What is the unit? Total in cents or euros, weight in grams or kilograms, time in UTC or local. Put it in the column name (amount_cents, weight_g) or the ticket.
  3. What can be empty, and what does empty mean? Null delivery date: not delivered yet, or unknown, or not applicable? Three meanings in one column is a bug factory.
  4. What is the status list, and who changes it? If a column is called status, the allowed values and the transitions belong in the ticket (see the state machine topic).
-- The same model as the diagram, as a developer would write it.
-- Reading this is enough; you will rarely write it.
CREATE TABLE customers (
  id          BIGSERIAL PRIMARY KEY,
  email       TEXT NOT NULL UNIQUE,
  created_at  TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE TABLE orders (
  id           BIGSERIAL PRIMARY KEY,
  customer_id  BIGINT NOT NULL REFERENCES customers(id),
  status       TEXT NOT NULL,              -- 'new' | 'paid' | 'shipped' | 'cancelled'
  total_cents  INTEGER NOT NULL,           -- unit in the name
  placed_at    TIMESTAMPTZ NOT NULL
);

CREATE TABLE products (
  id          BIGSERIAL PRIMARY KEY,
  sku         TEXT NOT NULL UNIQUE,
  name        TEXT NOT NULL,
  price_cents INTEGER NOT NULL             -- current price
);

CREATE TABLE order_items (
  id          BIGSERIAL PRIMARY KEY,
  order_id    BIGINT NOT NULL REFERENCES orders(id),
  product_id  BIGINT NOT NULL REFERENCES products(id),
  qty         INTEGER NOT NULL CHECK (qty > 0),
  price_cents INTEGER NOT NULL             -- price at the time of the order
);

Notice how much of the business lives in the small print: NOT NULL (must have), UNIQUE (one account per e-mail), CHECK (no zero quantities), the comment on status. When you review a schema, read the constraints before the columns.

With AI

Models draw plausible ERDs from a paragraph in seconds and are a fine way to get a first picture to argue about. They reliably miss history (question 1) and units (question 2), and they invent tables for every noun. Use the four questions on the output; the answers come from the business, not the model.

Try it (5–10 minutes)

Requirement: "Employees book meeting rooms. A booking is for one room, one time slot, and has an organiser and any number of attendees. Rooms belong to an office. We need to know who cancelled a booking and when."

  1. List the entities and their attributes. Decide the primary key of each (natural or surrogate, and why).
  2. Draw the ERD with cardinality and optionality. Where is the many-to-many?
  3. Run the four questions. Which one does "who cancelled and when" answer, and what columns does it add?

Where this shows up in real work

  • System analyst and data-adjacent BA job posts list "data modelling / ERD" and "SQL basics" as required; interviewers hand you a paragraph and ask for the entities and keys.
  • In real tickets, "add a field" requests are where analysts earn trust: the ones who ask about history, units and empties catch migrations that would have gone wrong.
  • Freelance briefs for internal tools (CRM, booking, inventory) are mostly a data model in disguise; a readable ERD is the first deliverable the client can react to.

Sources worth reading

Practice it on real drills

Data model for a new featureReport / dashboard requirementsData migration / cut-over plan

Finished reading and did the exercise?