Import foreign keys via JSON

Upcoming Syntho feature

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

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:

[
   {
      "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.

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.

Last updated