Domains in PostgreSQL projects

Domains can be defined in Luna Modeler in a similar way as Enums (enumerated types). In the main menu, click Others and select Domain. Then click the diagram area and add a new graphical object to the canvas.

Other object - toolbar

Another way to add a Domain to the diagram is via the context menu.

domain - context menu

Specify name, description, and other properties for your newly created domain in the right-side panel.

PostgreSQL domain - definition

What are the key advantages of using domains in PostgreSQL?

You can use standard datatypes in your column definitions, however, in case you need to change the datatype, you will have to modify it everywhere. If you used domains, such a change would be required only in the domain definition. Also, you can specify a check constraint for your domain. The same check constraint will be applied to every column where the domain will be used instead of the standard data type. Domains are great time-savers.

Domain selected instead of the standard data type:

PostgreSQL domain

Generated SQL script for PostgreSQL table with a column where the domain is used:

SQL script


Quick links

Download Buy Now!

Blog Categories
Blog by Platforms