# 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](https://docs.tonic.ai/app/generation/generators/generator-characteristics/consistency) (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](https://docs.tonic.ai/app/generation/generators/generator-characteristics/generators-fpe).

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 [foreign-keys](https://docs.tonic.ai/app/generation/foreign-keys "mention").

## 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](https://docs.tonic.ai/app/generation/generators/generator-reference/alphanumeric-string-key)
* [ASCII Key](https://docs.tonic.ai/app/generation/generators/generator-reference/ascii-key)\
  \
  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](https://docs.tonic.ai/app/generation/generators/generator-reference/iban)
* [Integer Key](https://docs.tonic.ai/app/generation/generators/generator-reference/integer-key)
* [Numeric String Key](https://docs.tonic.ai/app/generation/generators/generator-reference/numeric-string-key)
* [UUID Key](https://docs.tonic.ai/app/generation/generators/generator-reference/uuid-key)

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

In addition to the key-specific generators, you can also assign the [Character Substitution](https://docs.tonic.ai/app/generation/generators/generator-reference/character-substitution) generator to a primary key column.

You can also assign the [Regex Mask](https://docs.tonic.ai/app/generation/generators/generator-reference/regex-mask) and [Conditional](https://docs.tonic.ai/app/generation/generators/generator-reference/conditional) 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/generation/generators/generator-types/primary-key-generators.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
