I have two tables:
TableY:
id, name, description
TableX:
id, name, y_id
I have added a foreign key in TableX
(y_id
I guess you got misunderstanding. Try to delete row from TableY
and corresponding rows from TableX
will be cascade deleted. This option is indispensable when you have secondary related tables and would like to clean them all by deleting parent row from primary table without getting constraints violated or rubbish left.