A part of my table design would be to incorporate a IsDeleted BIT column that's set to at least one each time a user removes an archive. Therefore all Chooses are inevitable supported with a WHERE IsDeleted = condition.

I just read inside a previous question (I am unable to for that passion for God re-discover that publish and reference it) this is probably not the very best design as well as an 'Audit Trail' table may be better.

How's it going men coping with this issue?

Update I am on SQL Server. Solutions for other DB's are welcome although less helpful for me personally but maybe for some individuals.

Update2 Simply to encapsulate what everybody stated to date. There appears to become essentially 3 ways to cope with this.

  1. Let it rest because it is
  2. Create an audit table to keep an eye on all the new changes
  3. Utilization of sights with WHERE IsDeleted =

Therefore all Chooses are inevitable supported with a WHERE IsDeleted = condition.

This isn't an excellent method of doing it, while you most likely observed, it is extremely error-prone. You can produce a VIEW that is simply

CREATE VIEW myview AS SELECT * FROM yourtable WHERE NOT deleted;

Then you definitely only use myview rather than mytable and it's not necessary to consider this damn column in Chooses.

Or, you can move erased records to some separate "archive" table, which, with respect to the proportion of erased versus active records, will make your "active" table a great deal more compact, better cached in RAM, ie faster.

If you need to have this type of Erased Bit column, then you should consider establishing some Sights using the WHERE clause inside it, and employ individuals as opposed to the underlying tables. A smaller amount error prone.

For instance, for those who have this view:

CREATE VIEW [Current Product List] AS
SELECT ProductID,ProductName
FROM Products
WHERE Discontinued=No

Then someone who would like to see current items can easily write:

SELECT * FROM [Current Product List]

This really is a smaller amount error prone than writing:

SELECT ProductID,ProductName
FROM Products
WHERE Discontinued=No

While you say, individuals will forget that WHERE clause, and obtain confusing and incorrect results.

P.S. the example SQL originates from Microsoft's Northwind database. Normally I would suggest NOT using spaces in column and table names.

We are positively while using "Erased" column within our enterprise software. It's however a resource of constant errors when failing to remember to include "WHERE Erased = " for an SQL query.

Unsure what's meant by "Audit Trail". You may decide to possess a table to trace all erased records. Or there might be a choice of moving the erased content to paired tables (like Customer_Erased) to get rid of the passive content from tables to reduce their size and optimize performance.

Not long ago there is some blog uproar about this problem, Ayende and Udi Dahan both published about this.

For those who have Oracle DB, you'll be able to use audit trail for auditing. Look into the AUDIT VAULT tool form OTN, here. It even supports SQL Server.

Nai this really is totally your decision.

Must you have the ability to see that has erased / modified / placed what so when? If that's the case, you need to design the tables with this and adjust your procs to create these values when they're known as.

If you do not need an audit trail, dont spend your time with one. Simply do when you are with IsDeleted.

Personally, I flag things at this time, being an audit trail wasn't specified by my spec, but nevertheless, I tend not to really remove things. Hence, I selected to flag it. I am not likely to waste a clients time writing something they diddn't request. I wont mess about along with other tables because that's another factor that i can consider. I'd just make certain my index's were as much as the task.

Request your coworkers or client. Organize how lengthy the audit trail would take to allow them to cost it and allow them to decide for you personally )