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.
| Area | How to Open | Use |
|---|---|---|
| ERD bottom detail panel | Select 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 tab | Click "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.
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.
Composite PK
Select the PK checkbox on multiple columns to set a composite Primary Key.

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.
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.

Add FK
Click the "+ ADD FOREIGN KEY" button to open the FK creation modal.
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.
Confirm FK Name
The FK name is auto-generated in the format fk_{referencedTable}_to_{currentTable}. You can modify it manually if needed.

| FK List Column | Description |
|---|---|
| FK Name | Foreign key name |
| FK Column(s) | FK column(s) in the current table |
| Referenced Table | Referenced table |
| Referenced Column(s) | Column(s) in the referenced table |
| Actions | FK delete button |
FK Mapping Options
| Option | Behavior |
|---|---|
| Referenced Table selection | Choose 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 mapping | Only 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 Column | Turn 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. |
| Deferrable | Shown 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.
Check Indexes Section
View the current table's indexes in the Indexes section. PRIMARY, regular, and Unique indexes are shown together.

Add Index
Click the "+ ADD INDEX" button to open the index creation modal.
Set Index Name & Options
Enter the index name. If a Unique Index is needed, select the "Unique" checkbox.
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 List Column | Description |
|---|---|
| Index Name | Index name |
| Type | UNIQUE or INDEX |
| Column(s) | Columns included in the index |
| Index Type | Index type (BTREE, etc.) |
| Actions | Index 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.
- 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.
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.
Click Add Constraint
Click "Add Constraint" and choose UNIQUE, CHECK, or EXCLUSION for supported DBMSs.
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.
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.
| Type | Input | Note |
|---|---|---|
| UNIQUE | Select 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. |
| CHECK | Enter a CHECK expression such as age >= 18. | The DBMS must support CHECK constraints for database apply to succeed. |
| EXCLUSION | Enter 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.
