I'm working on an IoT project that involves storing data in a database.

Hi everyone, I'm working on an IoT project that involves storing data in a database. While writing the SQL code, I encountered the following error: "violated - parent key not found" I search everywhere, Has anyone else encountered this issue, or can anyone provide guidance on how to fix
attachment 0
Solution:
Thank you @jjbitnic👀 , actually i found that one of the FOREIGN KEY values in the REFERENCE Table does not exist in the Parent Table. I just Ensure that the ID value matches in both tables. ✅
Jump to solution
4 Replies
jjbitnic👀
jjbitnic👀•8mo ago
Check if the colums/fields in your query maych that of the table in database. What is the database vendor? Can you run the same query manually using native db client? Are you doing a select, update, or insert?
wafa_athmani
wafa_athmani•8mo ago
i am using MySQL, I am entering a values linked to a foreign key (FK)..
jjbitnic👀
jjbitnic👀•8mo ago
Sounds like a db issue with the query. I would approach this by trying with the mysql native client to see if it works there. There is a post on Stack Overflow that describes similar issue: https://stackoverflow.com/questions/69042788/im-repeatedly-getting-this-integrity-constraint-violated-parent-key-not-found
Stack Overflow
I'm repeatedly getting this "integrity constraint violated- parent ...
The problem goes like: I have 2 tables Employee and Department. Both tables have department_id and manager_id in them. I have a primary key employeeid in table employee and primary key department...
Solution
wafa_athmani
wafa_athmani•8mo ago
Thank you @jjbitnic👀 , actually i found that one of the FOREIGN KEY values in the REFERENCE Table does not exist in the Parent Table. I just Ensure that the ID value matches in both tables. ✅
Want results from more Discord servers?
Add your server