# Import foreign keys via JSON

{% hint style="info" %}
**Upcoming Syntho feature**

This upcoming Syntho feature is intended for users who want to import foreign key relationships via a JSON file.
{% endhint %}

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: 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.syntho.ai/configure-a-data-generation-job/manage-foreign-keys/add-virtual-foreign-keys/import-foreign-keys-via-json.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.
