DEV Community

Cover image for Generate ER Diagrams in MYSQL workbench
allan-pg
allan-pg

Posted on

Generate ER Diagrams in MYSQL workbench

Introduction

Entity Relationship(ER) diagrams are visual representation of the database structure that shows relationship between entities. An entity is a real world object for example student, employee and an entity has attributes. An attribute is characteristic of an entity for example a student can have an ID, name, age.

Creating ER Diagrams in MySQL Workbench

Ensure you have a database with more than one table in MYSQL workbench. In this article, I will be using Sakila database available on MYSQL website.

  1. Open MYSQL workbench and login to local host
  2. In a new Query Tab run the following command to use sakila database
USE sakila;
Enter fullscreen mode Exit fullscreen mode
  1. On the main menu bar Click on Databases

main menu bar

  1. click on reverse engineering or use (ctrl + R) shortcut command

reverse engineering

  1. A new window will appear → click on next

new window

  1. Enter password to the local host → click on next

login window

  1. Choose database to generate an ER diagram which is Sakila for our case → click next

SQL Workbench

  1. click next again

SQL Workbench

  1. Ensure all tables are selected by clicking on show filters button → click execute

MYSQL workbench

  1. click next on windows that will appear

MYSQL workbench

  1. click Finish and an ER diagram to sakila database will appear

ER Diagram

Conclusion

An ER diagram is an essential part of the database design process that reduces redundancy, ensures data integrity, aids in communication and simplifies database management. Designing a clear ER diagram at the start of a project helps prevent errors and ensures that the database system meets both functional and business requirements efficiently.

Top comments (1)

Collapse
 
amolo_awuor profile image
Fiona Amolo Awuor

Niiice. I'm learning day by day. Kudos Allan