For reasons at work I am currently looking into how storing and retrieving data from databases works. Was introduced to an abbrivation that I didn't know of earlier, ACID. ACID is a combination of Atomicity, Consistency, Isolation, and Durability.
- Atomicity - requires each transaction to be "all or nothing". A transaction may consist of several writes to the database, however, if any of these fail, or is interrupted, the entire transaction must be invalidated in order to have the database in a valid state.
- Consistency - requires that any transaction will bring the database from one valid state to another. No transactions may currupt the database.
- Isolation - ensures that concurrent transactions results in a system state that would be obtained if they were executed sequentially. Read that sentence again, it is a tricky one. Be able to perform concurrent transactions in a way that the result is like they have been done sequentially...
- Durability - ensures that a transaction, once commited, will remain so even if the power is lost, something crashes, some other error occurs.
One technique for providing the A and D (atomicity and durability) is Write-ahead logging (WAL). With this tecnique all modifications to the database is written to a log before being applied. The log usually contains both redo and undo information. When recovering from a power loss the log can be compared to the actual contents of the database to determine where in the execution the power was lost. That information can then be used to determine if and how to roll back, finish any interruptad transactions, or leave the database in the state it was when the power was lost.
That pretty much sums up what I have been learning about databases today. More reading on the topic tomorrow (and hopefully some implementation).
Databaser är kul! :)
SvaraRadera