Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Synthetic keys

hello

What is the easiest way to get rid of syn keys?

For example if I use two data sources called db1 and db2. And both have name and surname, address and code.so in the load script you load both data sources

but qlikview show you have syn keys.

so should you use a concatenate? Or what is the best way to get rid of that?

11 Replies
oknotsen
Master III
Master III

Are they the same data? Join the tables or remove the double fields.

Are they not the same thing? Rename the fields; things that are not the same should not have the same name.

May you live in interesting times!
Saravanan_Desingh

It depends on your usage.

QUALIFY & UNQUALIFY is one kind of solution.

Chanty4u
MVP
MVP

Anonymous
Not applicable
Author

Read below:

  1. 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).

  1. e.g.

Qualify *;
turns qualification on for all field names of the subsequent table(s).

Qualify “*_Name”;
turns qualification on for all field names ending with _Name in the ssubsequent table(s).

Qualify “Name_*”;
turns qualification on for all field names Starting with Name_ in the ssubsequent table(s).

Qualify “Amt*”,Profit;
turns qualification on for Profit and all field names starting with Amt.

Qualify S???;
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:

Qualify *;

Unqualify C1;

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.

  1. 2. Autonumber

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.

  1. 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.

  1. 3. Aliasing

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.

Anonymous
Not applicable
Author

It means Qlik thinks there is multiple primary keys between tables you are importing - note that Qlik thinks two fields should be joined if they have the same name.

tyagishaila
Specialist
Specialist

There are many ways depends upon your requirement .

--  if both database have same field name than they concatenate automatically.

-- or you can concatenate by using concatenate keyword.

-- renaming field names.

-- by using qualify.

-- join tables.

Cheers.

avinashelite

easy way would be to RENAME the fields or use Qualify and UNQUALIFY

ahammadshafi
Creator
Creator

I am assuming that there is no relationship between the tables; easy way is to rename the columns or use Qualify and Unqualify.

A sample data would help understand better.

jagan
Luminary Alumni
Luminary Alumni

Hi,

To remove synthetic keys the following are the options

- Concateante Tables

- Link Table

- Renaming Fields

- Qualify

- Composite Key

- Joining the tables

Choosing the above options depends on the data, if you attach some sample data and your expected result then it would be easier to provide solution.

Regards,

Jagan.