Database diagrams
Database diagrams graphically show the structure of the database and relations between database objects. You can generate a diagram for a data source, a schema, or a table. To create relations between database objects, consider using primary and foreign keys.
You can save the generated diagrams in two formats: UML and PNG. The UML format is an internal format developed specifically for PhpStorm. It is not supported by other products. If you want to share the created diagram, consider using PNG.
Also, you can build execution plans. Execution plan is a set of steps that were used to access data in a database. PhpStorm supports two types of execution plans:
Explain Plan: the result is shown in a mixed tree and table format on a dedicated Plan tab. You can click the Show Visualization icon (
) to create a diagram that visualizes the query execution.
Explain Plan (Raw): the result is shown in a table format.
Generate a diagram for a database object
In the Database tool window ( ), right-click a database object and select .
![Generate a diagram for a database object Generate a diagram for a database object](https://resources.jetbrains.com/help/img/idea/2022.1/create_diagram_for_db_object.png)
Build a query plan
Right-click an SQL statement, and select Explain Plan.
In the Output pane, click Plan.
By default, you see the tree representation of the query. To see the query plan, click Show Visualization
, or press Ctrl+Alt+Shift+U.
![Viewing SQL Query map Viewing SQL Query map](https://resources.jetbrains.com/help/img/idea/2022.1/psShowQueryMap.png)
Show execution plans
To create an execution plan, right-click a query in the editor and select Explain Plan. If you want to create a diagram for the query, click the Show Visualization icon (
).
Enable column comments
Generate a diagram. For more information about generating a diagram, see Generate a diagram for a database object.
Click the Comments button (
).
Apply colors to diagram objects
In the Database tool window ( ), right-click an object and select Color Settings….
Select a color and click OK.
Save diagrams in the UML format
This UML format is an internal format supported only by PhpStorm.
Right-click a diagram and select IDEA .uml.
To open the saved diagram, drag the UML file to the editor.
Save diagrams in the PNG format
Right-click a diagram and select Export to Image.