Skip to content
Guide · DataGrip

DataGrip ER Diagram Tutorial

DataGrip draws entity relationship diagrams from the tables and foreign keys that already exist in your database. This tutorial shows how to generate one, make it readable and export it, using a small example schema you can create yourself, and is clear about what the diagram editor does not do.

Steps and facts checked 8 October 2026 against the vendor's official documentation. Versions covered: DataGrip 2026.2. Next review due April 2027. Menus, shortcuts and prices change between releases; check the vendor's documentation for your version.
Short answer
  • Right-click a data source, schema or table and choose Diagrams | Show Diagram (Ctrl+Alt+Shift+U on Windows) to generate a diagram.
  • Relationships come from primary and foreign keys, so the diagram is only as good as the constraints in the database.
  • Diagrams export to PNG, draw.io, GraphML, Graphviz, Mermaid and PlantUML; the native .uml format only opens in DataGrip, in the same project.
  • DataGrip is a reverse-engineering viewer, not a design-first modelling tool: you change structure with DDL or the Modify dialog, then refresh the diagram.
How we know: Research-based: features, menus and export formats were checked against the DataGrip documentation on 8 October 2026. We have not generated these diagrams for this tutorial; the example schema is provided for you to run on your own database.

What a DataGrip ER diagram is

A DataGrip ER diagram is what JetBrains' documentation calls a database diagram: a graphical view of tables, their columns and the relationships between them. You can generate one for a whole data source, a single schema or one table. The feature comes from the Diagrams plugin, which is bundled and enabled by default; if the menu items are missing, check that the plugin has not been disabled under Settings | Plugins.

The diagram is built from the database's metadata. Lines between tables come from primary and foreign keys, so a schema without declared foreign keys produces boxes with no lines. The diagram toolbar also has a button to show or hide virtual foreign keys.

An example schema to diagram

If you do not have a schema with foreign keys to hand, create the four tables below in a test database (the statements use standard syntax that PostgreSQL and MySQL both accept). It gives a typical one-to-many and many-to-many layout: customers place orders, and order lines link orders to products.

Example schema with declared foreign keys (PostgreSQL / MySQL)
CREATE TABLE customers (
    customer_id INT PRIMARY KEY,
    name        VARCHAR(100) NOT NULL,
    email       VARCHAR(255) UNIQUE
);

CREATE TABLE products (
    product_id INT PRIMARY KEY,
    name       VARCHAR(100) NOT NULL,
    price      DECIMAL(10, 2) NOT NULL
);

CREATE TABLE orders (
    order_id    INT PRIMARY KEY,
    customer_id INT NOT NULL,
    order_date  DATE NOT NULL,
    CONSTRAINT fk_orders_customer
        FOREIGN KEY (customer_id) REFERENCES customers (customer_id)
);

CREATE TABLE order_items (
    order_id   INT NOT NULL,
    product_id INT NOT NULL,
    quantity   INT NOT NULL CHECK (quantity > 0),
    PRIMARY KEY (order_id, product_id),
    CONSTRAINT fk_items_order
        FOREIGN KEY (order_id) REFERENCES orders (order_id),
    CONSTRAINT fk_items_product
        FOREIGN KEY (product_id) REFERENCES products (product_id)
);

Generate the diagram step by step

  1. Connect to the database (see DataGrip and PostgreSQL or DataGrip and MySQL). After running the script, right-click the schema and choose Refresh (Ctrl+F5) so DataGrip sees the new tables.
  2. In the Database Explorer, right-click the schema and choose Diagrams | Show Diagram (Ctrl+Alt+Shift+U on Windows, Cmd+Alt+Shift+U on macOS). The diagram opens in its own editor tab.
  3. For a quick look without a new tab, use Diagrams | Show Diagram Popup (Ctrl+Alt+U, Cmd+Alt+U on macOS).
  4. To add a table from another schema, drag it from the Database Explorer onto the diagram.

For the example schema you should see four tables, with lines from orders to customers and from order_items to both orders and products.

Make a large diagram readable

  • Keys only. Toolbar buttons show or hide primary key columns and other columns separately; showing only keys makes the relationships stand out.
  • Comments. The Comments button adds column comments to the boxes.
  • Colours. Right-click an object in the Database Explorer, choose Set Color, then refresh the diagram.
  • Find. Press Ctrl+F in the diagram to jump to a table by name.
  • Focus. Select two tables and choose Analyze Graph | Focus On Paths Between Two Nodes, or use Focus on Node Neighborhood for one table and its neighbours.
  • Layout defaults. Under Settings | Tools | Diagrams you can choose which columns appear by default and the default layout.

Save and export the diagram

The .uml format is internal to DataGrip and can only be opened in the project where it was created, so use PNG for sharing a picture and Mermaid, PlantUML or draw.io when someone needs to edit or version the diagram as text.

Export options listed in the DataGrip documentation
ActionFormats or targets
Export Diagram | Export to ImagePNG
Export Diagram | Export to FileyEd .graphml, JGraph .drawio, Graphviz .dot (with or without positions), Mermaid .md, PlantUML, IDEA .uml
Export Diagram | Copy to ClipboardMermaid, PlantUML, Graphviz DOT (with or without positions)
Export Diagram | Open in Web EditoryEd Live, diagrams.net, Graphviz Online, Mermaid Live, PlantUML Web Server

Limits: what the DataGrip diagram editor does not do

DataGrip diagrams are generated from an existing database. The documentation does not describe drawing new tables or relationships on the canvas and generating a schema from that drawing, which is what dedicated modelling tools call forward engineering. Structural changes go through SQL in a query console or the Modify dialog (Ctrl+F6), which changes the database itself; JetBrains notes that undoing a diagram change does not revert changes already applied through the Modify dialog.

For a design-first workflow, write the DDL, run it against a scratch database, refresh, and regenerate the diagram, or export to draw.io or PlantUML and edit there. If you need a full modelling tool, see our list of ER diagram tools.

Frequently asked questions

How do I create an ER diagram in DataGrip?

Right-click a data source, schema or table in the Database Explorer and choose Diagrams | Show Diagram, or press Ctrl+Alt+Shift+U (Windows) or Cmd+Alt+Shift+U (macOS).

Why are there no relationship lines in my DataGrip diagram?

Lines come from foreign keys. If the tables have no declared foreign keys, add them with ALTER TABLE ... ADD CONSTRAINT ... FOREIGN KEY, then refresh the schema and the diagram.

Can I export a DataGrip diagram to PNG or draw.io?

Yes. Use Export Diagram | Export to Image for PNG and Export to File for .drawio, .graphml, .dot, Mermaid or PlantUML.

Can I design a new database by drawing in DataGrip?

Not as a modelling tool would. DataGrip visualises existing structures; create or change tables with SQL or the Modify dialog, then refresh the diagram.

Can someone else open my .uml diagram file?

Only in DataGrip, and only within the same project. Export to PNG, Mermaid, PlantUML or draw.io to share it.

Sources

Checked 8 October 2026.

How we research tool guides: our editorial method. CodeWithSQL earns nothing from the vendors mentioned.

Still choosing a SQL client?

Read the full reviews, or compare tools side by side.