Manage primary keys

When you set a foreign key to another table, you need to specify the primary key of the referenced table. This is required to create the table relationship. This also automatically sets a primary key if the referenced table did not already have one.

If necessary, you can manually set and remove primary keys for each table in a generator.

Set a primary key

You can set the primary key for any table regardless of the synthetic data use case (single-table, two-table, or multi-table).


  1. On the Data configuration page, click the Primary key drop-down for a table. MOSTLY AI - Set primary key
  2. Select the primary key column for the table.
  3. (Optional) Repeat for all tables.

Remove a primary key

To remove a primary key, hover over a table in the Primary key column and click the Remove primary key icon button.

MOSTLY AI - Remove primary key

If a foreign key references the primary key you want to remove, you will get a warning that this will break the existing relationship.

MOSTLY AI - Cannot remove primary key error