Transaction Processor: Dibyojyoti Bhattacharjee
Transaction Processor: Dibyojyoti Bhattacharjee
Dibyojyoti Bhattacharjee
1
Master and Transaction
Data
• Mater data are those data that generally
does not change with time.
• However, the transaction data can change
from time to time.
• Examples for master data can be employee
number, employee name etc.
• Examples of transaction data can be
number of days in a month in which a given
employee was present, deduction in salary
due to loan etc.
2
Master and Transaction
data..
• The master data and transaction data are
kept in separate files.
• Some times it may be necessary to read
both the files for making a report.
• For example, while preparing the payroll of
its employees both the master file and the
transaction file needs to be processed.
• The data is extracted after matching the
records from both the files for the same
employee number and is used to prepare
the pay roll.
3
Transactions
• A transactions is a set of operations that
must be performed completely or not at all.
• For example if Rs. 100 is to be transferred
from one account to another it should be
debited from one and credited to the other.
• If the two activities are done together the
transaction is complete.
• If any one of them is performed it will lead
to chaos.
4
Transaction in DBMS
• DBMS supports the concept of transactions
and thus allows data integrity.
• All transactions in DBMS takes place
between two instructions viz. Start-
transaction and End-transaction.
• Start-transaction denotes the beginning of
transaction
• End-transaction denotes the end of it.
5
Transaction in DBMS…
• All the necessary database updates
between these two should be treated as
atomic.
• If the transaction goes through all these
problems it is committed.
• However, if it does not go through then the
operation is rolled back.
• That is if the debiting the account is
successful but crediting the corresponding
account fails then the complete transaction
rolls back.
6
How Roll Back and Commit are
done technically?
• Whenever there is any change in the data base a
log keeps record of the chronological list of
database changes.
• Such records are called as before image record.
• When a transaction needs to be rolled back the
DBMS simply reads all the before image records
from that transaction from the log and applies them
to the database.
• For committing a transaction, the DBMS might
discard all the before image records.
7
For example
• When Rs. 100 are transferred from one
account to another DBMS writes the
record as it was before without
subtracting Rs. 100 from its balance in
the log file, and then changes in the
database.
• Now if the transfer is aborted then DBMS
simply takes the before image record of
the account and write it to the database
and take it to its original state.
8
Concept of Transaction
• To help a program to achieve its objectives.
• A transaction enabled program means that it
would execute as a logical unit of work.
• This prevents the database from reaching an
inconsistent state.
• If there is some difficulties in implementation
of the program, rollback operation is
performed and the program is terminated.
• It takes the program from one consistent
state to another.
9
Transaction Processing
Monitor
• Various types of problem may appear
during the execution of a program like
power failure, crashing of hard disc, non-
numeric data error, memory error and so
on.
• A transaction processing monitor provides
for a next best option. It is a special
program that looks after transaction
processing in a DBMS.
• It ensures the all-or-none operation.
10
Continued…
• When the TP Monitor sees a commit statement it informs the
DBMS that the database is a consistent state, and ask the
DBMS to make necessary updates in the physical database.
• However, if it encounters a roll back statement the TP
Monitor instructs the DBMS to undo all the changes made as
a part of the transaction.
• Remember, when the DBMS makes changes permanent to
the database, actual changes may not take place in the
tables but the DBMS guarantees that the updates would not
be lost.
11
Limitations of TP Monitor
Updated data
• It may so happen that in a database
instruction is sent to compute the salary of ten
employees.
• An error is committed after the salary of five
employees are calculated.
• Thus five values remains updated while five
others are not.
• TP monitor provides no guarantee against
such atomicity.
13
Properties of Transaction
• Transactions are said to depict ACID
Properties
• A → Atomic
• C → Consistent
• I → Isolation
• D → Durable
14
ATOMI
C
• A transaction is atomic in nature.
• It means that it executes exactly
once.
• It ensures that either all the updates
to the data base are complete
successfully or are not implemented
at all.
15
Consiste
nt
• A transaction ensures that a database
is in a consistent state after it
completes.
• A database remains consistent at the
start of the transaction and also
remains consistent at the end of the
transaction.
• In between start transaction and end
transaction it may not be consistent.
16
Isolation
• A transaction should remain in
isolation from other transaction.
• In a big database there can be
several ongoing transaction at the
same time.
• One transaction does not meet the
intermediate state of the other
transaction.
17
Durable
• A transaction is a unit of recovery.
• If a transaction is successful, its
updates persists even if there is some
sort of system crush or other kind of
problem.
• If a transaction fails the system is
guaranteed to be in the same state as
it was.
18