268
votes

I would like to generate an entity-relationship diagram (ERD) from an existing PostgreSQL database.

  • What is the recommended approach to do this?
  • Are there any built-in tools to do it? Or third-party alternatives?
6
  • 4
    i want to visualize the relationships between tables of the existing schema Commented Aug 13, 2010 at 6:40
  • @ALL is there any add-on for pgadmin III to get the ER-Diagrams done as this Video in this Link Says . Commented Oct 15, 2013 at 13:56
  • check this out... softwarerecs.stackexchange.com/questions/34552/… Commented Jun 8, 2021 at 10:49
  • No one mentioned SchemaSpy below thus far, so here it is. Commented Apr 15, 2023 at 13:49
  • You can use Luna Modeler to visualize relationships in PostgreSQL. Commented Jun 1, 2023 at 5:49

12 Answers 12

235
votes

You can use DBeaver Community to do this.

It's really easy... on the left just open one of your Databases:

  • Click on Schemas -> Public -> Tables
  • On Tables right click, and look for "View Diagram"

It also allows you to print your ER diagram and export as an image (png, gif, bmp formats) or as a file in GraphML format. You can check the official DBeaver documentation on ER diagrams here.

Sign up to request clarification or add additional context in comments.

6 Comments

Second this! While l I generally prefer the psql terminal, at times I also use DBeaver CE (Community Edition; dbeaver.jkiss.org/download ; an excellent, free and open source platform) for viewing data and visualizing the ERDs.
Here's the DBeaver ER Diagrams wiki page, which includes helpful tips for layout and exporting to image file format:
And it is opensource, meanwhile the accepted answer is for a product (DBVisualizer) that gives a limited trial and after you need to purchase a license
Started with DBVisualizer because it was higher on the page, but this is CLEARLY the right answer here. DBVisualizer's free version is immensely limited AND it looks like it was designed by a DBA in 1992. Meanwhile DBeaver, while not a design marvel, is quite nice looking, and the ERDs it generates are SIGNIFICANTLY easier to read/follow/look at.
Just point out that DBeaver Community Edition allows : double click on table to open ER diagram limited to related tables ; save manual arrangements you do to each autogenerated ER diagram ; create custom diagrams (.erd files) with a subset of tables ; add table to existing diagrams and auto add relationships ; export diagrams as .png
|
234
votes

pgAdmin 4 version 30 and newer can generate the ERD from an existing database. Just right-click on the database and select Generate ERD.

enter image description here

4 Comments

I just tried it (on a small DB with 5 tables) and it seems to work fairly well!
Good start but that doesn't generate everything. It would be usefull to also design views for example.
Can we generate ERD for some tables ?
(For those looking to export the ERD to an image, there's a download image button along the top options after creating [Alt+Ctrl+I is the listed shortcut for me]. Since that was part of krishna's answer, and my desire, figured that may be of use to some)
115
votes

We used DBVisualizer for that.

Description: The References graph is a great feature as it automatically renders all primary/foreign key mappings (also called referential integrity constraints) in a graph style. The table nodes and relations are layed out automatically, with a number of layout modes available. The resulting graph is unique as it displays all information in an optimal and readable layout. from its site

4 Comments

To find the graph in postgres, I had to click into the schema, then click TABLE, and, in the window on the right, click the 'References' tab. This feature is available in the free version, too.
Maybe this is a temporary problem, but the tool was unusable for me in v 11.0.4 on Win 10. The GUI had drawing problems which makes it unable to use.
This tool does not support Postgres' table inheritance. Parent and child tables are shown in the diagram without any visual relation.
does it have ERD with crow's foot notation?
17
votes

pgModeler can generate nice ER diagram from PostgreSQL databases.

It seems there is no manual, but it is easy enough without manual. It's QT application. AFAIK, Fedora and Ubuntu has package. (pgmodeler)

In the latest version of pgModeler (0.9.1) the trial version allows you to create ERD (the design button is not disabled). To do so:

  1. Click Design button to first create an empty 'design model'
  2. Then click on Import and connect to the server and database you want (unless you already set that up in Manage, in which case all your databases will be available to select in step 3)
  3. Import all objects (it will warn that you are importing to the current model, which is fine since it is empty).
  4. Now switch back to the Design tab to see your ERD.

2 Comments

Not that easy. "Design" button is disabled, and there are no hints how to enable it.
pgModeler seems to be the only one, which supports table inheritance.
6
votes

Download DbVisualizer from : https://www.dbvis.com/download/10.0

and after installing create database connection:

SS1

Change highlighted detail of your db and test by click ping server. Finally click connect

Enjoy.

1 Comment

Thanks, works for me. After you are connected - double-click on 'TABLE' and go to 'References' tab. Here is the link for details.
4
votes

Our team use Visual Paradigm to generate ER diagram from database in many of our projects. While we mainly work on MS SQL and Oracle, as I know they also support some other DBMS like PostgreSQL, MySQL, Sybase, DB2 and SQLite.

Steps:

  1. Select Tools > DB > Reverse Database... from the toolbar of Visual Paradigm
  2. Keep the settings as is and click Next Select PostgreSQL as driver and provide the driver file there. You can simply click on the download link there to get the driver.
  3. Enter the hostname, database name, user and password, and then click Next
  4. They will then study your database and lists out the tables in it.
  5. Select the table to form an ERD and continue, and that's it. An ERD will be generated with the tables you selected presented.

BTW they also support generating and updating database schema from ERD.

Hope this helps. :-)

More information about generating ERD from PostgreSQL database

1 Comment

The free Community version does have this feature available
3
votes

ERBuilder can generate ER diagram from PostgreSQL databases (reverse engineer feature).

Below step to follow to generate an ER diagram:

• Click on Menu -> File -> reverse engineer

• Click on new connection

• Fill in PostgresSQL connection information

• Click on OK

• Click on next

• Select objects (tables, triggers, sequences…..) that you want to reverse engineer.

• Click on next.

  • If you are using trial version, your ERD will be displayed automatically.
  • If your are using the free edition you need to drag and drop the tables from the treeview placed in the left side of application

enter image description here

1 Comment

No open source. Just 15 days trial.
2
votes

Another option is use Oracle SQL Developer. Two steps as below:

(1) First of all, you need to connect SQL Developer to your PostgreSQL database.

(2) Then you can generate an entity-relationship (ER) diagram using SQL Developer

Comments

2
votes

postgresql_autodoc is a command-line tool for doing this. Doesnt do cardinality, but none of the above mentioned GUI tools do as well.

Comments

0
votes

Perhaps have a look at AquaFold's Aqua Data Studio. It is a database IDE with entity-relationship diagramming. It also includes data profiling. It is not free but its price is very reasonable considering its capabilities.

Comments

-8
votes

You can generate ER diagram from PgAdmin.

  1. Open PgAdmin
  2. Right click on any table and select statement and it will show two window one is query other is graphical window so you can add the table which you want to generate the diagram.
  3. To save go to save as and select Graphical Query (image)

1 Comment

I don't see any options like this, pgAdmin 4, version 2.1. There is no "select statement" or "statement" in the context menu for a table
-10
votes
  1. Open MySQL Workbench. In the home screen click 'Create EER Model From Existing Database'. We are doing this for the case that we have already made the data base and now we want to make an ER diagram of that database.

  2. Then you will see the 'Reverse Engineer Database' dialouge. Here if you are asked for the password, provided the admin password. Do not get confused here with the windows password. Here you need to provide the MySQL admin password. Then click on Next.

  3. In the next dialouge box, you'll see that the connection to DBMS is started and schema is revrieved from Database. Go next.

  4. Now Select the Schema you created earlier. It is the table you want to create the ER diagram of.

  5. Click Next and go to Select Objects menu. Here you can click on 'Show Filter' to use the selected Table Objects in the diagram. You can both add and remove tables here.Then click on Execute.

6.When you go Next and Finish, the required ER diagram is on the screen.

1 Comment

Doesn't work for PostgreSQL or other databases, it's MySQL-only

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.