Creating ER diagram for a MySQL database

Jeyasri Ramesh
3 min readMar 20, 2022
Photo by Alina Grubnyak on Unsplash

The best way to understand a relational database is by reading its Entity Relationship (ER) diagram. It explains how the tables are related with one another and through which keys. Let’s learn how to create a ER diagram for a new database.

Step 1: Import a database into MySQL workbench

  • Download ‘Northwind’ MySQL database from Google Archive
  • Open MySQL Workbench -> Go to Databases -> Go to Data Import
  • Select the downloaded database to import
  • Click Start import and wait till the progress bar completes. Refresh the schemas. You’ll see the database ‘NorthWind’. Close the Data import window.

Step 2: Generate ER diagram

  • Select Database -> Reverse Engineer
  • For connection options, click continue.
  • For connection to DBMS, click continue.
  • For select schemas, select ‘Northwind’ database.
  • For retrieve objects, click continue.
  • For select object, select ‘Import MySQL table objects’ alone and click execute.
  • For reverse engineer, click continue. Also your ER diagram will now appear on the background.
  • For results, click close. It displays the number of tables in the database for which the ER diagram was created.

Step 3: Reading the ER diagram

  • Navigate around the ER diagram window to view all the tables connected with one another
  • For better readability, let’s re-arrange the tables in such a way that their connections don’t overlap one another. Finally download it by selecting File -> Export -> Export as PNG.

--

--