Lesson 5. Transaction Processing
Lesson Objective
- Understand methods of capturing, selecting, managing and exchanging data.
- Understand Transaction Processing.
- Understand ACID (Atomicity, Consistency, Isolation, Durability).
- Understand what is meant by record locking and its importance in a multi-user database.
- Understand redundancy.
Lesson Notes
Capturing Data
Manual methods of data capture
Data from forms that are filled out by hand often need to be typed in manually
Automated methods:
- smart card readers
- barcode readers
- scanners
- optical character recognition (OCR)
- optical mark recognition (OMR)
- magnetic ink character recognition
- sensors
Transferring Data
Once data has been collected, it can be transferred to a database. This can be done...
- automatically, using the DBMS software
- by manually typing it in using a customised form
- by importing it from a spreadsheet or file
- by using EDI (Electronic Data Interchange) - this is used to transfer data between one computer system and another
EDI?
Electronic Data interchange (EDI) is the computer-to-computer exchange of documents such as purchase orders, invoices and shipping documents between two companies or business partners.
It replaces post, email or fax.
All documents must be in a standard format so that the computer can understand them.
EDI translation software may be used to translate the EDI format so the data can be input directly to a company database.
Selecting Data
Once data has been collected and stored in a database, we will need effective ways to find and retrieve it.
SQL is a common query language used to retrieval and database management. MS Access Query by Example are another example.
DBMS
A database management system (DBMS) is a software application that helps users store, organize, and access data. DBMSs are used in a wide variety of applications, including e-commerce websites, online banking systems, and social media platforms.
A DBMS serves as an interface between an end-user and a database, allowing users to create, read, update, and delete data in the database without dealing with underlying structure and complexities.
Transaction Processing
Information Gathered from IBM. Full website link here.
Transaction processing is a style of computing, typically performed by large server computers, that supports interactive applications.
In transaction processing, work (information processing) is divided into individual, indivisible operations, called transactions.
In the context of databases, a single logical operation is defined as a transaction.
ACID
ACID stands for Atomicity, Consistency, Isolation, Durability.
This is a set of properties to ensure that the integrity of the database is maintained under all circumstances. It guarantees that transactions are processed reliably.
Atomicity
This property requires that a transaction is processed in its entirety or not at all.
A change to the database is either completely performed or not at all. Half completed changes must not be saved back to the database.
Consistency
This property ensures that no transaction can violate any of the defined validation rules.
Referential integrity, specified when the database is set up, will always be upheld. This means any change in the database must retain the overall state of the database.
Isolation
The Isolation property ensures that concurrent execution of transactions leads to the same result as if transactions were processed one after the other. This is crucial in a multi-user database.
A transaction must not be interrupted by another transaction. The transaction must occur in isolation so other users or processes cannot access the data concerned.
A DBMS enforces isolation by implementing a system of recording locking.
Durability
This ensures that once a transaction has been committed, it will remain so, even in the event of a power cut or system failure.
As each part of a transaction is completed, it is held in a buffer on disk until all elements of the transaction are completed. Only then will the changes to the database tables be made.
Record Locking
What are potential problems with multi-user databases?
Allowing multiple users to simultaneously access a database could potentially cause one of the updates to be lost.
Example Situation:
- User A accesses a customer record and it is copied to their local storage.
- User A starts to alter the customer's address.
- User B accesses the same customer record, alters the credit limit and saves the record.
- User A completes the change of address, and saves the record.
- Alterations made by User B are then overwriten by the save of User A.
Record locking prevents simultaneous access to objects in a database in order to prevent updates being lost or inconsistencies in the data arising.
Using record locking, a record is locked when a user retrieves it for editing or updating. Anyone else attempting to retrieve it is denied access until the transaction is completed or cancelled.
What are problems with record locking?
If two users are attempting to update two records, a situation can arise in which neither can proceed, known as deadlock.
Example Situation:
- Ken is attempting to make a transfer from Customer A's account to Customer B's account. Meanwhile, Paula is attempting to make a transfer from Customer B's account to Customer A's account.
- Ken locks Customer A's record, Paula locks Customer B's record.
- Ken tries to access Customer B's record, Paula tries to access Customer A's record.
- Both are now waiting.
Serialisation
The Database Management System (DBMS) must prevent such situations (Deadlocks) from arising. Serialisation ensures that transactions do not overlap in time and therefore cannot interfere with each other or lead to updates being lost. An example of a serialisation technique would be Timestamp Ordering.
Timestamp Ordering:
In a database system, each object (such as a record or data entry) is associated with two timestamps: a read timestamp and a write timestamp. Here's how they work:
- Read Timestamp: Whenever an object is read (retrieved from the database), its read timestamp is updated. This timestamp reflects the last time the object was accessed.
- Write Timestamp: Whenever an object is written (updated or modified), its write timestamp is updated. This timestamp indicates the most recent modification time.
Consider a scenario where a user attempts to save an update to an object:
- The user initiates a transaction (e.g. updating a customer's address).
- If during the transaction the read timestamp of the object is not the same as it was when the user started the transaction:
- The Database Management System (DBMS) detects that another user has accessed the same object in the meantime.
- To maintain data consistency, the transaction is cancelled.
- The user receives a message indicating that the update was unsuccessful.
Redundancy
Many organisations cannot afford to have their computer systems go down for even a short time. Imagine the chaos if the air traffic control system goes down…
Organisations have built-in redundancy in their computer systems. Duplicate hardware, located in different geographical areas, mirrors every transaction that takes place on the main system.
If this fails, the backup system automatically takes over.