SlideShare a Scribd company logo
1 of 47
Unit – 4
Chapter - 8
Transaction Processing
Concepts
INTRODUCTION
• Transaction processing system are systems with large databases and hundreds of
concurrent users that are executing database transactions.
• EX: System for reservations, banking, Credit card processing, stock markets,
supermarket checkout, and other similar systems.
• They require high availability and fast response time for hundreds of concurrent
users.
• In this chapter we present the concepts that are needed in transaction processing
system.
Transaction Processing Concepts
Transaction
A transaction is the basic logical unit of execution in an information system. A
transaction is a sequence of operations that must be executed as a whole, taking a
consistent (correct) database state into another consistent (correct) database state.
A transaction is a discrete unit of work that must be completely processed (or) not
processed at all.
Ex: Transferring funds from a checking account to a saving account.
Transaction Processing System (TPS)
Transaction processing systems are systems with large databases and hundreds of
concurrent users that are executing database transactions.
Ex: Airline reservation system, Order entry/processing systems, Bank’s account
processing systems.
Characteristics of TPS are
• Large amounts of data are processed
• The TPS processes information on a regular basis: daily, weekly, monthly, etc
• Large storage (database) capacity is required
• High processing speed is needed due to the high volume
• TPS basically monitors and collects past data
• High reliability is required
Transactional processing systems provide three functional areas.
1. System runtime functions
• Transaction processing systems provide an execution environment that ensures
the integrity, availability, and security of data.
• It also ensures fast response time and high transaction throughput .
2. System administration functions
• Transaction processing systems provide administrative support that lets users
configure, monitor, and manage their transaction system.
3. Application development functions
• Transaction processing systems provide functions for use in custom business
applications, Including function to access data, to perform inter computer
communication etc.
Single – user vs. Multi – user System
Single-User System
• A DBMS is single-user if at most one user can use the system at a time.
• The basic components of a transaction processing system can be found in single
user systems.
• Single-user DBMSs are mostly restricted to personal computer systems.
• Presentation Services – displays forms, handles flow of information to/from
screen.
• Application Services – implements user request, interacts with DBMS.
Multi-User System
• A DBMS is multi-user if many users can use the system concurrently.
• In multi-user system, many users can use the system and hence access the
database-concurrently
• Dumb terminals connected to mainframe
Application and presentation services on mainframe.
• ACID properties required
Isolation: DBMS sees an interleaved schedule.
Atomicity and durability: System supports a major enterprise.
• Transaction abstraction, implemented by DBMS, provides ACID properties.
Transaction And Systems Concepts
Transaction Operations
• A transaction is an atomic unit of work that is either completed in its entirety or not
not done at all.
• For recovery purposes the system needs to keep track of when the transaction starts,
starts, terminates and commits (or) aborts.
The recovery manager keeps track of the following operations:
• Begin_transaction: marks the beginning of the transaction executes.
• Read (or) Write : Two possible operations on the data. These specify read or write
operations on the database items that are executed as part of a transaction.
• End_transaction: Specifies that operations have ended and marks the end of
execution. The change can be either committed or aborted.
Recovery techniques use the following operators:
• undo : similar to rollback except that it applies to a single operation rather than to a
whole transaction.
• redo : This specifies that certain transaction operations must be redone to ensure
that all the operations of a committed transaction have been applied successfully to
to the database.
Transaction States
A transaction is any one execution of a user program in a DBMS, a transaction moves
moves through various types of execution states.
• Active state – the initial state, The active state is the first state of every transaction.
In this state, the transaction is being executed.
• Partially committed state - In the partially committed state, a transaction
executes its final operation, but the data is still not saved to the database.
• Failed state – after the discovery that normal execution can no longer proceed
• Aborted state – after the transaction has been rolled backed and the database has
been restored to its state prior to the start od transaction.
• Committed state - A transaction is said to be in a committed state if it executes all
its operations successfully. In this state, all the effects are now permanently saved
on the database system.
System Log
• Log is nothing but a file which contains a sequence of records, each log record
refers to a write operation.
• All the log records are recorded step by step in the log file. We can say, log files store
store the history of all updates activities.
• This information may be needed to permit recovery from transaction failures.
• Log contains start of transaction, transaction number, record number, old value,
new value, end of transaction etc. For example, mini statements in bank ATMs.
• The log is kept on disk, so it is not affected by any type of failure except for disk (or)
(or) catastrophic failure.
• In addition, the log is periodically backed up to archival storage (tape) to guard
against such catastrophic failures.
• “ T ” in the following discussion refers to a unique transaction-id that is generated
generated automatically by the system and is used to identify each transaction.
Types of log records
• <Ti, Xi, V1, V2> − update log record,
where Ti=transaction, Xi=data, V1=old data, V2=new value.
• <Ti, start> − Transaction Ti starts execution.
• <Ti, commit> − Transaction Ti is committed.
• <Ti, abort> − Transaction Ti is aborted
 [start_transaction, T ] : Records that transaction T has started execution.
 [read_item, T, X] : Records that transaction T has read the value of database item
item X.
 [commit, T] : Records that transaction T has completed successfully.
 [abort, T] : Record that transaction T has been aborted.
Commit Point of a Transaction
A transaction T is said to reach its commit point only when it completes all its
operation that has actually accessed the database and have been executed
successfully and the effect of all transaction operation on the database have been
recorded in the log. The transaction then writes an entry [commit, T] into the log.
• Roll Back of transaction : to erase all data modifications made from the start of
the transaction or to a savepoint.
• Redoing transactions: Transactions that have written their commit entry in the
log must also have recorded all their write operations in the log, otherwise they
would not be committed, so their effect on the database can be redone from the log
log entries.
• Force writing a log: Before a transaction reaches its commit point, any portion of
the log that has not been written to the disk yet must now be written to the disk.
This process is called force-writing the log file before committing a transaction.
Desirable properties of Transaction
The transaction has the four properties . In order to maintain consistency in a
database, before and after the transaction. These are called ACID properties.
ACID properties are applied for maintaining the integrity of database during
transaction processing.
ACID stands for Atomicity, Consistency, Isolation, and Durability.
Atomicity
• It states that all operations of the transaction take place at once if not, the
transction is aborted.
• There is no midway, i.e., the transaction cannot occur partially. Each transaction is
is treated as one unit and either run to completion or is not executed at all.
Atomicity involves the following two operations:
Abort: if a transaction aborts then all the changes made are not visible.
Commit: if a transaction commits then all the changes made are visible.
Consistency
• The integrity constraint are maintained so that the database is consistent before
and after the transaction.
• The execution of transaction will leave a database in either its prior stable state or
or new stable state.
• The consistent property of database states that every transaction sees a consistent
consistent database instance.
• The transaction is used to transform the database from one consistent state to
another consistent state
Isolation
• It shows that the data which is used at the time of execution of a transaction cannot
cannot be used by the second transaction until the first one is completed.
• In isolation, if the transaction T1 is being executed and using the data item X, then
then that data item cant be accessed by any other transaction T2 until the
transaction T1 ends.
• The concurrency control subsystem of the DBMS enforced the isolation property.
property.
Durability
• guarantees that once a transaction is committed, its effects are permanent and
survive any system failures. Together, these properties ensure reliability and
maintain data integrity in DBMS operations.
(optional)
• Atomicity ensures that a transaction is treated as a single indivisible
unit, either executing all its operations or none at all.
• Consistency ensures that the database remains in a valid state before
and after a transaction.
• Isolation ensures that concurrent transactions do not interfere with
each other, maintaining data integrity.
• Durability guarantees that once a transaction is committed, its effects
are permanent and survive any system failures. Together, these
properties ensure reliability and maintain data integrity in DBMS
operations.
Transaction Support System in SQL
Transaction initiation is done implicitly when SQL statement is executed. Every
transaction must have explicit end statement, which is either commit or rollback.
Every transaction has certain characteristics:
• Access mode: read only (or) read write.
• Diagnostic area size: option specifies an integer value n, indicating the number of
conditions that can be held simultaneously in the diagnostic area.
(The diagnostics area contains two kinds of information:
 Statement information, such as the number of conditions that occurred or the affected-rows
count.
 Condition information, such as the error code and message.)
• The isolation level: option that can be read uncommitted, read committed,
repeatable read, serializable.
(serializable :ensures that multiple transactions can access and modify the same data without interfering with each
other’s operations.)
If a transaction executes at a lower isolation level than serializable, then one or
more of the following violations may occur.
Dirty read: Reading a value that was written by a transaction which failed.
Non repeatable read: Allowing another transaction to write a new value
multiple reads of one transaction.
Phantom: A transaction T1 may read a set of rows from a table, then another
transaction T2 inserts new rows. If T1 repeated, then it will see a Phantom.
(Phantom Read – Phantom Read occurs when two same queries are executed, but the rows
retrieved by the two, are different.
For example, suppose transaction T1 retrieves a set of rows that satisfy some search criteria. Now,
Transaction T2 generates some new rows that match the search criteria for transaction T1)
Concurrency Control Techniques
• Concurrency control is a database management systems(DBMS) concept that is
used to address conflicts with the simultaneous accessing or altering of data that
can occur with a multi-user system.
• Concurrency control, when applied to a DBMS, is meant to co-ordinate
simultaneous transactions while preserving data integrity. The concurrency is
about to control the multiuser access of database.
Purpose of Concurrency control
• enforce isolation among transactions.
• preserve database consistency through consistency preserving execution of transactions.
• resolve read-write and write-read conflicts.
Terms of Concurrency Control
Transaction: A transaction is an execution of a user program as a series of reads and writes
of database objects
Schedules: A schedule is the arrangement of transaction operations. A schedule may contain
a set of transactions (Reading, Writing, Aborting or committing)To run transactions
concurrently, we arrange or schedule their operations in an interleaved fashion.
Serializability: Serialization helps in checking concurrency control between multiple
transactions. It also helps in maintaining consistency in the database before and after any
transaction. Serializable schedules are resource-efficient and help in improving CPU
throughput
Or
Serializability of a schedule means equivalence to a serial schedule (i.e., sequential with no
transaction overlap in time) with the same transactions.
Locking System for Concurrency Control
Two operations lock item and unlock item are used with binary Locking
2. Shared / exclusive (or) read/Write locks
1. Shared lock:
• It is also known as a Read-only lock. In a shared lock, the data item can only read by
by the transaction.
• It can be shared between the transactions because when the transaction holds a lock,
lock, then it can't update the data on the data item.
2. Exclusive lock:
• In the exclusive lock, the data item can be both reads as well as written by the
transaction.
• This lock is exclusive, and in this lock, multiple transactions do not modify the same
same data simultaneously.
There are three locking operations:
1. read_lock(X)
2. Write_lock(X)
3. Unlock(X)
• There are three possible states read locked, write locked(or) unlocked.
1. A read locked item is also called shared-locked because outer transactions are
are allowed to read the item.
2. Write locked item is called exclusive-locked because a single transaction
exclusively holds the lock on the item.
3. To implement these three operations on a read/write lock is to keep of the
number of transactions that hold a shared(read) lock on an item in the lock
table.
• Shared/ Exclusive locking scheme, the system must enforce the following
rules:
• A transaction T must issue the operation read_lock(X) (or) before any read-
item(X) operation is performed on T
• A transaction T must issue the operation write_lock(X) before any write_item(X)
• A transaction T will not issue a read_lock(X) operation if it already holds a
read lock(or) a write lock in item X.
• A transaction T will not issue a write_lock(X) operation if it already holds a
read lock (or) write lock on item X.
Lock Conversion
Two phase Locking (2PL)
• The two-phase locking protocol divides the execution phase of the transaction into
three parts.
• In the first part, when the execution of the transaction starts, it seeks permission for
the lock it requires.
• In the second part, the transaction acquires all the locks. The third phase is started as
as soon as the transaction releases its first lock.
• In the third phase, the transaction cannot demand any new locks. It only releases the
the acquired locks.
Two-Phase Locking Techniques : Essential Components
1. Lock Manager: Managing locks on data items.
2. Lock Table: Lock manager uses it to store the identify of transaction locking a data
item, the data item, lock mode and pointer to the next data item locked. One simple
simple way to implement a lock table is through linked list.
• Database requires that all transactions should be well-formed.
• It must lock the data item before it reads or write to it.
There are two phases of 2PL:
• Growing phase: In the growing phase, a new lock on the data item may be acquired
by the transaction, but none can be released.
• Shrinking phase: In the shrinking phase, existing lock held by the transaction may
be released, but no new locks can be acquired.
Two Phase policy generates two locking algorithm (a) Basic and (b) Conservative.
• Conservative: Prevents deadlocks by locking all desired data items before
transaction begins execution.
• Basic: Transaction locks data items incrementally. This may cause deadlock which is
dealt with.
Problems caused by use of Locks
The use of locks, can cause two problems, they are
• Deadlock
• Starvation
Deadlock
• A system is in a deadlock state if there exists a set of transactions such that every
transaction in the set in waiting for another transaction in the set.
• A deadlock is a situation in which two computer programs sharing the same
resource are effectively preventing each other from accessing the resource, resulting
resulting in both programs ceasing function.
Ex: there exists a set of waiting transaction {T0, T1,……Tn} such that T0 is waiting for
for data item that is held by T1, T1 is waiting for a data item that is held by T2, Tn-1 is
1 is waiting for a data item that is held by Tn, and Tn is waiting for a data item that is
is held by T0. None of the transactions can make progress in such a situation.
Dealing with Deadlock and Starvation
Deadkock prevention
• A transaction locks all data items it refers to before it begins execution.
• This way of locking prevents deadlock since a transaction never waits for a data
item.
• The conservative two-locking uses this approach.
Deadlock detection and resolution
• In this approach, deadlocks are allowed to happen. The scheduler maintains a
wait-for-graph for detecting cycle. If a cycle exists, then one transaction involved
involved in then cycle is selected (victim) and roller-back.
• A wait-for-graph is created using the lock table. As soon as a transaction is
blocked, it is added to the graph. When a chain like: Ti waits for Tj waits for Tk
waits for Ti or Tj occurs, then this creates a cycle.
Deadlock avoidance
• There are many variations of two-phase locking algorithm.
• Some avoid deadlock by not letting the cycle to complete.
• That is as soon as the algorithm discovers that blocking a transaction is likely to
create a cycle, it rolls back the transaction.
Starvation
• Starvation occurs when a particular transaction consistently waits or restarted and
and never gets a chance to proceed further.
• In a deadlock resolution it is possible that the same transaction may consistently be
be selected as victim and rolled-back.
• The limitation is inherent in all priority based scheduling mechanisms.
• In wound-wait scheme a younger transaction may always be wounded (aborted) by
by a long running older transaction which may create starvation.
DeadLock Prevention
A deadlock can be prevented by following two commonly used schemes.
1. Wait – die
2. Wound-wait
Wait-die Scheme
(Non-Preemptive Scheduling is one in which once the resources
(CPU Cycle) have been allocated to a process, the process holds it
until it completes its burst time or switches to the 'wait' state.
In non-preemptive scheduling, a process cannot be interrupted
until it terminates itself or its time is over.)
(Preemptive Scheduling is a CPU scheduling technique that
works by dividing time slots of CPU to a given process.
The time slot given might be able to complete the whole process or
might not be able to it.)
2. Wound – Wait scheme
Deadlock detection
Recovery Techniques
Database recovery techniques are used in database management systems (DBMS)
(DBMS) to restore a database to a consistent state after a failure or error has
occurred. The main goal of recovery techniques is to ensure data integrity and
consistency and prevent data loss.
Failure Classification
Recovery Techniques in DBMS
Concurrency Control Based on Time Stamp Ordering
• Timestamp TS(T) is a unique identifier created by DBMS to identify the
transaction
• The timestamp values are assigned in the order in which the transaction are
submitted to the system
• The timestamp can be generated using a counter that is incremented each time its
its value is assigned to a transaction
• Timestamp ordering algorithm (TO) it orders the transaction according to their
timestamps
• It generates serializability of schedules
• The algorithm must ensure that for each item accessed by conflicting operations in
in the schedule, does not violate the serializability order.
Database Backup and Recovery from Catastrophic Failures
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx

More Related Content

Similar to Unit 4 chapter - 8 Transaction processing Concepts (1).pptx

Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011
sumit_study
 
Transaction ps
Transaction psTransaction ps
Transaction ps
MR Z
 

Similar to Unit 4 chapter - 8 Transaction processing Concepts (1).pptx (20)

Introduction to transaction management
Introduction to transaction managementIntroduction to transaction management
Introduction to transaction management
 
DBMS UNIT 4
DBMS UNIT 4DBMS UNIT 4
DBMS UNIT 4
 
Dbms
DbmsDbms
Dbms
 
DBMS UNIT IV.pptx
DBMS UNIT IV.pptxDBMS UNIT IV.pptx
DBMS UNIT IV.pptx
 
Transaction processing
Transaction processingTransaction processing
Transaction processing
 
DBMS Vardhaman.pdf
DBMS Vardhaman.pdfDBMS Vardhaman.pdf
DBMS Vardhaman.pdf
 
Introduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theoryIntroduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theory
 
Autonomous transaction
Autonomous transactionAutonomous transaction
Autonomous transaction
 
TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERY
TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERYTRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERY
TRANSACTION MANAGEMENT AND TIME STAMP PROTOCOLS AND BACKUP RECOVERY
 
Transactions
TransactionsTransactions
Transactions
 
Tps revision 2017
Tps revision 2017Tps revision 2017
Tps revision 2017
 
Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011
 
Transactionsmanagement
TransactionsmanagementTransactionsmanagement
Transactionsmanagement
 
DBMS 4.pdf
DBMS 4.pdfDBMS 4.pdf
DBMS 4.pdf
 
Transaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptxTransaction Processing in DBMS.pptx
Transaction Processing in DBMS.pptx
 
Unit no 5 transation processing DMS 22319
Unit no 5 transation processing DMS 22319Unit no 5 transation processing DMS 22319
Unit no 5 transation processing DMS 22319
 
Crash recovery in database
Crash recovery in databaseCrash recovery in database
Crash recovery in database
 
Job Opportunity
Job OpportunityJob Opportunity
Job Opportunity
 
Transaction ps
Transaction psTransaction ps
Transaction ps
 
acid property.pptx
acid property.pptxacid property.pptx
acid property.pptx
 

More from Koteswari Kasireddy

Chapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdfChapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdf
Koteswari Kasireddy
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptx
Koteswari Kasireddy
 
Database System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptxDatabase System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptx
Koteswari Kasireddy
 

More from Koteswari Kasireddy (20)

DA Syllabus outline (2).pptx
DA Syllabus outline (2).pptxDA Syllabus outline (2).pptx
DA Syllabus outline (2).pptx
 
Chapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdfChapter-7-Sampling & sampling Distributions.pdf
Chapter-7-Sampling & sampling Distributions.pdf
 
Object_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdfObject_Oriented_Programming_Unit3.pdf
Object_Oriented_Programming_Unit3.pdf
 
unit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdfunit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdf
 
DBMS_UNIT_1.pdf
DBMS_UNIT_1.pdfDBMS_UNIT_1.pdf
DBMS_UNIT_1.pdf
 
business analytics
business analyticsbusiness analytics
business analytics
 
Relational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptx
 
CHAPTER -12 it.pptx
CHAPTER -12 it.pptxCHAPTER -12 it.pptx
CHAPTER -12 it.pptx
 
WEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptxWEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptx
 
Database System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptxDatabase System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptx
 
Evolution Of WEB_students.pptx
Evolution Of WEB_students.pptxEvolution Of WEB_students.pptx
Evolution Of WEB_students.pptx
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Control_Statements_in_Python.pptx
Control_Statements_in_Python.pptxControl_Statements_in_Python.pptx
Control_Statements_in_Python.pptx
 
Python_Functions_Unit1.pptx
Python_Functions_Unit1.pptxPython_Functions_Unit1.pptx
Python_Functions_Unit1.pptx
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
 
linked_list.pptx
linked_list.pptxlinked_list.pptx
linked_list.pptx
 
matrices_and_loops.pptx
matrices_and_loops.pptxmatrices_and_loops.pptx
matrices_and_loops.pptx
 
algorithms_in_linkedlist.pptx
algorithms_in_linkedlist.pptxalgorithms_in_linkedlist.pptx
algorithms_in_linkedlist.pptx
 
Control_Statements.pptx
Control_Statements.pptxControl_Statements.pptx
Control_Statements.pptx
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 

Unit 4 chapter - 8 Transaction processing Concepts (1).pptx

  • 1. Unit – 4 Chapter - 8 Transaction Processing Concepts
  • 2. INTRODUCTION • Transaction processing system are systems with large databases and hundreds of concurrent users that are executing database transactions. • EX: System for reservations, banking, Credit card processing, stock markets, supermarket checkout, and other similar systems. • They require high availability and fast response time for hundreds of concurrent users. • In this chapter we present the concepts that are needed in transaction processing system.
  • 3. Transaction Processing Concepts Transaction A transaction is the basic logical unit of execution in an information system. A transaction is a sequence of operations that must be executed as a whole, taking a consistent (correct) database state into another consistent (correct) database state. A transaction is a discrete unit of work that must be completely processed (or) not processed at all. Ex: Transferring funds from a checking account to a saving account.
  • 4. Transaction Processing System (TPS) Transaction processing systems are systems with large databases and hundreds of concurrent users that are executing database transactions. Ex: Airline reservation system, Order entry/processing systems, Bank’s account processing systems. Characteristics of TPS are • Large amounts of data are processed • The TPS processes information on a regular basis: daily, weekly, monthly, etc • Large storage (database) capacity is required • High processing speed is needed due to the high volume • TPS basically monitors and collects past data • High reliability is required
  • 5. Transactional processing systems provide three functional areas. 1. System runtime functions • Transaction processing systems provide an execution environment that ensures the integrity, availability, and security of data. • It also ensures fast response time and high transaction throughput . 2. System administration functions • Transaction processing systems provide administrative support that lets users configure, monitor, and manage their transaction system. 3. Application development functions • Transaction processing systems provide functions for use in custom business applications, Including function to access data, to perform inter computer communication etc.
  • 6. Single – user vs. Multi – user System Single-User System • A DBMS is single-user if at most one user can use the system at a time. • The basic components of a transaction processing system can be found in single user systems. • Single-user DBMSs are mostly restricted to personal computer systems. • Presentation Services – displays forms, handles flow of information to/from screen. • Application Services – implements user request, interacts with DBMS.
  • 7. Multi-User System • A DBMS is multi-user if many users can use the system concurrently. • In multi-user system, many users can use the system and hence access the database-concurrently
  • 8. • Dumb terminals connected to mainframe Application and presentation services on mainframe. • ACID properties required Isolation: DBMS sees an interleaved schedule. Atomicity and durability: System supports a major enterprise. • Transaction abstraction, implemented by DBMS, provides ACID properties. Transaction And Systems Concepts Transaction Operations • A transaction is an atomic unit of work that is either completed in its entirety or not not done at all. • For recovery purposes the system needs to keep track of when the transaction starts, starts, terminates and commits (or) aborts. The recovery manager keeps track of the following operations: • Begin_transaction: marks the beginning of the transaction executes.
  • 9. • Read (or) Write : Two possible operations on the data. These specify read or write operations on the database items that are executed as part of a transaction. • End_transaction: Specifies that operations have ended and marks the end of execution. The change can be either committed or aborted. Recovery techniques use the following operators: • undo : similar to rollback except that it applies to a single operation rather than to a whole transaction. • redo : This specifies that certain transaction operations must be redone to ensure that all the operations of a committed transaction have been applied successfully to to the database.
  • 10. Transaction States A transaction is any one execution of a user program in a DBMS, a transaction moves moves through various types of execution states.
  • 11. • Active state – the initial state, The active state is the first state of every transaction. In this state, the transaction is being executed. • Partially committed state - In the partially committed state, a transaction executes its final operation, but the data is still not saved to the database. • Failed state – after the discovery that normal execution can no longer proceed • Aborted state – after the transaction has been rolled backed and the database has been restored to its state prior to the start od transaction. • Committed state - A transaction is said to be in a committed state if it executes all its operations successfully. In this state, all the effects are now permanently saved on the database system.
  • 12. System Log • Log is nothing but a file which contains a sequence of records, each log record refers to a write operation. • All the log records are recorded step by step in the log file. We can say, log files store store the history of all updates activities. • This information may be needed to permit recovery from transaction failures. • Log contains start of transaction, transaction number, record number, old value, new value, end of transaction etc. For example, mini statements in bank ATMs. • The log is kept on disk, so it is not affected by any type of failure except for disk (or) (or) catastrophic failure. • In addition, the log is periodically backed up to archival storage (tape) to guard against such catastrophic failures. • “ T ” in the following discussion refers to a unique transaction-id that is generated generated automatically by the system and is used to identify each transaction.
  • 13. Types of log records • <Ti, Xi, V1, V2> − update log record, where Ti=transaction, Xi=data, V1=old data, V2=new value. • <Ti, start> − Transaction Ti starts execution. • <Ti, commit> − Transaction Ti is committed. • <Ti, abort> − Transaction Ti is aborted  [start_transaction, T ] : Records that transaction T has started execution.  [read_item, T, X] : Records that transaction T has read the value of database item item X.  [commit, T] : Records that transaction T has completed successfully.  [abort, T] : Record that transaction T has been aborted.
  • 14. Commit Point of a Transaction A transaction T is said to reach its commit point only when it completes all its operation that has actually accessed the database and have been executed successfully and the effect of all transaction operation on the database have been recorded in the log. The transaction then writes an entry [commit, T] into the log. • Roll Back of transaction : to erase all data modifications made from the start of the transaction or to a savepoint. • Redoing transactions: Transactions that have written their commit entry in the log must also have recorded all their write operations in the log, otherwise they would not be committed, so their effect on the database can be redone from the log log entries. • Force writing a log: Before a transaction reaches its commit point, any portion of the log that has not been written to the disk yet must now be written to the disk. This process is called force-writing the log file before committing a transaction.
  • 15. Desirable properties of Transaction The transaction has the four properties . In order to maintain consistency in a database, before and after the transaction. These are called ACID properties. ACID properties are applied for maintaining the integrity of database during transaction processing. ACID stands for Atomicity, Consistency, Isolation, and Durability.
  • 16. Atomicity • It states that all operations of the transaction take place at once if not, the transction is aborted. • There is no midway, i.e., the transaction cannot occur partially. Each transaction is is treated as one unit and either run to completion or is not executed at all. Atomicity involves the following two operations: Abort: if a transaction aborts then all the changes made are not visible. Commit: if a transaction commits then all the changes made are visible. Consistency • The integrity constraint are maintained so that the database is consistent before and after the transaction. • The execution of transaction will leave a database in either its prior stable state or or new stable state. • The consistent property of database states that every transaction sees a consistent consistent database instance. • The transaction is used to transform the database from one consistent state to another consistent state
  • 17. Isolation • It shows that the data which is used at the time of execution of a transaction cannot cannot be used by the second transaction until the first one is completed. • In isolation, if the transaction T1 is being executed and using the data item X, then then that data item cant be accessed by any other transaction T2 until the transaction T1 ends. • The concurrency control subsystem of the DBMS enforced the isolation property. property. Durability • guarantees that once a transaction is committed, its effects are permanent and survive any system failures. Together, these properties ensure reliability and maintain data integrity in DBMS operations.
  • 18. (optional) • Atomicity ensures that a transaction is treated as a single indivisible unit, either executing all its operations or none at all. • Consistency ensures that the database remains in a valid state before and after a transaction. • Isolation ensures that concurrent transactions do not interfere with each other, maintaining data integrity. • Durability guarantees that once a transaction is committed, its effects are permanent and survive any system failures. Together, these properties ensure reliability and maintain data integrity in DBMS operations.
  • 19. Transaction Support System in SQL Transaction initiation is done implicitly when SQL statement is executed. Every transaction must have explicit end statement, which is either commit or rollback. Every transaction has certain characteristics: • Access mode: read only (or) read write. • Diagnostic area size: option specifies an integer value n, indicating the number of conditions that can be held simultaneously in the diagnostic area. (The diagnostics area contains two kinds of information:  Statement information, such as the number of conditions that occurred or the affected-rows count.  Condition information, such as the error code and message.) • The isolation level: option that can be read uncommitted, read committed, repeatable read, serializable. (serializable :ensures that multiple transactions can access and modify the same data without interfering with each other’s operations.)
  • 20. If a transaction executes at a lower isolation level than serializable, then one or more of the following violations may occur. Dirty read: Reading a value that was written by a transaction which failed. Non repeatable read: Allowing another transaction to write a new value multiple reads of one transaction. Phantom: A transaction T1 may read a set of rows from a table, then another transaction T2 inserts new rows. If T1 repeated, then it will see a Phantom. (Phantom Read – Phantom Read occurs when two same queries are executed, but the rows retrieved by the two, are different. For example, suppose transaction T1 retrieves a set of rows that satisfy some search criteria. Now, Transaction T2 generates some new rows that match the search criteria for transaction T1)
  • 21. Concurrency Control Techniques • Concurrency control is a database management systems(DBMS) concept that is used to address conflicts with the simultaneous accessing or altering of data that can occur with a multi-user system. • Concurrency control, when applied to a DBMS, is meant to co-ordinate simultaneous transactions while preserving data integrity. The concurrency is about to control the multiuser access of database.
  • 22. Purpose of Concurrency control • enforce isolation among transactions. • preserve database consistency through consistency preserving execution of transactions. • resolve read-write and write-read conflicts. Terms of Concurrency Control Transaction: A transaction is an execution of a user program as a series of reads and writes of database objects Schedules: A schedule is the arrangement of transaction operations. A schedule may contain a set of transactions (Reading, Writing, Aborting or committing)To run transactions concurrently, we arrange or schedule their operations in an interleaved fashion. Serializability: Serialization helps in checking concurrency control between multiple transactions. It also helps in maintaining consistency in the database before and after any transaction. Serializable schedules are resource-efficient and help in improving CPU throughput Or Serializability of a schedule means equivalence to a serial schedule (i.e., sequential with no transaction overlap in time) with the same transactions.
  • 23. Locking System for Concurrency Control
  • 24. Two operations lock item and unlock item are used with binary Locking
  • 25. 2. Shared / exclusive (or) read/Write locks 1. Shared lock: • It is also known as a Read-only lock. In a shared lock, the data item can only read by by the transaction. • It can be shared between the transactions because when the transaction holds a lock, lock, then it can't update the data on the data item. 2. Exclusive lock: • In the exclusive lock, the data item can be both reads as well as written by the transaction. • This lock is exclusive, and in this lock, multiple transactions do not modify the same same data simultaneously. There are three locking operations: 1. read_lock(X) 2. Write_lock(X) 3. Unlock(X)
  • 26. • There are three possible states read locked, write locked(or) unlocked. 1. A read locked item is also called shared-locked because outer transactions are are allowed to read the item. 2. Write locked item is called exclusive-locked because a single transaction exclusively holds the lock on the item. 3. To implement these three operations on a read/write lock is to keep of the number of transactions that hold a shared(read) lock on an item in the lock table. • Shared/ Exclusive locking scheme, the system must enforce the following rules: • A transaction T must issue the operation read_lock(X) (or) before any read- item(X) operation is performed on T • A transaction T must issue the operation write_lock(X) before any write_item(X)
  • 27. • A transaction T will not issue a read_lock(X) operation if it already holds a read lock(or) a write lock in item X. • A transaction T will not issue a write_lock(X) operation if it already holds a read lock (or) write lock on item X.
  • 29. Two phase Locking (2PL) • The two-phase locking protocol divides the execution phase of the transaction into three parts. • In the first part, when the execution of the transaction starts, it seeks permission for the lock it requires. • In the second part, the transaction acquires all the locks. The third phase is started as as soon as the transaction releases its first lock. • In the third phase, the transaction cannot demand any new locks. It only releases the the acquired locks. Two-Phase Locking Techniques : Essential Components 1. Lock Manager: Managing locks on data items. 2. Lock Table: Lock manager uses it to store the identify of transaction locking a data item, the data item, lock mode and pointer to the next data item locked. One simple simple way to implement a lock table is through linked list. • Database requires that all transactions should be well-formed. • It must lock the data item before it reads or write to it.
  • 30. There are two phases of 2PL: • Growing phase: In the growing phase, a new lock on the data item may be acquired by the transaction, but none can be released. • Shrinking phase: In the shrinking phase, existing lock held by the transaction may be released, but no new locks can be acquired. Two Phase policy generates two locking algorithm (a) Basic and (b) Conservative. • Conservative: Prevents deadlocks by locking all desired data items before transaction begins execution. • Basic: Transaction locks data items incrementally. This may cause deadlock which is dealt with.
  • 31. Problems caused by use of Locks The use of locks, can cause two problems, they are • Deadlock • Starvation Deadlock • A system is in a deadlock state if there exists a set of transactions such that every transaction in the set in waiting for another transaction in the set. • A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting resulting in both programs ceasing function. Ex: there exists a set of waiting transaction {T0, T1,……Tn} such that T0 is waiting for for data item that is held by T1, T1 is waiting for a data item that is held by T2, Tn-1 is 1 is waiting for a data item that is held by Tn, and Tn is waiting for a data item that is is held by T0. None of the transactions can make progress in such a situation.
  • 32. Dealing with Deadlock and Starvation Deadkock prevention • A transaction locks all data items it refers to before it begins execution. • This way of locking prevents deadlock since a transaction never waits for a data item. • The conservative two-locking uses this approach.
  • 33. Deadlock detection and resolution • In this approach, deadlocks are allowed to happen. The scheduler maintains a wait-for-graph for detecting cycle. If a cycle exists, then one transaction involved involved in then cycle is selected (victim) and roller-back. • A wait-for-graph is created using the lock table. As soon as a transaction is blocked, it is added to the graph. When a chain like: Ti waits for Tj waits for Tk waits for Ti or Tj occurs, then this creates a cycle. Deadlock avoidance • There are many variations of two-phase locking algorithm. • Some avoid deadlock by not letting the cycle to complete. • That is as soon as the algorithm discovers that blocking a transaction is likely to create a cycle, it rolls back the transaction.
  • 34. Starvation • Starvation occurs when a particular transaction consistently waits or restarted and and never gets a chance to proceed further. • In a deadlock resolution it is possible that the same transaction may consistently be be selected as victim and rolled-back. • The limitation is inherent in all priority based scheduling mechanisms. • In wound-wait scheme a younger transaction may always be wounded (aborted) by by a long running older transaction which may create starvation.
  • 35. DeadLock Prevention A deadlock can be prevented by following two commonly used schemes. 1. Wait – die 2. Wound-wait Wait-die Scheme
  • 36. (Non-Preemptive Scheduling is one in which once the resources (CPU Cycle) have been allocated to a process, the process holds it until it completes its burst time or switches to the 'wait' state. In non-preemptive scheduling, a process cannot be interrupted until it terminates itself or its time is over.) (Preemptive Scheduling is a CPU scheduling technique that works by dividing time slots of CPU to a given process. The time slot given might be able to complete the whole process or might not be able to it.)
  • 37. 2. Wound – Wait scheme
  • 39. Recovery Techniques Database recovery techniques are used in database management systems (DBMS) (DBMS) to restore a database to a consistent state after a failure or error has occurred. The main goal of recovery techniques is to ensure data integrity and consistency and prevent data loss.
  • 41.
  • 43. Concurrency Control Based on Time Stamp Ordering • Timestamp TS(T) is a unique identifier created by DBMS to identify the transaction • The timestamp values are assigned in the order in which the transaction are submitted to the system • The timestamp can be generated using a counter that is incremented each time its its value is assigned to a transaction • Timestamp ordering algorithm (TO) it orders the transaction according to their timestamps • It generates serializability of schedules • The algorithm must ensure that for each item accessed by conflicting operations in in the schedule, does not violate the serializability order.
  • 44. Database Backup and Recovery from Catastrophic Failures