PostgreSQL database design

 

Note: this page is outdated. Please visit page PostgreSQL Database Design

 

1. New project

To create a new project, click New on the main toolbar and select the PostgreSQL project type.

2. Add tables

Basic database objects can be added to your project/diagram by clicking the appropriate icon on the main toolbar.

New postgresql database table

Then click the diagram area. A new graphical object will appear on the diagram.

Edit properties in Right Side panel:

Edit table

Alternatively, you can double click the graphics or right-click the item and choose Edit.

Edit table

Table properties

Basic type settings can be specified in the section Details.

Columns

In section Columns, you can add new table columns. Specify new column name, datatype, enum, domain and click Add.

  • PK indicates primary key.
  • NN represents Not Null column.

Detailed column specifics can be defined in a collapsible/expandable area.

Detail of table columns

 

3. Relationships

Relationships can be created between parent and child tables (for other visual references you can use Lines and connect two graphical objects).

To add a new relationship to the diagram, click the Relationship icon, then click the parent table and then the child table. If the primary key is defined in the parent table, a new column will be added to the child table and marked as a foreign key.

Example: relationship drawn from table customer to table cart. Foreign key column customer_id was added to the child table automatically.

PostgreSQL relationship

4. Code generation

To generate an SQL script, click the SQL Script icon on the main toolbar.

Generated SQL script for postgreSQL

How to execute the script? Use another tool, for example, PG Admin:

PG admin dark theme

5. Other features and visual elements

Notes, lines and other information that can be displayed in a diagram will help you keep the structure well documented. You can also display descriptions instead of columns in the visualisations.

6. Reverse engineering and visualization of existing database structures

You can establish a connection to your PostgreSQL database and load the existing structure, incl. all supported PostgreSQL objects.

To reverse engineer a database, create a new connection

PostgreSQL database connection

and then click Connect and reverse engineer the existing database.

Connect and reverse engineer a PostgreSQL database structure

Enjoy!

#

Copyright: 2024 Ideamerit s.r.o. All rights reserved. Legal