Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
amafrici
Contributor
Contributor

Cannot add or update a child row: a foreign key constraint fails

Cannot add or update a child row: a foreign key constraint fails (`db_derivato_aziende`. 'fact_investimento' ,CONSTRAINT `id_anno` FOREIGN KEY (`id_anno`) REFERENCES `dim_anno_investimento` (`id_anno`)).

I want to load my facts table but it gives me this error i dont know why, can someone help me please ?

I'm attaching pictures of my fact table fact_investimento and my dimension table dim_anno_investimento.

I'm attaching also a picture of the job that I lanched and a picture of tMap that I used.

Labels (3)
4 Replies
iamabhishek
Creator III
Creator III

So your error "Cannot add or update a child row: a foreign key constraint fails" essentially means that, you are trying to add a row to your `db_derivato_aziende`. 'fact_investimento' table for which no matching row (`id_anno`) is present in `dim_anno_investimento` table.

You must first insert the row to your `dim_anno_investimento` table.

amafrici
Contributor
Contributor
Author

Hi, actually there are rows in my 'dim_anno_investimento` table, as you can see in the photos. So I don't know what is the problem.

iamabhishek
Creator III
Creator III

Yes, but what you are trying to insert that specific row(key - id_anno) is not present in the 'dim_anno_investimento` table.

Could you give an example - on what you are trying to insert here or are you able to perform the insert when you try through database ide tool and it fails only on Talend?

amafrici
Contributor
Contributor
Author

It fails only on Talend. Do you know an alternative solution to solve this problem?