Basie Blog

A Lightweight Software Development Portal in Django

Hide vs. Delete

with 3 comments

At the moment, Basie maintains referential integrity by disallowing deletes on most models. For some models (e.g. tickets), users are granted the option to “hide” specific instances (this is natural, since we would want to be able to dismiss tickets that we’re done with, but may want to recall past changes if new related issues come to light). For others (e.g. wiki pages), the objects remain visible indefinitely. Regardless, these models are being treated as “append-only” in the database. In the future, we may notice more delete-able models, but, as with most referential integrity related plights, we ran into problems when delete was involved.

Consider this problem encountered while trying to add tags to the Milestone model as reported by John Peters. Filtering out null values would be problematic, due to the fact that tags refer to arbitrary objects and, so, each content table for each model would have to be LEFT JOINed.

Two obvious options we are left with are a) make use of a primary key which never repeats values, regardless of who gets deleted or b) adopt the same conventions used throughout the rest of Basie. The question now is: do we ever want to permanently delete anything from the database? And, if so, could IncrementingField allow us this freedom?

In the meantime, for future generations of devs to whom this is applicable, if you want users to be able to remove an instance of your model, simply add a flag to indicate whether or not it should be displayed rather than sending it into the void.

Written by ilienert

December 22nd, 2009 at 11:41 pm

Posted in Database, Development

3 Responses to 'Hide vs. Delete'

Subscribe to comments with RSS or TrackBack to 'Hide vs. Delete'.

  1. [...] few more piled up to worry about in January—see, for example, Ian Lienert’s post about deleting vs. hiding, or Andrew Schurman’s look at why integrating with IRC is hard (short answer: channel [...]

  2. [...] Make sure that everything hides data instead of deleting data. [...]

  3. [...] bugs, tidying up Basie’s visual appearance, improving its performance, making sure that we hide things instead of erasing them, and so on. This isn’t as exhilarating as writing entirely new [...]

Leave a Reply