Indexes / Constraints

Learn how to manage PK, FK, and Indexes (including Unique) in the Schema Editor.

Where to Manage

PK, FK, Index, and Constraint settings are managed in the table detail editor. You can open the same editor from an ERD node or from a table detail tab in the left tree.

AreaHow to OpenUse
ERD bottom detail panelSelect a table in the ERD to show Table Columns, Foreign Keys, Indexes, and Constraints sections at the bottom.Use this when you want to add or delete FK/Index/Constraint settings while viewing ERD relationships.
Schema Editor detail tabClick "View in Detail Tab" on a table or open a table from the left table tree.Use this when you want a wider editor for table info, columns, FKs, indexes, and constraints.

Primary Key (PK)

Set up and manage the primary key of a table.

1

Set PK in Schema Editor

When you open a table, the Table Columns grid is displayed. Select the "PK" checkbox for the column you want to designate as PK.

2

Composite PK

Select the PK checkbox on multiple columns to set a composite Primary Key.

Primary Key (PK)
Tip

Columns with PK set are automatically shown as a PRIMARY index with Type "UNIQUE" in the Indexes section below.

Note: PK columns are automatically set to Not Null. PK changes are tracked as table primaryKeys changes, not as ordinary single-column edits, and are included in PK ALTER DDL when applying to the database.

Foreign Key (FK)

Manage foreign keys that define referential relationships between tables.

1

Check Foreign Keys Section

View the FK list owned by the current table in the Foreign Keys section. FKs created from ERD relationship lines also appear here.

Check Foreign Keys Section
2

Add FK

Click the "+ ADD FOREIGN KEY" button to open the FK creation modal.

3

Map Referenced Table & Columns

Select the referenced table in the modal, and its PK columns will be auto-displayed. Map a type-compatible column from the current table, or toggle "New Column" to create a new column.

4

Confirm FK Name

The FK name is auto-generated in the format fk_{referencedTable}_to_{currentTable}. You can modify it manually if needed.

Foreign Key (FK)
FK List ColumnDescription
FK NameForeign key name
FK Column(s)FK column(s) in the current table
Referenced TableReferenced table
Referenced Column(s)Column(s) in the referenced table
ActionsFK delete button

FK Mapping Options

OptionBehavior
Referenced Table selectionChoose a referenced table from the connection's schema-grouped table list. If metadata is not loaded yet, it is loaded on demand when selected.
Existing column mappingOnly non-deleted columns with compatible types that are not already used by another FK are shown. For self-referencing FKs, the table's own PK columns are excluded as FK columns.
New ColumnTurn this on when no compatible column exists or when you want to create a new FK column. Enter the column name and use N/N to set Not Null.
DeferrableShown only for DBMSs that support deferrable FK constraints. You can choose DEFERRABLE and INITIALLY IMMEDIATE/DEFERRED.

Note: When an FK is created through identifying/non-identifying relationship mode, mappable columns can be restricted by the relationship mode. Identifying relationships prefer PK columns, while non-identifying relationships prefer non-PK columns.

Index Management

Create and manage indexes for query performance optimization. Unique constraints are also set through index creation.

1

Check Indexes Section

View the current table's indexes in the Indexes section. PRIMARY, regular, and Unique indexes are shown together.

Check Indexes Section
2

Add Index

Click the "+ ADD INDEX" button to open the index creation modal.

3

Set Index Name & Options

Enter the index name. If a Unique Index is needed, select the "Unique" checkbox.

4

Select Columns & Sort Order

Select columns from the left "Available Columns" list and move them to the right "Selected Columns". Use drag & drop or arrow buttons to move/reorder columns. Double-click a selected column to toggle its sort order (ASC/DESC).

Index Management
Index List ColumnDescription
Index NameIndex name
TypeUNIQUE or INDEX
Column(s)Columns included in the index
Index TypeIndex type (BTREE, etc.)
ActionsIndex delete button

Note: Unique indexes can be created in the Indexes section, and UNIQUE constraints can also be created in the Constraints section. Both are handled as unique-style DDL when applying database changes.

Tip
  • Double-click the sort order cell in Selected Columns to toggle ASC/DESC. The default is ASC.
  • Move columns by drag and drop, or use the center/right arrow buttons to select, remove, and reorder them.
  • When you click the delete button for an index, a confirmation dialog appears. Confirming deletes all column entries under that index name.

Constraint Management

The Constraints section shows PK, FK, UNIQUE, CHECK, and EXCLUSION constraints in one list. PK/FK rows are derived from existing settings, while UNIQUE/CHECK/EXCLUSION can be added or edited through the Add Constraint modal.

1

Check Constraints Section

In the Constraints section, review Name, Type, Definition, Deferrable, and Actions. PRIMARY_KEY and FOREIGN_KEY are read-only derived rows; UNIQUE/CHECK/EXCLUSION rows are editable.

2

Click Add Constraint

Click "Add Constraint" and choose UNIQUE, CHECK, or EXCLUSION for supported DBMSs.

3

Enter Name and Definition

Enter Name manually or click Auto to generate one. For UNIQUE, check columns. For CHECK, enter an expression. For EXCLUSION, enter the PostgreSQL EXCLUDE clause body.

4

Set Deferrable and Save

If the DBMS supports it, configure Deferrable options and click Add Constraint. The added constraint becomes part of table changes for save/apply-to-DB.

TypeInputNote
UNIQUESelect column checkboxes. The check order becomes the constraint column order.Prevents duplicates for a column or column combination. It is similar in purpose to a Unique Index but is managed separately in the Constraints list.
CHECKEnter a CHECK expression such as age >= 18.The DBMS must support CHECK constraints for database apply to succeed.
EXCLUSIONEnter an EXCLUDE clause body such as USING gist (room WITH =, during WITH &&).Shown only for DBMSs that support EXCLUSION constraints, such as PostgreSQL.

Note: PK and FK rows are not edited directly in the Constraints section. Manage PK from the Table Columns PK checkbox and FK from the Foreign Keys section or ERD relationship lines.