> For the complete documentation index, see [llms.txt](https://docs.tonic.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tonic.ai/app/generation/generators/generator-types/primary-key-generators.md).

# Primary key generators

Generators that are applied to primary key columns are different from other generators in the following ways:&#x20;

* The generated data must be unique in order to not break constraints&#x20;
* The generators are [consistent](/app/generation/generators/generator-characteristics/consistency.md) (same input → same output), so that when this generator is applied to a primary key column and its linked foreign key columns, no links are broken.&#x20;

This is accomplished using [format preserving encryption](/app/generation/generators/generator-characteristics/generators-fpe.md).

For more information on this, and details on how to provide your own encryption key, contact <support@tonic.ai>.

## How generators on primary keys are applied

You apply a primary key generator in the same way as you do any other generator.

Tonic Structural then automatically applies the same generator to all foreign key columns that reference the primary key.

Foreign keys are either defined by the source schema or added from the **Foreign Key Relationships** page. For more information, go to [Viewing and adding foreign keys](/app/generation/foreign-keys.md).

## Supported generators for primary key columns <a href="#primary-key-generator-support" id="primary-key-generator-support"></a>

Structural currently supports the following generators for primary key columns:

* [Alphanumeric String Key](/app/generation/generators/generator-reference/alphanumeric-string-key.md)
* [ASCII Key](/app/generation/generators/generator-reference/ascii-key.md)\
  \
  The ASCII Key generator does not preserve the format of the input value. It uses the ASCII alphabet for input and the alphanumeric alphabet for output. This leads to output values that are longer than the input values.
* [IBAN](/app/generation/generators/generator-reference/iban.md)
* [Integer Key](/app/generation/generators/generator-reference/integer-key.md)
* [Numeric String Key](/app/generation/generators/generator-reference/numeric-string-key.md)
* [UUID Key](/app/generation/generators/generator-reference/uuid-key.md)

If you need support for additional types, contact <support@tonic.ai>.

In addition to the key-specific generators, you can assign the following generators to primary key columns:

* [Character Substitution](/app/generation/generators/generator-reference/character-substitution.md)
* [Finnish Personal Identity Code](/app/generation/generators/generator-reference/finnish-personal-identity-code.md)

You can also assign the [Regex Mask](/app/generation/generators/generator-reference/regex-mask.md) and [Conditional](/app/generation/generators/generator-reference/conditional.md) generators to primary key columns. However:

* Make sure that the configuration preserves the uniqueness of your primary key values.
* Do not use these generators on primary key columns that are used for subsetting.


---

# 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.tonic.ai/app/generation/generators/generator-types/primary-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.
