Foreign keys on columns

A foreign key links a column to another table. Set it in the FK cell of a table's Columns step, where you also pick the target table and the relationship type.

Set a foreign key

  1. Open the table and go to its Columns step. The step and its grid are covered on Edit a table's columns.
  2. Click the checkbox in the column's FK (Foreign Key) cell. The picker opens; a column that already has a key shows the checkbox ticked.
  3. Pick the relationship type: Many to One or One to One.
  4. Find the table. The picker loads its list of tables when it opens, and the search box reads Search table…; a search with no matches shows No table found.
  5. Click the table you want. Clicking the same table again deselects it.
  6. Close the picker. Your choices apply when it closes; nothing is written to the row before that.

What changes on the column

Setting a key reshapes the column in one go:

Like every other cell edit, they are saved with the rest of the columns when the step is saved. How the grid treats the cells of a key column is on The table columns grid.

Change or clear a key

Questions, answered

How do I set a foreign key on a column?

In the FK cell of the column's row, in the table's Columns step: click the checkbox to open the picker, pick the relationship type and the target table, and close the picker to apply. Edit a table's columns covers the step itself.

What happens to the column when I set a key?

It takes the key's shape: it is renamed to the target table's name with Key appended, its relationship type becomes Many to One if none was picked, it is marked mandatory (M), and Data Domain and Data Type are set to LargeID and UInt64.

Do my choices apply right away, or when I close the picker?

They apply when the picker closes: that is when the type and the selected table are written to the row. As with every other cell, they are saved with the rest of the columns when the step is saved.

Can I change the relationship type after I set it?

Yes. Open the picker again and pick the other option; the change applies when the picker closes.

How do I clear a foreign key?

Open the picker, click the selected table again to deselect it, and close the picker. Removing the key resets the column's relationship type, its mandatory flag and its Data Domain and Data Type values.

Why did my column's name change?

Setting a key renames the column to the target table's name with Key appended. That is how the grid shows which table the column points at.

Why can't I find the table I need?

The picker loads its tables when it opens, and the search matches their names, ignoring capitalisation. When nothing matches, the list reads No table found. Names that differ only in capitalisation belong to different tables, so check the exact name.

What does the tick in the FK cell mean?

The column has a key: the checkbox is ticked while the column points at a table. Click it to open the picker and change or clear the key.

Why doesn't double-clicking the FK cell start an edit?

The cell keeps the grid's own click and double-click gestures away, so a click there does not select the cell and a double-click does not open an editor. Its checkbox is the control that opens the picker.