Transaction processing is any form of information processing, divided into individual and indivisible operations labelled transactions.
Each transaction must either succeed or fail as a complete unit.
Data Interchange
Data interchange is handled by the Electronic Data Interchange (EDI), which handles the computer-to-computer exchange of documents, i.e., purchase orders, acting as a replacement for email, fax, post, etc.
Data Integrity
To ensure Data Integrity is kept when using transaction processing, database management systems (DBMS) must conform to ACID (required properties for all database transactions):
- Atomicity - a change is either completely performed or not at all
- Consistency - any change must retain the overall state of the database
- Isolation - a transaction must not be interrupted by another
- Durability - once a change has been made to a database, it cannot be lost due to system failure
Isolation is typically enforced by record locking. When a record is locked, they are in an effective read-only state which is unlocked upon transaction competition.
Durability is typically achieved by ensuring the transaction effects are immediately written to permanent secondary storage, rather than being simply held in memory.
Record Locking
Record locking is the process of effectively making a record read-only. It prevents simultaneous access to objects in order to prevent inconsistencies or the loss of data.
Deadlocks
If two users are attempting to update two records, a situation can arise in which neither can proceed, known as deadlock.
Example
A transfer is being made from customer A to customer B.
Customer A’s record is locked, modified
Query waits for customer B’s record to be unlocked in order to modify
At the same time, a transfer is being made from customer B to customer A.
Customer B’s record is locked, modified
Query waits for customer A’s record to be unlocked in order to modify
In this situation, neither can proceed as they are indefinitely waiting upon each other to finish.
Serialisation
Deadlocks are then solved by serialisation which ensures that transactions do not overlap in time and therefore cannot interfere with each other or lead to updates being lost.
Two techniques for serialisation include:
- Timestamp ordering
- Commitment ordering
Timestamp Ordering
Each object in the database has both a read timestamp and a write timestamp, which are updated whenever either is triggered.
Commitment Ordering
Each transaction is ordered in terms of their dependencies on one another as well as the time they were initiated.