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

how to create composite key

i have been working on making a data model for the northwind database. i am stuck at a point of removing synthetic keys. the thing is i don't know exactly about the composite key. can anyone please tell how to apply composite key and what should be its syntax?

18 Replies
its_anandrjs

Then load a script like

Sol:

Tab1:

Country&'-'&Region as Key    //Composite key,

Country as Tab1_Country,

Region as Tab1_Region

Sales,

Products

From --------------;

Tab2:

Country&'-'&Region as Key   //Composite key,

Country as Tab2_Country,

Region as Tab2_Region

Customer,

Outstanding

From --------------;

Rename this two fields in the table

Not applicable
Author

You can rename those fields

ex:

In Tab1:

Country as Tab1_Country

Region as Tab1_Region

In Tab2:

Country as Tab2_Country

Region as Tab2_Region

or

You can keep Country and Region as it is from any one table.

Now all your fields are unique except Key field(composite key) and relation ship exists between your 2 tables based on this

muniyandi
Creator III
Creator III

Hi,

Tab1 & Tab2 both are common field. i want select common single column in listbox.

Regards,

Muni

its_anandrjs

In Tab1 & Tab2 not all fields are common in above suppose they are same

Eg:-

Tab1:

Country&'-'&Region&'-'&Sales as Key    //Composite key,

//Country as Tab1_Country,

//Region as Tab1_Region

//Sales

From --------------;

Tab2:

Country&'-'&Region&'-'&Sales as Key   //Composite key,

//Country as Tab2_Country,

//Region as Tab2_Region

//Sales,

From --------------;

After loading this two tables concatenate to each other and give single table with key field

muniyandi
Creator III
Creator III

i want county,region,sales field in list.

user want select list box to filter purpose.

MK_QSL
MVP
MVP

Please check enclosed file having dummy data which can help to understand how synthetic key/table can be removed using Link Table approach.

UPDATE : You can check the table structure by CTRL + T

Hope this helps...

robert99
Specialist III
Specialist III

http://community.qlik.com/blogs/qlikviewdesignblog/2013/04/16/synthetic-keys

I like synthetic keys in some circumstances. As long as I have planned to use them. For example I joined the three main tables together in a service company using a synthetic key

The call table (call_num) and field service visit table number (call_Num & FSR_Num) with the revenue charges lines (call_Num & FSR_Num & FSRL_Num)

This was tidier and the saved file was smaller than when I used a composite key

Not applicable
Author

Hi Anand,

I have got nothing common from the table which i want to add in Data model.Can u help as how to use Composite key on that.Same data as in discussion.

Table Name:Sales Reports

Fields:ID,Display,GroupBy,Title,Filterrowsource.

Mahamed_Qlik
Specialist
Specialist

Hi ,

Is it necessary to add any separation symbol in between?

For example in your case you are using the separation symbol "-".

What if I directly create the key as -

Sol:

Tab1:

Country&Region as Key    //Composite key

Sales

Products

From --------------;

Tab2:

Country&Region as Key   //Composite key

Customer,

Outstanding

From --------------;

Regards,

Mahamed