Use the SQL plugin to create an entity relationship diagram
This plugin should be used as-is, as an unsupported example for developers.
Insert SQL code using the SQL plugin to automatically generate entity shapes, including their attributes, as well as their primary and foreign keys. To complete your entity relationship diagram, connect the entities together and set the connector ‘arrows’ to describe their relationships.
Load the SQL plugin
- To create a new diagram with the plugin already loaded, go to https://app.diagrams.net/?splash=0&p=sql
Create an ER diagram from SQL code
As SQL and MySQL are the most popular languages used to program and work with relational database systems, diagrams.net has made it easy to automatically create your diagrams from your code.
- Click Arrange > Insert > From SQL.
- Copy and paste your SQL code into the dialog, then click Insert MySQL or Insert SQL Server, whichever matches the code you just pasted.
- Your SQL code is converted into entities containing the attributes, as well as the primary and foreign keys your code defines.
- Connect the entities and choose the ‘arrow’ shape that defines the relationship.
Tip: To see the various entity relationship styles, enable the Entity Relation shape library (via More Shapes in the left panel), then hover over the various connector shapes to show their descriptions.
Permanently load the plugin
If you want to always use the sql plugin, add it to the plugins list so it will be loaded each time you create or edit a diagram.
- From the menu, select Extras > Plugins.
- Click Add.
sqlin the drop-down list of built-in plugins, then click OK.
- Click Apply.
Reload your browser tab to load the plugin into the diagram editor.
Note: Plugins are not supported in draw.io for Confluence.