ms access - Audit table design suggestions -
is correct approach? suggestions make better?
below screenshot of employee table , shadow table
tl_name,deptfields may change , using shadow table track changes.records inserted/updated in main table , gets copied shadow table of data macro.
all records in shadow table have approved/rejected superuser
main table have updated alignment , shadow table have entire history of changes employee.
when record added/updated in main table via userform, copy of record created in shadow table has approved admin.
when record added/updated in main table via userform,
is_activefield set false , once approved admin updated true.
as understand requirements:
- changed/inserted data should visible everyone, visible flag un-approved data.
- this reasonable, if work under assumption majority of changes correct , approved (hopefully true ;) ).
i think missing:
- if change rejected, data in main table should automatically reverted recent approved state.
- otherwise main table stays in (sort of) undefined state forever,
is_active = false, (apparently) wrong data.
this can done audit table design. find latest approved entry emp pk, , use data.
but if number of columns audited may change in future, might consider approach 2 tables, in project: https://autoaudit.codeplex.com/documentation
auditheader table
this table inserted 1 row everytime 1 record inserted, updated or deleted in table has been setup use autoaudit system.
auditdetail table
this table related auditheader , inserted 1 row each column changed during insert or update operation , each column during delete operation.
if save old + new values every change, can revert "old" state current audit entry.
and structure change of main table (or if decide e.g. users can edit emp_name too) doesn't need structure change of audit table, because every audited column in main mapped row in auditdetails instead of column.
edit: additional advantage:
in sample data have marked changed values in red. access table doesn't work that. if want keep information ("which column(s) edited?"), need additional column in audit table.
this covered auditdetail, since contains each change old + new value.

Comments
Post a Comment