Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lifesound's avatar

what actually on delete cascade?

what actually on delete cascade did ?

will it delete from other tables??

0 likes
1 reply
kyxeo's avatar
kyxeo
Best Answer
Level 24

If you have a record on one (child) table that references an ID on another (parent) table via a foreign key, and it is set to "cascade" on delete, then if the record on the parent table is deleted it will also delete all of the corresponding records on the child table.

For example, if you have a posts table and a users table, and have user_id on posts referencing id on users, then when you delete a user it will "cascade" down to the posts table and delete all of their posts.

Please or to participate in this conversation.