Answer a question

The lead developer on a project I'm involved in says it's bad practice to rely on cascades to delete related rows.

I don't see how this is bad, but I would like to know your thoughts on if/why it is.

Answers

I'll preface this by saying that I rarely delete rows period. Generally most data you want to keep. You simply mark it as deleted so it won't be shown to users (ie to them it appears deleted). Of course it depends on the data and for some things (eg shopping cart contents) actually deleting the records when the user empties his or her cart is fine.

I can only assume that the issue here is you may unintentionally delete records you don't actually want to delete. Referential integrity should prevent this however. So I can't really see a reason against this other than the case for being explicit.

Logo

华为、百度、京东云现已入驻,来创建你的专属开发者社区吧!

更多推荐