I have this table in which I store comments. Every comment has its own ID and a isReply
column in case the comment is a reply to another comment. I was wondering if I could set a relation so that when a comment is deleted all comments that are replies to that comment are deleted automatically. I tried setting a foreign key to the isReply
column referencing comments.id
but I got this error:
#
1452 - Cannot add or update a child row: a foreign key constraint fails (_db
.#sql-1030_31f
, CONSTRAINT#sql-1030_31f_ibfk_1
FOREIGN KEY (isReply
) REFERENCEScomments
(id
) ON DELETE CASCADE ON UPDATE NO ACTION)