Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Fk (Constraint error) - "Cannot add or update a child row"

Hi, everyone! Did anyone ever come across this problem? I'm trying to insert data into my dw.

I already disabled my FKs on my data warehouse. But it won't go anyways.

 

Here's the error:

 

Cannot add or update a child row: a foreign key constraint fails
(`dw_bi_web`.`fact_lancamento_contabil`, CONSTRAINT `fk_fact_lancamento_contabil_dim_conta_contabil1`
FOREIGN KEY (`dim_conta_contabil_sk_conta_contabil`)
REFERENCES `dim_conta_contabil` (`sk_c) [statistics] disconnected Job carga_fato_contas ended at 11:11 12/04/2018. [exit code=0]

 

 

Thanks!

Labels (2)
17 Replies
Anonymous
Not applicable
Author

Hello,

Could you please clarify in which Talend version/edition you are?

Best regards

Sabrina

manodwhb
Champion II
Champion II

@isadoralmeida06,this is DB related issue.

 

Foreign key relationships involve a parent table that holds the central data values, and a child table with identical values pointing back to its parent. The FOREIGN KEY clause is specified in the child table.

 

It will reject any INSERT or UPDATE operation that attempts to create a foreign key value in a child table if there is no a matching candidate key value in the parent table.

 

Please check the the vaule which you were instering or updating in `dw_bi_web`.`fact_lancamento_contabil` are presnt in `dim_conta_contabil`.

TRF
Champion II
Champion II

@isadoralmeida06, did you use drop contraint for this foreign key too?
@manodwhb, it's a good practice to give URL when copying part of text from elsewhere.
TRF
Champion II
Champion II

@isadoralmeida06, did this help you?

If so, thank's to mark your case as solved (Kudos also accepted).

Anonymous
Not applicable
Author

Hi

@TRF and @manodwhb

Basically, yes it does have an fk  in my child table, but the problem is, it should be working.
So I have a field on my parent table (item) from my data warehouse called "item_description" which is a long string, e.g : "1-The car was cleaned on time.".
And then on my database (origem), I have a table that have this same column with exact same rows  "1-The car was cleaned on time." and then when I do mapping, it gives me the FK error, and when i dropped my FK constraint, it says that my sk is null, so my fact table has all NULLs on the item_sk.

 

Does anyone know how to make talend get it that if a text is equal to the other, get the correspondent SK?

All my other maps are working, but the matches are between, few words or number.

Anonymous
Not applicable
Author

Totally agree. But there are matches. All the values that I have, there's a specific match on my dimension table.
TRF
Champion II
Champion II

Can you share your tables definition?

What if you try to do same from SQL, not from a Talend job?

Anonymous
Not applicable
Author

Like an inner join? I'll try!
Anonymous
Not applicable
Author

It works on my database. But all the project is on talend, cuz that's what my client wants.  Anyways, I managed to work around it a couple of days ago,but I wish I could get it fixed by the BI rules, you know. Trought the Surrogate key. But I'll leave like this for now.

 

Thanks!