Synthetic keys
Qlik Sense creates synthetic keys when two or more data tables have two or more fields in common. These keys are anonymous fields that represent all occurring combinations of the composite key.
If you receive a warning about synthetic keys when loading data, you should review the data structure in the data model viewer. You should ask yourself whether the data model is correct or not. Sometimes it is, but most times the synthetic key is there due to an error in the script.
Multiple synthetic keys are often a symptom of an incorrect data model. However, a sure sign of an incorrect data model is if you have synthetic keys based on other synthetic keys.
Handling synthetic keys
If you need to avoid synthetic keys, there are a number of ways of solving this in the data load script:
-
Check that only fields that logically link two tables are used as keys.
- Fields like “Comment”, “Remark” and “Description” may exist in several tables without being related, and should therefore not be used as keys.
- Fields like “Date”, “Company” and “Name” may exist in several tables and have identical values, but still have different roles (Order Date/Shipping Date, Customer Company/Supplier Company). In such cases they should not be used as keys.
-
Make sure that redundant fields aren’t used – that only the necessary fields connect. If for example a date is used as a key, make sure not to load year, month or day_of_month of the same date from more than one internal table.
-
If necessary, form your own non-composite keys, typically using string concatenation inside an AutoNumber script function.