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.
Then click the diagram area. A new graphical object will appear on the diagram.
Edit properties in Right Side panel:
Alternatively, you can double click the graphics or right-click the item and choose Edit.
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.
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.
4. Code generation
To generate an SQL script, click the SQL Script icon on the main toolbar.
How to execute the script? Use another tool, for example, PG Admin:
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
and then click Connect and reverse engineer the existing database.
Enjoy!
#