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

Primary Key Exception in Lookup

Hi,

I have two tables orders and customers,

I am trying to add the orders table as the lookup for the Order_Id column in Customers

My condition is Cust_Id=Ord_Cust_ID

I am getting a Primary Key Violation Error while Runningprimar.JPGmapping1.JPG

Labels (1)
2 Replies
TimGarrod
Employee
Employee

The customer table Key (Natural or business key) is customer_id.   By performing a lookup to orders - Compose will generate a left join - thereby creating multiple records with the same customer_id value.  Which then triggers the PK validation check.  (Multiple records for the NK). 

Can you explain a little further what you are trying to do here?   

Are you trying to get the last order_id for each customer or ? 

If you are trying to relate orders to customer - then the relationship should be defined on the order table (with customer as the parent).   This screenshot may show creating the relationship in the wrong direction ?

 

nikhilraorane65
Contributor
Contributor

Hi Ray,

You are getting this error as their is a one to many relation between Cust_Id and Ord_Cust_ID due to which cust_id which is the key in your table is getting repeated giving a primary key voilation detected.

As per my knowledge lookup here is doing a left join .

Regards,
Nikhil