Chado Audit Module
The Audit module is not a module in the same sense as the other Chado modules. It is a set of recommendations on how one might implement auditing in Chado. This documentation describes an example of such an implementation which is in use at FlyBase. The SQL used at Flybase is
We consider the implementation of auditing policy as a database administration issue and subject to the local requirements of specific database groups. We therefore have not developed a detailed audit module, providing instead this policy statement.
Database project groups who would use chado as their primary DBMS would be well advised to implement as robust and detailed an audit trail as possible, while groups who would use chado more informally, for instance primarily as a read-only resource, may have no need for auditing.
We here describe how auditing will be implemented at FlyBase, where chado will serve as the primary DBMS.
Auditing will be implemented in a separate, orthogonal database to the chado, with each chado table having a corresponding shadow audit table which will include all of the columns of the chado table, plus these additional columns:
transaction_date TIMESTAMP NOT NULL transaction_type CHAR NOT NULL </sql> WHERE ''transaction_type'' VALUE IS one OF: * i (insertion) * u (UPDATE) * d (deletion) Thus an chado db instance chado.1 containing a TABLE ''gene'', FOR example: <syntaxhighlight lang="sql"> CREATE TABLE gene ( gene_id serial NOT NULL, PRIMARY KEY (gene_id), name VARCHAR(255) NOT NULL, dbxref_id INT, FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id), UNIQUE(name), UNIQUE(dbxref_id) ); </sql> Would have a corresponding audit DATABASE, chado.1_audit, containing a shadow audit TABLE, ''gene_audit'': <syntaxhighlight lang="sql"> CREATE TABLE gene_audit ( gene_id serial NOT NULL, PRIMARY KEY (gene_id), name VARCHAR(255) NOT NULL, dbxref_id INT, FOREIGN KEY (dbxref_id) REFERENCES dbxref(dbxref_id), UNIQUE(name), UNIQUE(dbxref_id), transaction_date TIMESTAMP NOT NULL, transaction_type CHAR NOT NULL ); </sql> ===TRANSACTION USE Cases=== ====Insertion OF a NEW Record==== WHEN a record IS intially inserted INTO an chado TABLE, the same record IS inserted INTO the corresponding shadow audit TABLE, WITH the CURRENT TIMESTAMP AND ''transaction_type'' = 'i'. ====UPDATE OF an Existing Record==== WHEN a record IS TO be updated, BEFORE the UPDATE TRANSACTION IS executed IN chado, the existing chado record IS copied TO the corresponding shadow audit TABLE, WITH the CURRENT TIMESTAMP AND ''transaction_type'' = 'u'. The UPDATE TRANSACTION IS THEN executed IN chado. ====Deletion OF an Existing Record==== WHEN a record IS TO be deleted, BEFORE the DELETE trasaction IS executed IN chado, the existing chado record IS copied TO the corresponding shadow audit TABLE, WITH the corrent TIMESTAMP AND ''transaction_type'' = 'd'. The DELETE TRANSACTION IS THEN executed IN chado. ===Implementation Issues=== The benefit OF this system IS that it allows a certain amount OF "time travel", OR the ability TO reconstruct the DATABASE TO its state at a particular TIME IN the past. We don't anticipate making this functionality available to the general user population, but recognize that from a database programming point of view, it is often quite useful, and sometimes vital, for a programmer to be able to track changes in the database in detail. While the auditing policy described here fulfills all of our auditing requirements in principle, it remains to be seen how it will work in practice. The size of the shadow audit database may become an issue over time. How the handling of audit transactions will affect overall database transaction performance is also unknown. FlyBase makes a practice of reporting certain audit details to the public (e.g. date entered and date last updated of gene records) - it is not know whether implementing this will be too expensive using this shadow audit db method ===Listing of MODs' Implemented Audit Tracking Systems=== A listing OF instances OF audit tracking systems implemented BY different MODs IS provided [[audit_tracking_by_mods | here]]. [[Category:Chado Modules]]