4 ms·
>On the other hand, "is deleted" flags end up causing issues when you forget to put "where not is_deleted" in your queries. My solution would be a view for eve
by dorgo 6y ago
>On the other hand, "is deleted" flags end up causing issues when you forget to put "where not is_deleted" in your queries.
My solution would be a view for every table. Are there drawbacks? Other solutions?
- capableweb 6y agoNot sure about drawbacks but another solution would be to change the point where you do the queries instead. So you have a "user" object that is largely saved the same as most other "crud" objects, so you have a layer for those, add the flag there.
- perl4ever 6y agoEh, the situation that I've been in, if I recall correctly, is that one has read/write access to all data for reporting, but not the ability to create views (or stored procedures etc) to share. Where I am now, (as far as Oracle goes) you can't even create your own tables under your own schema. A view requires a meeting with a DBA and their manager and really special, compelling arguments.
- lilyball 6y agoCan you just have a general policy where every table that has an is_deleted flag also automatically gets a view, and clients must use the view unless they have a particular need to access deleted data?
- dbbk 6y agoMost ORMs have built-in support for this. For example Laravel's Eloquent automatically filters out `deleted_at` records