Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would treat the audit information separately from the actual domain information as much as possible. </p> <p><strong>Requirement #1:</strong> I think you will create additional audit tables to record the changes. Eric suggestion is a good one, creating the audit information using triggers in the SQL database. This way your application needs not be aware of the audit logic.</p> <p>If your database does not support triggers, then perhaps you are using some kind of persistence or database layer. This would also be a good place to put this kind of logic, as again you minimize any dependencies between <em>normal</em> application code and the audit code.</p> <p><strong>Requirement #2:</strong> As for showing the indicators: I would not create boolean fields in the table that stores the actual. (This would cause all sorts of dependencies to exist between your <em>normal</em> application code and your <em>audit trail</em> code.)</p> <p>I would try to let the code responsible for displaying the form also be responsible for showing audit data on field level. This will cause query overhead, but that is the cost for displaying this extra layer of information. Perhaps you can minimize the database overhead by adding metadata to the audit information that allows for easy retrieval.</p> <p>Some big Enterprisy application that I maintain uses roughly the following structure:</p> <ul> <li>A change header table corresponding to a change of a record in a table.</li> </ul> <p>Fields:</p> <pre><code>changeId, changeTable, changedPrimaryKey, userName, dateTime </code></pre> <p>- A change field table corresponding to a field that is changed.</p> <p>Fields:</p> <pre><code>changeId, changeField, oldValue, NewValue </code></pre> <p><strong>Sample content:</strong></p> <p>Change Header:</p> <pre><code>'1', 'BooksTable', '1852860138', 'AdamsD', '2009-07-01 15:30' </code></pre> <p>Change Item:</p> <pre><code>'1', 'Title', 'The Hitchhiker's Guide to the Gaxaly', 'The Hitchhiker's Guide to the Galaxy' '1', 'Author', 'Duglas Adasm', 'Douglas Adams' </code></pre> <p>This structure allows both easy viewing of audit trails as well as easy retrieval for showing the desired indicators. One query (inner join in the Header and Items table) would be enough to retrieve all information to show in a single form. (Or even a table when you have a list of shown Id's)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload