Entity relationship diagram

Entity relationship diagram

An ER diagram is the fastest way to explain a database to somebody who has not read it. Capable gives you three text routes to one, and the right choice depends on whether the diagram is documentation or a source of truth.

Mermaid is the easy default. DBML is better if the diagram will eventually generate a schema.


When to reach for one

  • Documenting a schema for people who will query it.

  • Design reviews, where the relationships are the debate.

  • Onboarding, where a picture beats reading migrations.


How to draw it in Capable

Route

Use when

Route

Use when

Mermaid

Quick documentation of an existing schema.

DBML

The diagram is the schema definition, with types and defaults.

ERD

Classic ER notation from a compact text format.


A worked example

An order schema with cardinality on every relationship:

extension

The source, which you can paste into a new diagram and edit:

extension

A few things that catch people out

  • Get cardinality right; it is the only part of the diagram that carries real information.

  • Include the columns that matter, not every column. A 40-column table drawn in full is unreadable.

  • Join tables deserve to be drawn. Hiding them behind a many-to-many line loses their extra columns.


Related

extension

Get the cardinality right and the rest follows.

extension
extension