ERD from SQL

The ERD tool allows you to generate an ER diagram from a SQL database. It is also possible to create an ERD from a SQL DDL script. You can turn the whole schema into a diagram or you can select only some tables that you want to be imported.

Generate ERD from SQL DDL Script

If you want to create an ERD from SQL, you can use the Smart Parser sidebar for this purpose. (The sidebar can be displayed from the ribbon - VIew tab/ Window group/ Sidebars drop-down button/ Smart Parser). It is very easy to use the sidebar - just switch the Language drop-down to SQL DDL, paste a SQL script to the large text area (that covers most of the sidebar), and click on the Parse button.

The results (entities, relationships), which were extracted from the given SQL script, will be displayed in the list in the bottom part of the sidebar. You can insert only a selected item from the list using the Insert button or you can insert all the resolved elements using Insert All button.

Parse Multiple SQL DDL Scripts to Diagram

The first procedure is suitable for a quick script conversion. If you want to convert several SQL scripts to ERD, it is better to use the Source Code reverse engineering feature. You can access it from the ribbon - Process tab / Reverse Engineering group / Source Code button.

ERD Generation Settings
ERD Generation Settings

Convert Database to ER Diagram

If you want to extract model and diagrams from your relational database or its part you can do it using the Database Reverse Engineering tool. It is available from the ribbon - Process tab / Reverse Engineering group / Database button. It shows the Import Database dialog, where you can specify the data source and connection string of the desired database.

Firstly, choose the, data source from the following options:

  • MS SQL Server
  • My SQL
  • OLE DB (other databases, e.g. Oracle)

Then enter the connection string to a target database from the chosen data source.

When you click on the Load Tables button, the table will be listed in the box below. There you can choose the tables you want to import.

Import Database
Import Database

You can adjust the generated results using the Advanced tab. There are two group boxes with settings. One includes diagram generation options, the second one is for the imported model.

Diagram Options

If you want to import only the model and then draw the diagrams yourself (from the imported ERD entities) you can uncheck the option Add new elements to diagram. If the option is checked the database diagrams will be automatically created by the imported model.

You can choose the diagram where the new entities will be created. You have these options:

  • New diagram - creates a new diagram for the imported database tables. This option has also another parameter Separate diagram for each schema. If you check it, multiple diagrams will be generated - one diagram for each database schema.
  • Automatic to existing diagram - the new tables that are currently missing in your ER model will be added to existing diagrams. The entities will be added to a diagram in which it has the most relationships.
  • Existing Diagram option allows you to choose any diagram in your project you want. The additional ERD entities will be imported to the chosen diagram.

Model Options

The Model group box offers options that allow you to modify the model importer behavior. There are these options:

  • Update existing elements - if checked, updates the entities that are already included in the project - adds new attributes, updates the attribute details, and remove missing attributes.
  • Delete missing elements - if checked, the entities that are missing in the database will be deleted from the project.

You can also set which repository will be used for the imported model. There are two options:

  • Default repository - the elements will be imported to the default path in the project.
  • Custom repository - the elements will be imported to the chosen repository.
Import Database Settings
Import Database Settings

Add a Table to ERD using Database Sidebar

The Database sidebar provides a quick view of chosen databases. It lists the database tables and allows you to import the desired tables to the active diagram very quickly and easily. Just drag and drop the table from the list to the diagram or double click the item of the desired table.

You can decide which databases and database servers will be included in the database sidebar list. The sidebar offers the top bar with these buttons:

  • Connect Server - connects a SQL server with all its databases.
  • Connect Database - connects a single SQL database.
  • Disconnect Server or Database - disconnects the node selected in the list of servers and databases.
  • Add to Project - creates an entity by the selected table in the list and adds it to the active diagram.

New Comment

Comment