Sphere
Log in Join
☆ 8

Foreign key ON DELETE CASCADE or manual cleanup?

I have orders with order_items. Cascade is convenient but one accidental delete could wipe years of data. Is manual cleanup worth the complexity?

⚑ Report

3 replies

☆ 0
O Oskar ·2026-11-03#1

Cascade is fine when the child rows truly belong to the parent. The danger is when you add a foreign key to something you did not mean to cascade.

⚑ Report
☆ 0
P Priya ·2026-11-03#2

We need an audit trail even after deletion. Does that rule out cascade?

⚑ Report
☆ 0
A Aisha ·2026-11-03#3

Yes. Use soft delete on orders and keep cascade for genuinely dependent rows like items. Audit rows should never cascade with the business object.

⚑ Report
Log in to reply.