I am designing a system and I don’t think it’s a good idea to give the ability to the end user to delete entries in the database. I think that way because often then end user, once given admin rights, might end up making a mess in the database and then turn to me to fix it.
Of course, they will need to be able to do remove entries or at least think that they did if they are set as admin.
So, I was thinking that all the entries in the database should have an “active” field. If they try to remove an entry, it will just set the flag to “false” or something similar. Then there will be some kind of super admin that would be my company’s team who could change this field.
I already saw that in another company I worked for, but I was wondering if it was a good idea. I could just make regular database backups and then roll back if they commit an error and adding this field would add some complexity to all the queries.
What do you think? Should I do it that way? Do you use this kind of trick in your applications?
In one of our databases, we distinguished between
transactionalanddictionaryrecords.In a couple of words,
transactionalrecords are things that you cannot roll back in real life, like a call from a customer. You can change the caller’s name, status etc., but you cannot dismiss the call itself.Dictionaryrecords are things that you can change, like assigning acityto a customer.Transactionalrecords and things that lead to them were never deleted, whiledictionaryones could be deleted all right.By “things that lead to them” I mean that as soon as the record appears in the business rules which can lead to a
transactionalrecord, this record also becomestransactional.Like, a
citycan be deleted from the database. But when a rule appeared that said “send anSMSto all customers in Moscow“, the cities becametransactionalrecords as well, or we would not be able to answer the question “why did thisSMSget sent”.A rule of thumb for distinguishing was this: is it only my company’s business?
If one of my employees made a decision based on data from the database (like, he made a report based on which some management decision was made, and then the data report was based on disappeared), it was considered OK to delete these data.
But if the decision affected some immediate actions with customers (like calling, messing with the customer’s balance etc.), everything that lead to these decisions was kept forever.
It may vary from one business model to another: sometimes, it may be required to record even internal data, sometimes it’s OK to delete data that affects outside world.
But for our business model, the rule from above worked fine.