Primary and Foreign Keys

This chapter describes the Primary and Foreign Key capabilities of Virtual Tables and Views within Querona.

When importing source meta data any primary keys will be imported. Foreign keys will also be created for the tables if the referenced table is also being imported at the same time.

It is possible to create and edit primary and foreign keys after the meta data has been imported.

Primary and Foreign keys can be used by tools that connect to Querona to optimize queries. For this reason, it is also possible to create Primary and Foreign keys for Views also.

Primary and Foreign keys are constraints that are enforced within Querona. It ensures that the columns that are primary keys or are referenced by a foreign key column mapping cannot be deleted.

Primary Keys

Single or Multiple Column Primary Keys can be viewed in the Table & Views “Primary Key” section.

Primary Key View

Click Edit to modify the primary key columns for a table or view.

From here you can add or remove primary key columns from the table or view selected.

Edit Primary Key

Foreign Keys

Foreign Keys can be viewed in the Table & Views “Foreign Keys” section.

Foreign Keys are made up of one or more column mappings between the table/view selected and a reference table/view column.

Foreign Key View (Expanded)

To add a new Foreign Key click on the Add Foreign Key button and follow the steps provided.

Clicking on a foreign key in the list displays their summary and lists the column mappings in more detail:

Foreign Key Summary

From here you can delete a foreign key or chose to edit it, where you can add, remove, or edit existing foreign key column mappings.

Foreign Key Edit

Removing Columns with Constraints

In order to remove a column with Primary or Foreign key constraints, you must first remove these constraints. It is at the point of removing a column where information about any constraints is visible:

Remove column with Constraints

This page shows you whether the column is part of a primary key via the ‘Primary Key’ check box and a list of Foreign keys that the column is associated with. To find the table that ‘owns’ the foreign key see the table name listed under the ‘Foreign Key Table’ header.