From Requirements to Entities and Relationships
Turn a paragraph of requirements into entities, attributes and relationships, read cardinality in both directions, and sketch the result as an ER diagram.
Contentsand lesson path
On this page
- Why it matters
- Nouns, verbs and the identity test
- Relationships and cardinality
- Drawing and reading the diagram
- Check your understanding
- Apply it
- Review prompt
Lessons of Relational Data Modeling
- From Requirements to Entities and Relationships Concept · 20 min
- Choosing Keys: Natural, Surrogate and Composite Concept · 20 min
- Worked Example: An Order Management Schema Worked example · 30 min
- Spotting Anomalies and Normalizing to 3NF Lab · 30 min
- Constraints as Executable Business Rules Lab · 25 min
- Check: Review and Repair a Flawed Schema Knowledge check · 8 questions
What you will learn
- Derive entities, attributes, relationships and cardinalities from written requirements and draw them as an ER diagram.
Prerequisites: SQL Fundamentals
01. Why it matters
In the SQL fundamentals lessons you queried tables that already existed. Someone decided that products should be a table, that orders should live separately, and that an order's items belong in a third table. This skill is about being that someone.
A query is cheap to rewrite. A table holding live data is not: changing its shape means a migration, coordination with every program that writes to it, and often downtime. The cheapest place to get a data model right is before any data exists, and the input at that point is almost never a schema — it is a paragraph of requirements from the people who run the business.
The tool for that translation is the entity-relationship model: a short list of the things the business cares about, the facts kept about each, and how they connect. It is also a communication device. You can walk a stakeholder through an entity-relationship diagram in five minutes; you cannot walk them through a page of CREATE TABLE statements at all.
This skill keeps the small online shop from the SQL lessons as its running example, so the tables you design here are tables you already know how to query.
02. Nouns, verbs and the identity test
Here is the requirement paragraph for the shop, in the form a product owner might write it:
Customers register with an email address, a full name and an
optional phone number. A customer can save several delivery
addresses. Customers place orders; each order gets a reference
like ORD-2026-0142, is placed at a moment in time and ships to
exactly one of that customer's addresses. An order contains one
or more lines; each line names one product, a quantity and the
unit price charged. Products have a stock-keeping unit (SKU), a
name and a catalogue price. Staff curate collections for the
storefront: a product can appear in many collections, and a
collection lists many products in a chosen order.Start mechanical: underline the nouns and the verbs. Nouns become candidates for entities (kinds of thing the business keeps many of: Customer, Address, Order, Order line, Product, Collection) or for attributes (single facts about one entity: an email address, a phone number, a placed-at time). Verbs become candidates for relationships: places, contains, ships to, appears in.
The noun list alone does not decide; apply the identity test. An entity is something the business refers to on its own — counts it, searches for it, links other facts to it, or needs to change one instance without touching the rest. A customer passes: the shop counts customers per month and emails one customer without the others. A phone number fails: it is a fact about a customer, and no other part of the domain points at a phone number by itself. So phone becomes a column on Customer, not a PhoneNumber entity.
Two easy traps hide in the paragraph. "A reference like ORD-2026-0142" is an identifier — an attribute whose job is to be unique and readable, not a separate thing. And "the unit price charged" belongs to the line, not to the product: the catalogue price and the price actually charged are two different facts, because prices change and old orders must not. Getting that placement right now is what keeps last month's invoices correct later.
Some facts belong to a pairing rather than to one entity. "A chosen order" for products in a collection is a fact about one product in one collection — neither the product alone nor the collection alone. The model treats the pairing itself as a thing with attributes, which becomes its own table in the next lesson.
03. Relationships and cardinality
Every relationship gets a cardinality: how many of each side take part. There are only three shapes to choose from, and you must read each in both directions:
- One-to-many. One customer places many orders; each order belongs to exactly one customer. This is the workhorse of relational design — the many side holds the reference.
- One-to-one. Rare and deliberate; used to split or isolate facts, for example one user profile row per user account.
- Many-to-many. Products appear in many collections and collections list many products. No single column can express this on either side; the pairing entity resolves it.
Cardinality also records optionality, and the two questions are separate. Ask "how many?" and "can it be none?". A customer with zero orders so far is fine, so orders are zero or many from the customer side. But an order with zero lines is not an order at all: from the order side, lines are one or many. Those small words drive real decisions later — which columns may be NULL, which relationships are mandatory.
Reading a relationship line is a two-step habit that prevents most modelling mistakes. Stand on one entity, pick a single instance of it, and ask how many of the other entity connect to that one. Then swap ends and repeat. "How many orders can one customer have? Zero or many. How many customers does one order have? Exactly one." Do this for every line on the diagram and far fewer numbers will surprise you later.
04. Drawing and reading the diagram
Crow's foot notation is the most common way to draw cardinality. The symbol at each end of a line says how many of that entity relate to one instance at the other end:
Marker Reads as Meaning
──|| exactly one one and only one
──o| zero or one an optional single
──|{ one or many at least one
──o{ zero or many none, one or morecustomers ||──o{ orders a customer places 0..* orders
orders ||──|{ order_lines an order contains 1..* lines
products ||──o{ order_lines a product appears on 0..* lines
customers ||──o{ addresses a customer keeps 0..* addresses
addresses ||──o{ orders an address receives 0..* orders
(each order ships to exactly 1)
collections ||──o{ collection_products the meet-in-the-middle entity
products ||──o{ collection_products detailed in the next lessonRead the first line both ways: a customer places zero or many orders (──o{ at the orders end), and each order is placed by exactly one customer (──|| at the customers end). Tools like dbdiagram.io, draw.io or Mermaid ER diagrams draw the same thing with nicer lines, and paper is a perfectly good medium — what matters is that the numbers are explicit and agreed.
The diagram is a working document, not an afterthought. Sit with the people who wrote the requirements and interrogate each end: can a customer really have zero addresses? Could an order ever hold two copies of the same product as separate lines? Every answer either confirms a line or changes the model while it is still cheap. When the diagram settles, it maps almost mechanically to SQL: each entity becomes a table, each one-to-many becomes a reference column on the many side, and the pairing entity becomes a small table of its own. The worked example later in this skill does exactly that mapping for this diagram.
05. Check your understanding
06. Apply it
Start the skill practice now: a clinic wants an appointment-booking system. Write the requirements paragraph yourself in the same style as the shop one — patients, doctors, appointments, and at least one more kind of thing the clinic counts. Then work the paragraph:
- List the nouns, and sort them into entities and attributes using the identity test; note any noun you had to argue about, and why.
- List the verbs and give every pair a cardinality in both directions, marking optionality ("zero or many", "one or many").
- Mark any attribute that belongs to a pairing of two entities rather than to either one.
- Draw the diagram and have someone read each line back to you in full sentences; fix whatever sounds wrong.
Keep the result: the entity-relationship diagram is the first deliverable of the practice for this skill.
07. Review prompt
Without looking back: what two tests separate an entity from an attribute, and what does each test ask? Name the three cardinality shapes with one shop example each, read in both directions. Where does an attribute like "position within a collection" belong, and why? And why is the diagram drawn before the DDL, not generated afterwards?
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.