Database diagrams
In the Database tool window, right-click a database object and select Diagrams | Show Diagram
This functionality relies on the Database Tools and SQL plugin, which is bundled and enabled in Aqua by default. If the relevant features are not available, make sure that you did not disable the plugin.
Press CtrlAlt0S to open settings and then select Plugins.
Open the Installed tab, find the Database Tools and SQL plugin, and select the checkbox next to the plugin name.
This functionality relies on the Diagrams plugin, which is bundled and enabled in Aqua by default. If the relevant features are not available, make sure that you did not disable the plugin.
Press CtrlAlt0S to open settings and then select Plugins.
Open the Installed tab, find the Diagrams plugin, and select the checkbox next to the plugin name.
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 Aqua. It is not supported by other products. If you want to share the created diagram, consider using PNG.
Also, you can build execution plans. An execution plan is a set of steps that were used to access data in a database. For more information about creating an execution plan, refer to Visualize a query plan.
In the Database tool window (View | Tool Windows | Database) , right-click a database object and select Diagrams | Show Diagram.
![Generate a diagram for a database object Generate a diagram for a database object](https://resources.jetbrains.com/help/img/idea/2024.3/create_diagram_for_schema.png)
![Generate a diagram for a database object Generate a diagram for a database object](https://resources.jetbrains.com/help/img/idea/2024.3/create_diagram_for_database.png)
To pan and zoom the diagram, use your touchpad, scroll bars or the mouse wheel for vertical scrolling and Shift + mouse wheel for horizontal scrolling. You can also use Shift + mouse wheel for zooming.
To use the magnifier tool, keep the Alt key pressed and hover over the desired areas of the diagram. Use the mouse wheel to extra zoom the diagram area within the magnifier tool.
Generate a diagram. For more information about generating a diagram, refer to Generate a diagram for a database object.
Click the Comments button (
).
In the Database tool window (View | Tool Windows | Database) , right-click an object and select Tools | Set Color.
Select a color and click OK. Refresh the diagram to apply the color by clicking the Refresh button ().
In Aqua, you can export a diagram in various formats to a file, to clipboard, and open it in a web editor. You can also print a diagram and save it as an image. To do that, use the corresponding actions in the context menu of your diagram.
To export your diagram to a third-party editor in web browser, right-click the diagram, navigate to Export Diagram | Open in Web Editor, and select the editor.
Alternatively, click the Export Diagram button (
) on the diagram toolbar, and select the editor in the corresponding submenu.
The supported editors are as follows:
To copy your diagram to clipboard, right-click the diagram, navigate to Export Diagram | Copy to Clipboard, and select the format.
Alternatively, click the Export Diagram button (
) on the diagram toolbar, and select the format in the corresponding submenu.
The supported formats are as follows:
Mermaid
classDiagram
{...}PlantUML
@startuml
{...}Graphviz DOT
digraph "sakila" {
{...}Graphviz DOT with Positions
digraph "sakila" {
{...}
To export your diagram to a file, right-click the diagram, navigate to Export Diagram | Export to File, and select the format.
Alternatively, click the Export Diagram button (
) on the diagram toolbar, and select the format in the corresponding submenu.
The supported formats are as follows:
YEd .graphml
JGraph .drawio
Graphviz .dot
Graphviz .dot with Positions
Mermaid .md
PlantUML
IDEA .uml: The UML format
is an internal format supported only by Aqua. To open the saved diagram, drag the UML file to the editor.
To export your diagram as an image in PNG format, right-click the diagram and select Export Diagram | Export to Image.
Alternatively, click the Export Diagram button (
) on the diagram toolbar, and select Export to Image.
Possible icon combinations for columns in diagrams:
Icon | Foreign key | Primary key | Indexed | NOT NULL |
---|---|---|---|---|
To configure the default visibility settings and layout for diagrams, Open settings by pressing CtrlAlt0S and navigate to Tools | Diagrams. .
![the Diagrams menu the Diagrams menu](https://resources.jetbrains.com/help/img/idea/2024.3/database_diagrams_settings.png)
Select the checkboxes next to the elements to be shown on diagrams.
Item | Description |
---|---|
Show Difference | |
Details | If this checkbox is selected, all the specified details of the elements will be shown in the UML class diagram for a revision. If this checkbox is not selected, only node elements will be included in the diagram. |
DB Diagrams | |
Key columns | For the primary key columns to be shown when a diagram opens, select this checkbox. When viewing a diagram in the editor, use |
Columns | For the columns other than the primary key columns to be shown when a diagram opens, select this checkbox. When viewing a diagram in the editor, use |
Graphical Explain Plan | |
Attributes | Toggles the display of query attributes on a query map. These attributes can be a number of rows, index names, or any other additional information about the query. For more information about building a query map, refer to Visualize a query plan. Enabled Disabled ![]() ![]() |
note
More nodes appear in this pane depending on the installed and enabled plugins.
Item | Description |
---|---|
Default layout | Select the desired layout from the Default layout list. Node elements in newly created diagrams will be arranged according to the selected layout. |
Default scope | Select scope from the Default scope list. Specifying a scope helps you avoid showing in diagram the unnecessary hierarchies. You can define scopes for your project in the Scopes page of the Settings (CtrlAlt0S) dialog. |
Fit content after layout | If this checkbox is selected, then after applying a layout selected on the diagram context menu, all diagram elements will be resized to fit into the current diagram area. In diagram, use the |
Do relayout when new elements were added | If this checkbox is selected, diagram layout will be performed automatically after adding new elements. |
Use the diagram editor toolbar to quickly access actions and the context menu to manage the displayed diagram.
Item | Description |
---|---|
(Available when you work with databases.) Click this button to show primary key columns in the diagram. | |
(Available when you work with databases.) Toggles the display of the following:
| |
(Available when you work with databases.) Click this button to hide or show virtual foreign keys in the diagram. | |
(Available when you work with databases.) Click this button to hide or show comments in the diagram. | |
Click this icon to increase the scale of the diagram. Alternatively, press NumPad +. | |
Click this icon to decrease the scale of the diagram. Alternatively, press NumPad -. | |
Click this icon to restore the actual size of the diagram. | |
Click this icon to make the contents fit into the current diagram size. | |
Click this icon to apply the current layout, selected from the Layout node of the diagram context menu. | |
Click this icon to scale the diagram to the edges of the window. | |
Click this icon to copy the diagram into the clipboard. | |
Click this icon and then select any diagram area with the mouse: the selected area will be copied into the clipboard. | |
Click this icon to export a diagram using various formats, which are compatible with third-party tools, to a file, to an image, or open the diagram in the browser. ![]() You can select and configure the following options:
| |
Click this button to refresh the whole diagram. | |
Click this button to open the Diagram settings where you can configure additional options. |
The table below contains commands that are not available from the toolbar.
Item | Description |
---|---|
Selected Element Actions | Use this option to open a list of actions that is applied to a selected element in the diagram. You can select actions to copy an element, jump to its source, find its usages, use the Navigate actions, various Git actions, and so on. |
Content | Use this option to open a list of actions that help you to add new elements, show dependencies, sort elements inside the diagram, and so on.
|
Delete | Deletes the selected diagram. |
Analyze Graph | Use this node to select one of the commands to analyze a diagram. You can check the graph characteristics, change the focus of the graph, measure graph centrality, and so on. |
Layout | Select the desired diagram layout from the submenu. |
Behavior | Use this option to select commands related to the diagram behavior sucha as aligning elements against the grid, showing structure view for the selected node, or fitting the content after the layout. |
Export Diagram | Use this option to export a diagram using various formats, which are compatible with third-party tools, to a file, to an image, or open the diagram in the browser. |
Thanks for your feedback!