If some standards apply when "it depends" then should I stick with custom approaches?

Posted by Travis J on Programmers See other posts from Programmers or by Travis J
Published on 2012-03-28T00:03:24Z Indexed on 2012/03/28 5:41 UTC
Read the original article Hit count: 494

If I have an unconventional approach which works better than the industry standard, should I just stick with it even though in principal it violates those standards?

What I am talking about is referential integrity for relational database management systems. The standard for enforcing referential integrity is to CASCADE delete. In practice, this is just not going to work all the time. In my current case, it does not. The alternative suggested is to either change the reference to NULL, DEFAULT, or just to take NO ACTION - usually in the form of a "soft delete".

I am all about enforcing referential integrity. Love it. However, sometimes it just does not fully apply to use all the standards in practice. My approach has been to slightly abandon a small part of one of those practices which is the part about leaving "hanging references" around. Oops. The trade off is plentiful in this situation I believe. Instead of having deprecated data in the production database, a splattering of "soft delete" logic all across my controllers (and views sometimes depending on how far down the chain the soft delete occurred), and the prospect of queries taking longer and longer - instead of all that - I now have a recycle bin and centralized logic. The only tradeoff is that I must explicitly manage the possibility of "hanging references" which can be done through generics with one class.

Any thoughts?

© Programmers or respective owner

Related posts about relational-database

Related posts about industry-standard