ErdDocs

ER diagram examples

14 database schemas, each drawn by ErdDocs as an interactive ER diagram with the SQL to copy. Every domain teaches a different modeling pattern, so find the one closest to your assignment or project.

New to the notation? ER diagram explains what the boxes and line ends mean before you copy anything.

Questions before you copy one

What are the main types of database schema?

Four names come up: flat (one table, no relations), hierarchical (a strict parent-child tree), network (a record may have several parents) and relational (tables joined by keys). Every example below is relational, because that is what PostgreSQL, MySQL, SQL Server and SQLite are. The other three are mostly history, or a way to describe document and graph databases that are not built from tables at all.

Can I use these schemas in my own project or assignment?

Yes. Each page gives the SQL in full, and it runs as written on PostgreSQL. They are teaching schemas rather than production ones. Each is small enough to read in a sitting. Each is built around one modeling decision worth copying, or worth arguing with, which is just as useful in an assignment.

How do I turn one of these into a diagram of my own database?

Replace the SQL. Export your schema with pg_dump --schema-only or mysqldump --no-data and paste it over the example. You can also paste a Prisma schema, DBML, Mermaid, PlantUML, or Django, SQLAlchemy, Sequelize or TypeORM models. The format is detected from what you paste. Nothing is uploaded: the parsing happens in your browser.

Which example should I start with?

Start with the blog schema if you want every relationship type in five tables. Take the e-commerce one if you need a junction table that carries its own data. If your problem is really about time, take the hotel or library schema. Bookings, loans and availability are where beginners most often model a query as a column. For a database you will meet in a SQL course, start with Northwind or Chinook. For one shaped like a real company, take AdventureWorks.

Have your own schema instead? Paste it on the home page: same tool, your tables. For the printable reference document, use the data dictionary generator.