I finally found a simple way to generate entity relationship diagram an existing database with MySQL Workbench.

In order to achieve this, we must use MySQL Workbench. It is a free application from Oracle and MySQL can be downloaded from you here.

Once installed and configured our connection to the database we want to get your "Entity-Relationship Diagram," we go to the top menu Database and select the option Reverse Engineer (Reverse engineering):

paso 01 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
We will show the following window where we select our connection to the database, localhost, and press Next (Following):

paso 02 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
When the process is finished, we press Next:

paso 03 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
Select the database that interests us and press Next:

paso 04 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
When the process is finished, we press Next:

paso 05 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
In the next window we select which objects you want to include in our diagram. In our select all. It is important to select the check that appears at the bottom. Sometimes I happened to select leaves me because maybe there are too many objects selected. press Next to continue:

paso 06 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
When the process is finished, we press Next:

paso 07 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
If all goes correctly you should see a window like this:

paso 08 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
press Finish to complete and should show the diagram with all the tables in our database. Sometimes it only matters the tables without establishing relations between them. This is because such information does not exist in the tables, very common in free software applications.

paso 09 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench

If we look closely, the tables have drawn relationships is because they have that information created:

paso 09a Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
Instead, here we can see a table that does have the foreign columns:

paso 09b Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench

but that does not have such information created:

paso 09c Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench

For that reason, does not draw relationships in the diagram.

Once we have the complete diagram, we can print it and take notes of each of the tables and put them to our liking to make it easier to read the diagram.

paso 10 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench
Besides getting the diagram, there are two things that I liked enough of this tool, although it seems bullshit, are as follows.

If we position on a relationship between tables, it is shaded and indicates which table fields are those that are related. This is very useful because visually it is not easy to know which columns are related. There are many Free Software applications that use a simple nomenclature in the fields and even sometimes give generic names because they are trying to primary keys that are used for many types of entities, so the power to visualize this makes it easier develop your SQL queries:

paso 11 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench

And the other thing that is also very useful, is that you can change the type of diagram for the above is simpler still. From the top menu, in ModelAnd the menu Relationship Notation you can select the style diagram. Default is selected "Crow's Foot (IE)" but if we select Connect to Columns we can see directly the relations on the fields involved.

paso 12 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench

The diagram would be shown as follows, also indicating the cardinality of relations with clearer symbols if we do not have much knowledge of UML:

paso 13 Generar diagrama entidad relacion de una base de datos MySql existente con MySQL Workbench

The only downside of it is that draws no relations with horizontal and vertical lines. Use diagonal lines and drawing is a little uglier. But at least it helps to interpret the scheme.

I hope you liked it and will serve as useful.

Save

Advertisements

Use of cookies

This site uses cookies for you to have the best user experience. If you continue to browse you are giving your consent to the acceptance of the above cookies and acceptance of our cookies policy, Click the link for more information.

OK
Notice of cookies

Pin it on Pinterest

Share This

Share

Share this with your friends!