liveBook · Manning

Entity-relationship diagram

As explained in 100 SQL Server Mistakes and How to Avoid Them

An entity relationship diagram is a diagram that represents data entities, their attributes, and the relationships between them.

An entity-relationship diagram (ERD) maps data entities such as tables, their attributes such as columns, and the relationships between them. It can show primary and foreign key constraints and optionally record each column’s data type. section 3.1 section 4.1

Use an ERD to make database design decisions visible and testable:

  • Document the current table structure, expected column values, data types, primary keys, foreign keys, and relationships. section 3.1 section 4.4
  • Validate normalization instead of relying on personal judgment, helping expose nonatomic values and duplicated data. section 4.1
  • Use the diagram as the code-level diagram in a C4 model when documenting a database design. section 3.1 section 4.1

Employees ERD

An Employees ERD records EmployeeID and ManagerID as SMALLINT because the expected number of unique values is below the INT range. It records StaffOrContract as BIT because the column stores 0, 1, or NULL, and documents the remaining columns with their types and expected values. section 3.1

Figure 3.1 Employees ERD

The Employees ERD figure provides a concrete visual model of entities, attributes, relationships, and annotated data types. section 3.1

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains diagram contents and validation purpose, but stops short of prescribing a complete notation or diagramming procedure.
Examples
Uses an Employees ERD annotated with column expectations and SQL Server data-type choices such as SMALLINT and BIT.
What it assumes
Assumes basic familiarity with tables, columns, and database schemas while defining entities, attributes, and relationships directly.
What you can do after
Evaluate schema structure, validate normalization, and document key relationships and column definitions.
How it connects
Connects database normalization, primary keys, foreign keys, data generalization, and C4 code diagrams.

Also explained in

Compare how 4 books explain entity-relationship diagram →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.