Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Luis_Fer0812
Partner - Contributor II
Partner - Contributor II

Link several tables with primary and foreign keys

Hi everyone, I have a basic doubt, first of all I have several tables that I have extracted from an excel file but these tables doesn't have Id fields in order to related between then so I decided to create these id fields, but how I can link one table with another. For example 

Table A,

primary key 

Table B

primary key

foreign key

 

how to set my primary key in the table A to the tabla B? 

6 Replies
jwjackso
Specialist III
Specialist III

Qlik will join tables based on field names and Qlik is case sensitive.  If the primary key for Table A was DEPTID and the primary key for Table B was DEPTID, Qlik would join the tables on DEPTID.

Luis_Fer0812
Partner - Contributor II
Partner - Contributor II
Author

I did what you mention but the problem is that I have many tables with the same key, and my model shows like this:  

TABLE A

ID_CAR

 

TABLE B

ID_CAR

 

TABLE C

ID_CAR

 

ArnadoSandoval
Specialist II
Specialist II

Hi @Luis_Fer0812 

What you do in these scenarios is create on alias for the conflicting column, by example

TABLE A
ID_CAR   As CAR_ID

TABLE B
ID_CAR   As B_CAR_ID

TABLE C
ID_CAR   As CAR_ID

TABLE D
ID_CAR   As D_CAR_ID

Tables A and C share the same CAR_ID column, then Qlik join them, while Tables B and D (and any other table) have their own CAR_ID column, if you do not like so many aliases, you can also use Qualify  to eliminate synthetic keys and your resolving the joins by renaming the required columns to a common name.

Hope this helps, 

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
Luis_Fer0812
Partner - Contributor II
Partner - Contributor II
Author

Maybe I did not explained very well, but the thing that I want is to load a Primary Key in another table, for example:

table CLIENT

ID_CLIENT

-

-

-

 

table ORDER

ID_ORDER

-

-

ID_CLIENT (I want lo load this field in this table)

 

I want to do in order to related them.

 

ArnadoSandoval
Specialist II
Specialist II

Hi @Luis_Fer0812 

Well, we will expect that to be a common field between Orders and Customers; How are Customers and Orders associated in the current application, prior to getting its data in Qlik's QVDs; How are they join at the backend database?

HTH

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
Luis_Fer0812
Partner - Contributor II
Partner - Contributor II
Author

Ok thanks, now I understand that the tables need to be related according to the common fields amount them. I thought that making an ID field was the only way to relate tables.