> For the complete documentation index, see [llms.txt](https://docs.syntho.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/key-generators.md).

# Key generators

Key generators control how primary key (PK) and foreign key (FK) values appear in generated data. They preserve referential integrity between related tables.

Choose **Duplicate**, **Generate**, or **Hash** based on whether you must preserve source values or relationships.

Choose a key generator based on how you need to handle key values and relationships.

| Generator | Description                                                                                                                                                               | When to use                                                                                                                                                                                    | When not to use                                                                                                                                                                                                                                                       |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Duplicate | Copies the original key values exactly as they appear in the source data, preserving both the correlations and referential integrity between primary and foreign keys.    | When it’s essential to maintain the original key values and relationships, particularly in de-identification scenarios where the data structure must be preserved without generating new keys. | Upsampling is not supported when using Duplicate, as the original keys are simply copied, not expanded. Additionally, it is not recommended when the keys are sensitive and need to be protected, as this method retains the original key values without obfuscation. |
| Generate  | Creates new, synthetic key values that do not correspond to the original keys. It preserves only the referential integrity, but not the correlations between key columns. | Use Generate for upsampling or creating synthetic datasets where there is no need to maintain relationships with the original data. It can also be used when creating data from scratch.       | The Generate function creates new keys independently of the original key order, which disrupts correlations. As a result, it is unsuitable for scenarios where maintaining the correlations and order is essential.                                                   |
| Hash      | Converts original key values into hashed representations. Both correlations between tables and relational integrity are maintained.                                       | Use Hash when you need to obscure the original key values, while ensuring correlations and referential integrity are preserved.                                                                | Upsampling, or situations where the original key values must be maintained for direct referencing, such as cases where exact key values are essential for business logic (e.g. country codes) or traceability in audit scenarios.                                     |

## Apply key generators

### Apply a generator to a key column

{% hint style="info" %}
Applying a key generator to any key column applies the same generator settings to all linked key columns. This preserves referential integrity.
{% endhint %}

1. Open **Column settings > Generator**.
2. Select **Duplicate**, **Generate**, or **Hash**.
3. Confirm the change.

<figure><img src="https://content.gitbook.com/content/U61B9DqtWCNO3Z30vnjh/blobs/bAWNqQSlEoN2rM7yUf8C/Screenshot%20(15).png" alt="Selecting a key generator in Column settings" width="563"><figcaption><p>Apply a key generator to a column.</p></figcaption></figure>

### Set the workspace default

{% hint style="info" %}
Column-level settings override the workspace default. For example, a column set to **Duplicate** overrides a workspace default of **Hash**.
{% endhint %}

1. Open **Edit workspace** from the **Saved workspaces** or **Configuration** panel.
2. Select **Default settings**.
3. Set the key generator to **Duplicate**, **Generate**, or **Hash**.

You can also use `CTRL + SHIFT + ALT + 0` to open **Workspace settings**. The selected generator applies to every key column without an override.

### Composite keys

Set the generator on any composite key column. Syntho applies it to every column in that composite key.

### Examples

The example below shows two composite keys. Each composite key uses one generator across its linked columns.

<figure><img src="https://content.gitbook.com/content/U61B9DqtWCNO3Z30vnjh/blobs/dWwBECLqncYC5dmyA0eW/compositeExample.png" alt="Composite key columns Birthdate and First"><figcaption><p>Composite key columns: Birthdate and First.</p></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/U61B9DqtWCNO3Z30vnjh/blobs/PRw7krihW3BZqHQI58Y0/compositeExample2.png" alt="Composite key columns Birthdate and Birthplace"><figcaption><p>Composite key columns: Birthdate and Birthplace.</p></figcaption></figure>

## Limitations

* **Generate** does not support composite foreign keys or columns referencing a composite key.
* Key generators do not apply to tables in **Exclude** mode.
* The same input produces the same output to preserve PK and FK links.
* Images and large binary objects do not support key generation.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/key-generators.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
