Insert from SQL to create an ER diagram
Entity relationship diagrams show how data is structured in relational databases. Each entity consists of rows of attributes. ER diagrams are used in software development and by IT workers to design and document database structure.
You can document your existing databases quickly and easily in diagrams.net by inserting your SQL code. This adds entities, or table shapes, to the drawing canvas which automatically contain rows for the attributes defined in your SQL code, which you will simply need to connect appropriately.
How to insert from SQL to create a diagram
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 > Advanced > SQL.
- You’ll see an example of SQL code in the dialog that appears. Copy and paste your SQL or MySQL code into the dialog, then click Insert.
- Your SQL code has been converted into entities containing all the attributes your code had defined. Now, all you need to do is to rearrange and connect the entities.
Enable the entity relation shape library
- Click More Shapes at the bottom of the left panel.
- In the Software section, click on the checkbox next to the Entity Relation shape library to enable it, then click Appy.
Use the entity relation connectors
When you want to add a connector from the entity shape library, hover over the connectors and a larger preview of connector will let you see the different connection types at each end.
Click on one of the connector shapes in the entity relation shape library to drop it quickly onto the drawing canvas.
Add rows to entity shapes
To add more attributes to entity shapes by duplicating an existing row. Select an existing entity row, then press the keyboard shortcut
Cmd+Enter on MacOS) to duplicate it.
Alternatively, right-click on an entity row, then select
Duplicate from the context menu.
You can also drag an entity row shape from the library into an entity shape to expand it.