5.3 Basic Versus Transaction Logging



There are two types of logging: basic and transaction. Basic logging records all file changes without regard to any meaning those changes might have. This provides a secondary backup of changes made after the last system backup. If you perform backups every night and your system goes down during the day, the basic logging allows you to restore your files up to the point of the system crash.

With some applications, this type of logging is not sufficient to restore a database to a consistent state. For example, in an accounting system, if the system crashes while adding an invoice, the total debits and credits entered into the system could be out of balance. To restore a database to a consistent state requires transaction logging.

Transaction logging groups file changes into transactions. For example, the addition of an invoice can be a transaction. Besides adding records to the invoice files, this transaction also updates customer balances, inventory balances, and general ledger account balances. All of these changes are considered part of adding the invoice.

When you restore a database, only completed transactions are restored. The actual rules are somewhat complicated, but the idea is that a transaction is considered complete if it was logged as completed and does not overlap a transaction that did not complete.