Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

>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?



Eh, 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.


Can 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?


Not 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.


Most ORMs have built-in support for this. For example Laravel's Eloquent automatically filters out `deleted_at` records




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: