How to Generate Database EER Diagrams from SQL Scripts using MySQL Workbench
By Güngör Budak
- One minute read - 210 wordsMySQL Workbench makes it really easy to generate EER diagrams from SQL scripts. Follow below steps to make one for yourself.
Download and install MySQL Workbench for your system.
See below simple SQL commands, later I’ll use them to generate a sample diagram.
1create table country (
2 id integer primary key,
3 name CHAR(55));
4
5create table city (
6 id integer primary key,
7 country_id integer,
8 name CHAR(55),
9 foreign key (country_id) references country(id));
Open MySQL Workbench and create a new model (File -> New Model).
Then import your SQL script (File -> Import -> Reverse Engineer MySQL Create Script). Note that you should select MySQL Model tab prior to this to be able to import the SQL script.
The above operation will open a window where you should be selecting your SQL file and make sure that you checked Place imported objects on a diagram. This will automatically generate the diagram for you.
After you Execute, and complete, click Continue and then Close to finish up. You should be able to see the diagram as shown below.
Finally, use File -> Export -> Export as Single Page PDF… to export the diagram to a PDF file.
This applies to MySQL Workbench 6.3.9 on macOS Sierra 10.12.6.