> 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/manage-foreign-keys/add-virtual-foreign-keys/import-foreign-keys-via-json.md).

# Import foreign keys via JSON

You can import a **JSON** file that contains foreign keys, to define the (virtual) key relationships in your workspace.

If you already have virtual foreign keys set up, they will be replaced by the keys contained in the uploaded **JSON** file.

To import a foreign key **JSON** file:

1. Head over to the **Foreign Keys** tab.
2. Select the **Upload foreign keys** button.
3. Use the **Browse** button to search for and select the JSON file you wish to upload.
4. After selecting the file, simply click **Import**.

The uploaded foreign keys will be added to the **Foreign Keys** list and any existing virtual foreign keys will be replaced.

The contents of **JSON** file would look like below:

```json
[
   {
      "apply":true,
      "fk_columns":[
         "FK_COLUMN_NAME"
      ],
      "fk_schema":"FK_SCHEMA_NAME",
      "fk_table":"FK_TABLE_NAME",
      "pk_columns":[
         "PK_COLUMN_NAME"
      ],
      "pk_schema":"PK_SCHEMA_NAME",
      "pk_table":"PK_TABLE_NAME"
   },
   {
      "apply":true,
      "fk_columns":[
         "FK_COLUMN_NAME"
      ],
      "fk_schema":"FK_SCHEMA_NAME",
      "fk_table":"FK_TABLE_NAME",
      "pk_columns":[
         "PK_COLUMN_NAME"
      ],
      "pk_schema":"PK_SCHEMA_NAME",
      "pk_table":"PK_TABLE_NAME"
   }
]
```

Users are required to configure the following parameters according to their needs:

* `apply`: If set to `false`, the foreign key will be added but not activated. If set to `true`, it will be activated.
* `FK_COLUMN_NAME`: The column that is designated as a foreign key.
* `FK_TABLE_NAME`: The table where the foreign key column is located.
* `FK_SCHEMA_NAME`: The schema containing the table with the foreign key.
* `PK_COLUMN_NAME`: The column that is designated as a primary key.
* `PK_TABLE_NAME`: The table where the primary key column is located.
* `PK_SCHEMA_NAME`: The schema containing the table with the primary key.

<figure><img src="https://content.gitbook.com/content/U61B9DqtWCNO3Z30vnjh/blobs/ygnuwCMrU3P90q7RMayA/illustration2.drawio.png" alt=""><figcaption><p>The direct influence of configuration "apply" in Syntho UI</p></figcaption></figure>

The description above elucidates how the "apply" configuration within the foreign key JSON file affects the process. If `apply` is set to `false`, the foreign key will be added but remain inactive, illustrated by an unchecked box. Conversely, if `apply` is set to `true`, the foreign key will be activated immediately upon upload.

Additionally, a subsequent illustration will guide the reader on locating schemas, tables, and columns within an example database, such as MySQL. This information is mirrored in the foreign key **JSON** file (import file), offering valuable insights for configuration.

<figure><img src="https://content.gitbook.com/content/U61B9DqtWCNO3Z30vnjh/blobs/FoThapGJ3UEdncCLy371/pic.png" alt="" width="375"><figcaption><p>MySQL hierarchy</p></figcaption></figure>


---

# 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/manage-foreign-keys/add-virtual-foreign-keys/import-foreign-keys-via-json.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.
