What does ON DELETE CASCADE do and when is it risky?

SQL keys and table design · Freshers and experienced

Model answer

When the parent row is deleted, rows that reference it are deleted automatically. It keeps data consistent but a single delete can remove a lot of data. For important records many teams prefer RESTRICT or soft deletes (a deleted_at column).

Learn this topic

Keys and Table Design: Why Data Is Split Into Tables in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions