I'm pondering an issue that I can best describe as database auditing vs. database history. Consider 3 tables:
Country
CountryId
PostalAddress
PostalAddressId
CountryId
BankAccount
BankAccountId
PostalAddressId
Bank accounts have postal address that have country.
Now when a request to make a payment from an account comes in we need to store a snapshot of this hierarchy so that if an address changes for an account or more importantly the account number, we still have the address or account number at the time the payment was made for reporting purposes. So now we have:
PaymentHistory
PaymentHistoryId
BankAccountHistoryId
BankAccountHistory
BankAccountHistoryId
PostalAddressHistory
PostalAddressHistoryId
CountryHistory
CountryHistoryId
Another requirement is to provide an audit trail. I think the first inclination is to use the history table. Sounds like an obvious choice, but is it? I'm thinking this is mixing audit data with history data. When I see a foreign key relationship between non-history and history tables I feel that its wrong...
If a Country row changes, we should insert a row in the audit table but not the CountryHistory table, but should we insert a row in the history table(s) for every payment and fore go the logic required to check if the "current" history row is identical?
There is a clear separation in my mind between the history hierarchy I have here and auditing data. Have I just chosen bad nomenclature for what I'm calling the history hierarchy?
Have I explained the situation well enough? As I've typed this it seems obvious to me, but would love to hear some thoughts....