Schemas
Define relationships and indexes
Relationships and indexes give a schema its shape. Kenseme records primary keys, foreign-key relationships and indexes per table, and can suggest relationships by matching column names to primary keys.
In the app: Data Model › Schemas › your schema › Tables › a table › Relationships or Indexes tab
Before you start¶
Changing keys, relationships and indexes needs Read/Write access to the schema.
Set the primary key¶
- Open the table and go to the
Columnstab. - Click the pencil icon on a key column.
- Tick
Primary Keyand clickSave Changes. - For a composite key, repeat for each column in the key.
The key columns show a key icon in the grid, and the Indexes tab shows the key under Primary Key.
Note: Keys, relationships and indexes are design metadata. Kenseme doesn’t enforce them on data; they flow into the SQL it generates.
Relationships on a table¶
The Relationships tab has two sections:
- Relationships From This Table: relationships where this table references another. Columns:
References Table,Column Mappings,Type, and edit/delete actions. - Relationships To This Table: other tables whose relationships point here. Columns:
From Table,Column Mappings,Type.
Create a relationship¶
- Open the table and go to
Relationships. - Click
Add Relationship. TheCreate Database Relationshipdialog opens in three steps. - Step 1 of 3, source. Pick the
Relationship Type:One to Many,Many to OneorMany to Many. Pick theFrom Tableand tick its columns. ForOne to Many, pick the primary key columns; forMany to One, the foreign key columns. - Click
Next. - Step 2 of 3, target. Pick the
Schema(it can be a different schema), theTo Table, and its columns. - Click
Next. - Step 3 of 3, map columns. For each source column, pick the matching target column, or choose
Literal Valueand type a fixed value. - Click
Finish.
To change a relationship, click its pencil icon; the Edit Database Relationship dialog uses the same steps. To remove one, click the trash icon. The confirmation says you can restore it within 30 days.
Suggest relationships¶
Kenseme can suggest relationships by matching column names to the primary keys of other tables. There are two places to run it.
For the whole schema
- On the schema’s
Infotab, underACTIONS, clickSuggest Relationships. - Kenseme analyzes every table and lists suggestions with
One (PK),Column MappingsandMany (FK). - Click
Createon a row, or tick rows and clickCreate Selected. Rows that already exist showCreated.
For one table
- On the table’s
Relationshipstab, clickSuggest. - Tick
All schemasto look beyond this schema, then clickSearch. - Create suggestions the same way.
If nothing is found, the dialog says so. That usually means the relationships already exist, or column names don’t follow a pattern Kenseme can match.
Tip: Matching works best when foreign key columns are named after the table they point to, for example
CustomerIdpointing atCustomer. Set your ID suffix under naming conventions in Schema settings.
Indexes¶
The Indexes tab shows the table’s Primary Key and its Indexes, each with Index Name, Type, Columns and Unique.
Create an index¶
- Click
Add Index, or tick columns on theColumnstab and clickCreate Index. - Enter an
Index Name, or click the button next to it to generate one from the selected columns. - Optionally add a
Description. - Tick
Unique Indexif the index enforces uniqueness. - In the
Columnsgrid:- Tick
Indexedfor key columns. - Tick
Includedfor columns carried in the index but not part of the key. - Set
Orderfor the key column sequence andSort(ascending or descending).
- Tick
- Click
Create Index.
At least one column must be marked Indexed. Edit an index with its pencil icon; delete it with the trash icon.
Note: Some dialects don’t support traditional indexes, for example Fabric Lakehouse. Generated SQL leaves them out there. See Dialect-specific output notes.