Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Entity Relationship Diagrams: A Practical How-To

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

An entity relationship diagram (ERD) is a picture of the data your system needs: the things you store (entities), the facts you record about them (attributes), and how they connect (relationships). Building one first prevents the classic database headache of adding a column that breaks three other screens. You do not need special software to start — a whiteboard or a notebook works — but you do need a clear idea of what questions the data must answer.

What You'll Need

  • A list of the real-world things your system tracks — customers, orders, products, devices, rooms, readings. Write them as nouns.
  • The questions the system must answer, in plain language: "Which orders belong to this customer?", "How many devices are in each room?"
  • Paper and pencil, a whiteboard, or a diagramming tool. Free options include draw.io, Lucidchart's free tier, and the diagram features built into many IDEs.
  • Optional but helpful: a sample of real data (a spreadsheet export, a few rows from an existing system) to test your model against.

Step-by-Step

  1. List the entities. Go through your requirements and underline every noun that represents something you store more than once. "Customer" and "Order" are entities; "total price" is not — it is a calculated value. Aim for 5–15 entities on a first pass. If you have 40, you are probably listing attributes as entities.
  2. Give each entity a primary key. Every entity needs a unique identifier: customer_id, order_id, device_id. Prefer a meaningless surrogate key (an auto-incrementing number or UUID) over a natural key like an email address, because natural keys change. Write the key at the top of each entity box.
  3. Add attributes. Under the key, list the facts you need about each entity. For a Customer: name, email, signup date. For an Order: order date, status, total. Keep attributes atomic — one value per attribute. "Address" should usually split into street, city, postcode, country if you will ever filter or sort by them.
  4. Draw the relationships. Connect entities with a line and label it with a verb: Customer places Order; Order contains Product; Device belongs to Room. Read each line in both directions to check it makes sense: "A customer places many orders" and "an order is placed by one customer."
  5. Set cardinality and optionality. Mark each end of the line with 1 or many (often drawn as crow's foot notation). Then ask: must every order have a customer? If yes, the customer end is mandatory; if an order can exist as a guest checkout, it is optional. Getting optionality right prevents NULL-heavy tables later.
  6. Resolve many-to-many relationships. An Order contains many Products, and a Product appears in many Orders — that is many-to-many. Break it with a linking entity, OrderLine, which holds order_id, product_id, quantity, and unit price at time of sale. The same pattern applies to Student–Course (Enrollment) and Device–User (Assignment).
  7. Check for repeating groups. If you are tempted to add phone1, phone2, phone3 to a Customer, stop. Create a Phone entity linked to Customer instead. Any numbered column is a sign of a missing entity.
  8. Normalise to third normal form. First normal form: no repeating groups, every cell holds one value. Second: every non-key attribute depends on the whole key, not part of it. Third: no attribute depends on another non-key attribute — if you store both postcode and city, city depends on postcode, so either accept the redundancy deliberately or move it to a separate table.
  9. Test against real questions. Take each question from your requirements list and trace the path through the diagram. "Which devices are offline in the living room?" should go Device → Room → filter. If a question needs a join across four tables, consider whether a relationship is missing.
  10. Document the diagram. Add a short note for each entity explaining what it represents and any business rules ("an order cannot be deleted, only cancelled"). Label the cardinality clearly. A diagram without notes is a puzzle, not documentation.
  11. Review with someone who will use the data. Walk a colleague or stakeholder through the diagram using their own questions. They will spot missing entities — usually the ones that represent events, like Payment or Shipment — faster than you will.

Common Mistakes

  • Treating attributes as entities. "Address" as an entity only makes sense if one address is shared by many customers or changes independently. Otherwise it is a set of columns on Customer.
  • Forgetting the linking table. Many-to-many relationships drawn as a direct line will fail at implementation; the database cannot store them without a join table.
  • Using natural keys everywhere. Email addresses, phone numbers, and product names change. Surrogate keys are boring and reliable.
  • Modelling the UI instead of the data. A screen with a customer and their orders does not mean one table. Model what is true, not what is displayed.
  • Ignoring history. If you need to know what a product cost last month, you need a price history entity or a price column on the order line, not just the current price on Product.

Tips

  • Name entities in the singular (Customer, not Customers) and relationships as verbs. It keeps the diagram readable.
  • Keep a "parking lot" list of entities you are unsure about. Add them later rather than forcing them in early.
  • Use colour sparingly — one colour for core entities, another for lookup tables — so the diagram stays legible when printed.
  • Version your diagram. Date it and keep old copies; data models evolve and the history explains why.
  • If you are using a tool, export to PDF or PNG and store it with the project documentation, not just in the tool's cloud.

Troubleshooting

The diagram keeps growing. Stop and re-read your requirements. You are probably modelling future features. Cut to what the current system must do and note the rest.

Two entities look almost identical. Ask whether they differ in attributes or behaviour. If not, merge them; if they differ only by a type flag, consider a single entity with a type attribute.

A relationship needs attributes. That is a sign it should be an entity. "Customer buys Product" with a purchase date and quantity becomes OrderLine or Purchase.

You cannot decide on cardinality. Write two example rows and see whether the rule holds. If a customer can have zero orders, the relationship is optional on that side.

The model will not normalise cleanly. Accept a little denormalisation for reporting if you document it, but never let it creep into the transactional tables without a reason.

Frequently Asked Questions

Do I need special software to draw an ERD?

No. Paper works for a first draft. Free tools like draw.io and Lucidchart's free tier are fine for sharing, and many database design tools can generate a diagram from an existing schema.

What is the difference between an ERD and a database schema?

An ERD is a conceptual or logical model of entities and relationships. A schema is the physical implementation — tables, columns, data types, indexes. The ERD comes first and guides the schema.

How many entities should a diagram have?

There is no fixed number. A small app might have five; a large system dozens. If a first draft has more than about fifteen, check whether some are really attributes or lookup values.

Should I include data types in the ERD?

Only if the diagram is meant to be a physical model. For a logical ERD, attribute names and keys are enough; data types belong in the schema design.

Can I change the diagram later?

Yes, and you should. Treat the ERD as a living document. Update it when requirements change and keep dated versions so you can see how the model evolved.

What is crow's foot notation?

A way of drawing cardinality where the "many" end of a relationship is shown as a three-pronged fork. It is widely used because it shows one-to-many and optionality clearly on a single line.