#1452 - Cannot add or update a child row: a foreign key constraint fails (`Appian`.`#sql-alter-34ce-15086d9`, CONSTRAINT `table1_ibfk_2` FOREIGN KEY (`first_id`) REFERENCES `table2` (`first_id`))
What does this error mean?
Discussion posts and replies are publicly visible
shubhamy0001
Since you are getting this error while creating the relationship itself, I think your foreign key column contains values that are not present in the parent table as a primary key.
For example, let's say tableA is the parent table & the primary key column is colA. It contains 10 rows of data hence the primary key values are 1,2,3,4,5,6,7,8,9,10. Your child table is tableB & the foreign key column is colB. If the colB has values other than the present values such as 0 (or) greater than 10, then the database will not allow adding the constraint because it fails.
Try deleting such values from your child table & then perform this operation.