Delete post results in “Cannot delete or update a parent row: a foreign key constraint fails”

Your MySQL table structure creates a reference and constraint relationship between your wp_product table and wp_posts. MySQL is doing exactly what you have instructed it to do. In this case, preventing you from deleting a record in wp_posts that is ‘related’ to records in your wp_product table.

In a nutshell, this is what foreign keys are supposed to do; maintain data integrity. Therefore you cannot delete a row in wp_posts while a corresponding/related record exists in wp_product.

I’d suggest taking a look at the MySQL documentation on Using FOREIGN KEY Constraints. Per your comments below I’d suggest looking at ‘Referential Actions’ to set the action to CASCADE.

Review the linked documentation to drill down to the specifics that match your requirements.