Synthetic keys
When two or more internal tables have two or more fields in common, this implies a composite key relationship. Qlik Sense handles this through synthetic keys. These keys are anonymous fields that represent all occurring combinations of the composite key.
An increased number of composite keys can result in elevated memory usage, and can affect performance. This may also depend on data amounts, table structure, and other factors. Whenever there are several synthetic keys that are dependent on each other, it is good practice to remove them.
Now it is time to load our final set of data.
Do the following:
- Open the Data load editor in the Scripting Tutorial app.
- Click to add a new script section.
- Name the section Customers.
-
Under DataFiles in the right menu, click Select data.
- Upload and then select Customers.xlsx. The data preview window opens.
- Select Sheet1.
- Click Insert script.
- Click Load data.
- Open the Data model viewer.
Now you can see in the data load progress window that a synthetic keys was created.
We can see that a synthetic key has been created by seeing that a new table, $Syn 1 Table, has been created. It contains all the fields, Region and Region code, that the connected tables Sheet1 and Region have in common. In this case it makes the connections a bit confusing and misleading, so it is not desirable to keep.
Resolving synthetic keys
The easiest way to eliminate synthetic keys is to rename one or more fields in the tables. This can be done when loading the data. Now we will go through the steps of how to remove a synthetic key.
Do the following:
- Open the Data load editor.
- Click the section Customers and delete the row in the LOAD statement saying:
- Click Load data.
- Open the Data model viewer.
Region,
The synthetic key is has been removed.