Discussion board where members can get started with QlikView.
Please go through Page 473 of QlikView Reference Manaual. It will give your fair idea about Synthetic key and it can be avoided in two ways.
1. Use Qualify
2. Use Alias
if more than one column linked between two tables its create sythetic key.
and you remove it using qualify/unqualify.
qualify all the fields
and unqulify the key field.
synthetic key creates synthetic tables in Contol +T(table viewer)
sythetic table tells you how many fields creates synthic key
hope this help
Hi At tude,
You can find more info about Synthetic keys in the QlikView manual.
The concept is, when you join two tables, it can be done based on primary key and foreign key relationship based on a particular column. We can treat it as a normal join between the two tables. The problem starts when the joining is on more than one columns.
The synthetic key scenario is when you have same column name for more than one columns between the loaded tables (e.g. C1 & C2 is common between Table 1 & Table 2). QlikView internally relates those tables based on the common column names and create another internal table (synthetic table) with the matching columns and a synthetic key generated by all possible combined values of the matching columns (C1, C2 and Synthetic Key column....starts with '$'). The impact could be a datamodel with unncessery jumble as well as wastage of memory. e.g. think of two tables with millions of rows. If they have synthetic keys between them, that would generate another table, with large number of rows...and completely unnecessery...finally, eating up memory. And a 'not so well' designed datamodel can of course lead to performance impact in terms of time, as you know.
Now, the question is, if you really want to get rid of the issue, how to fix it.
1. Using QUALIFY
This enforces QlikView to qualify all/selected fields. Qualify implements the check on full path of the field (e.g. Field is designated by Tablename.FieldName).
turns qualification on for all field names of the subsequent table(s).
turns qualification on for all field names ending with _Name in the ssubsequent table(s).
turns qualification on for all field names Starting with Name_ in the ssubsequent table(s).
turns qualification on for Profit and all field names starting with Amt.
turns qualification on for four character field names starting with S.
Ofcourse you don't always need to qualify ALL the fields of a table. E.g. you have C1 & C2, two common columns between Table 1 & Table 2. C1 is used to join the 2 tables and C2 is the column that you think might create Syn Key. You will do something like:
Select * from Table1;
Select * from Table2;
This will ensure that only C1 is used to join the two tables, eventually nullifying the possibility of Syn Key.
If you need to concat the Syn Key candidate fields and create your own key, you can use Autonumber/Autonumberhash128/Autonumberhash256 function. This will create a unique integer value for each distinct combination of the concateneted columns. Autonumberhash128 and Autonumberhash256 creates 128bit and 256bit values respectively.
E.g. In the previous example, autonumber(C1&C2) or autonumberhash128(C1,C2) or autonumberhash256(C1,C2) will create the necessery uniqueness.
One word of cauton using Autonumber is, as they are system generated, you do not have any control over the values. And for external QVDs, since the range of unique autonumber values are limited, uniqueness is not guranted. the hash128 and hash256 functions particularly address this issue and widens the range to ensure uniqueness.
If you alias the comflicting fields, i.e. the Syn Key candidate fields, they would be treated as different fields and will not be joined automatically by QV. This is a simple solution based on how flexible the requirements are, in renaming the fields.
Ofcourse you will find many other examples in this forum/QV manual that will strenthen your concept. This is my understanding from my experience with QV. Please let me know if it answers your question on my post.
When two or more input tables have two or more fields in common, this
implies a composite key relationship. QlikView handles this through synthetic
keys. These keys are anonymous fields that represent all occurring
combinations of the composite key. When the number of composite keys
increases, depending on data amounts, table structure and other factors,
QlikView may or may not handle them gracefully. QlikView may end up
using excessive amount of time and/or memory. Unfortunately the actual
limitations are virtually impossible to predict, which leaves only trial and
error as a practical method to determine them.
I think the best way to avoid Synthetic Keys is to (a) Rename the fields, (b) if you don't need the one of the field you delete it from your script.
When we load data into qlikview there could be occasions where the fields of two tables may be the same name. The qlikview creates associations when loading the data to make it easier to manipulate but it could cause a problem when there are more than one pair of matching fields in two tables.
Solution: As the guys have mentioned above, you should rename it using either alias or qualify.
If you use the alias you can give a field name of your choosing eg: DeliveryDate as OrderDeliveryDate.
If you use the qualify keyword it would append the table name and then the field name - <table_name>.fieldname.
As there is no chance of tables with similar names, the qualify keyword will be a preferred choice if there are may fields to be changed. However if there is only a handful of fields, then you can use the field aliasing.
Hope this helps!
Synthetic keys is a Complex Keys consisting of two or more fields connecting tables, Resource Heavy, May slow down calculations, Make a document harder to understand and maintain and Should be removed if possible.
How to Removed Synthetic keys:
- Renaming a fileds use( As) ex: Customer as %Customer
-Adding a Remarks or comment out unneccesary fields ex: // Customer,
Go through the below link you will get more insights on the raised topic.