SlideShare uma empresa Scribd logo
1 de 18
Department of Information Technology 1Data base Technologies (ITB4201)
Introduction to Transaction concepts
Dr. C.V. Suresh Babu
Professor
Department of IT
Hindustan Institute of Science & Technology
Department of Information Technology 2Data base Technologies (ITB4201)
Action Plan
• Transaction processing systems
• Introduction to TRANSACTION
• Need for TRANSACTION
• Operations
• Transaction Execution and Problems
• Transaction States
• Transaction Execution with SQL
• Transaction Properties
• Transaction Log
• Quiz
Department of Information Technology 3Data base Technologies (ITB4201)
Transaction processing systems
• Transaction is a logical unit of work that represents real-world events of
any organisation.
• Transaction processing systems execute database transactions with large
databases and hundreds of concurrent users,
for example,
• railway and air reservations systems,
• banking system,
• credit card processing,
• stock market monitoring,
• super market inventory and
• checkouts and so on.
Department of Information Technology 4Data base Technologies (ITB4201)
Introduction to TRANSACTION
• A transaction is a logical unit of work of database processing that includes one or more database
access operations.
• A transaction can be defined as an action or series of actions that is carried out by a single user or
application program to perform operations for accessing the contents of the database. The
operations can include
– retrieval (Read)
– insertion (Write)
– deletion and
– modification.
• A transaction must be either completed or aborted.
It can either be embedded within an application program or can be specified interactively via a high-
level query language such as SQL.
• Its execution preserves the consistency of the database.
Each transaction should access shared data without interfering with the other transactions and
whenever a transaction successfully completes its execution; its effect should be permanent.
Department of Information Technology 5Data base Technologies (ITB4201)
Need for TRANSACTION
This basic abstraction frees the database application programmer
from the following concerns :
• Inconsistencies caused by conflicting updates from concurrent
users.
• Partially completed transactions in the event of systems failure.
• User-directed undoing of transactions.
• A transaction is a sequence of READ and WRITE actions that are
grouped together to from a database access. A transaction may
consist of a simple SELECT operation to generate a list of table
contents, or it may consist of a series of related UPDATE command
sequences.
Department of Information Technology 6Data base Technologies (ITB4201)
Operations
• A transaction can include the following basic database access operations:
Operations Descriptions
Retrieve To retrieve data stored ina database.
Insert To store new data in database.
Delete To delete existing data from database.
Update To modify existing data in database.
Commit To save the work done permanently.
Rollback To undo the work done.
• Transaction that changes the contents of the database must alter the database from one consistent state to
another.
• A consistent database state is one in which all data integrity constraints are satisfied.
To ensure database consistency, every transaction must begin with the database in a known consistent state.
Department of Information Technology 7Data base Technologies (ITB4201)
Transaction Execution and Problems
• A transaction which successfully completes its execution is said
to have been committed. Otherwise, the transaction is
aborted.
• Thus, if a committed transaction performs any update
operation on the database, its effect must be reflected on the
database even if there is a failure.
Department of Information Technology 8Data base Technologies (ITB4201)
Transaction States
• A transaction can be in one of the following states:
Department of Information Technology 9Data base Technologies (ITB4201)
State Description
Active state
• A transaction goes into an active state immediately after it starts execution, where it
can issue READ and WRITE operations.
• A transaction may be aborted when the transaction itself detects an error during
execution which it cannot recover from, for example, a transaction trying to debit loan
amount of an employee from his insufficient gross salary.
• A transaction may also be aborted before it has been committed due to system failure
or any other circumstances beyond its control.
Partially
committed
• When the transaction ends, it moves to the partially committed state. When the last
state is reached.
• To this point, some recovery protocols need to ensure that a system failure will not
result in an inability to record the changes of the transaction permanently.
• Once this check is successful, the transaction is said to have reached its commit point
and enters the committed state.
Aborted
• When the normal execution can no longer be performed.
Failed or aborted transactions may be restarted later, either automatically or after
being resubmitted by the user as new transactions.
Committed
• After successful completion of transaction.
• A transaction is said to be in a committed state if it has partially committed and it can
be ensured that it will never be aborted.
Department of Information Technology 10Data base Technologies (ITB4201)
Transaction Execution with SQL
• The American National Standards Institute (ANSI) has defined standards that govern SQL database
transactions. Transaction support is provided by two SQL statements namely COMMIT and
ROLLBACK.
The ANSI standards require that, when a transaction sequence is initiated by a user or an application
program, it must continue through all succeeding SQL statements until one of the following four
events occur :
• A COMMIT statement is reached, in which case all changes are permanently recorded within the
database. The COMMIT statement automatically ends the SQL transaction. The COMMIT operations
indicates successful end-of-transaction.
• A ROLLBACK statement is reached, in which case all the changes are aborted and the database is
rolled back to its previous consistent state. The ROLLBACK operation indicates unsuccessful end-of-
transaction.
• The end of a program is successfully reached, in which case all changes are permanently recorded
within the database. This action is equivalent to COMMIT.
• The program is abnormally terminated, in which case the changes made in the database are aborted
and the database is rolled back to its previous consistent state. This action is equivalent to
ROLLBACK.
Department of Information Technology 11Data base Technologies (ITB4201)
Transaction Properties
A transaction must have the following four properties, called
ACID properties (also called ACIDITY of a transaction), to ensure
that a database remains stable state after the transaction is
executed:
• Atomicity.
• Consistency.
• Isolation.
• Durability.
Department of Information Technology 12Data base Technologies (ITB4201)
Atomicity
• The atomicity property of a transaction requires that all operations of a
transaction be completed, if not, the transaction is aborted. In other
words, a transaction is treated as single, individual logical unit of work.
Therefore, a transaction must execute and complete each operation in its
logic before it commits its changes.
• As stated earlier, the transaction is considered as one operation even
though there are multiple read and writes. Thus, transaction completes or
fails as one unit.
• The atomicity property of transaction is ensured by the transaction
recovery subsystem of a DBMS.
• In the event of a system crash in the midst of transaction execution, the
recovery techniques undo any effects of the transaction on the database.
Department of Information Technology 13Data base Technologies (ITB4201)
Consistency
• Database consistency is the property that every transaction sees a consistent database
instance. In other words, execution of a transaction must leave a database in either its prior
stable state or a new stable state that reflects the new modifications (updates) made by the
transaction.
• If the transaction fails, the database must be returned to the state it was in prior to the
execution of the failed transaction.
• If the transaction commits, the database must reflect the new changes. Thus, all resources
are always in a consistent state.
• The preservation of consistency is generally the responsibility of the programmers who
write the database programs or of the DBMS module that enforces integrity constraints.
• A database program should be written in a way that guarantees that, if the database is in a
consistent state before executing the transaction, it will be in a consistent state after the
complete execution of the transaction, assuming that no interference with other
transactions occur. In other words, a transaction must transform the database from one
consistent state to another consistent state.
Department of Information Technology 14Data base Technologies (ITB4201)
Isolation
• Isolation property of a transaction means that the data used
during the execution of a transaction cannot be used by a
second transaction until the first one is completed.
• This property isolates transactions from one another. In other
words, if a transaction T1 is being executed and is using the
data item X, that data item cannot be accessed by any other
transaction (T2………..Tn) until T1 ends.
• The isolation property is enforced by the concurrency control
subsystem of the DBMS.
Department of Information Technology 15Data base Technologies (ITB4201)
Durability
• The durability property of transaction indicates the performance of
the database's consistent state. It states that the changes made by
a transaction are permanent.
• They cannot be lost by either a system failure or by the erroneous
operation of a faulty transaction.
• When a transaction is completed, the database reaches a
consistent state and that state cannot be lost, even in the event of
system's failure.
• Durability property is the responsibility of the recovery subsystem
of the DBMS.
Department of Information Technology 16Data base Technologies (ITB4201)
Transaction Log (or Journal)
To support transaction processing, DBMSs maintain a transaction record of every change made to the
database into a log (also called journal). For each transaction, the following data is recorded on the log:
A start-of-transaction marker.
• The transaction identifier which could include who and where information.
• The record identifiers which include the identifiers for the record occurrences.
• The operation(s) performed on the records (for example, insert, delete, modify).
• The previous value(s) of the modified data. This information is required for undoing the changes
made by a partially completed transaction. It is called the undo log. Where the modification made by
the transaction is the insertion of a new record, the previous values can be assumed to be null.
• The updated value(s) of the modified record(s). This information is required for making sure that the
changes made by a committed transaction are in fact reflected in the database and can be used to
redo these modifications. This information is called the redo part of the log. In case the modification
made by the transaction is the deletion of a record, the updated values can be assumed to be null.
• A commit transaction marker if the transaction is committed, otherwise an abort or rollback
transaction marker.
Department of Information Technology 17Data base Technologies (ITB4201)
Test Yourself
1. With regards to transaction processing, any DBMS should be capable of:
a. Ensuring that transactions are free from interference from other users.
b. Parts of a transaction are not lost due to a failure.
c. Transactions do not make the database inconsistent.
d. All of the above.
2. What is ACID properties of Transactions?
a. Atomicity, Consistency, Isolation, Database
b. Atomicity, Consistency, Inconsistent, Durability
c. Automatically, Concurrency, Isolation, Durability
d. Atomicity, Consistency, Isolation, Durability
3. A transaction completes its execution is said to be
a. Saved b. Loaded c. Rolled d. Committed
4. The deadlock state can be changed back to stable state by using _____________ statement.
a. Commit b. Rollback c. Savepoint d. Deadlock
5. A transaction for which all committed changes are permanent is called:
a. Atomic b. Consistent c. Isolated d. durable
Department of Information Technology 18Data base Technologies (ITB4201)
Answers
1. With regards to transaction processing, any DBMS should be capable of:
a. Ensuring that transactions are free from interference from other users.
b. Parts of a transaction are not lost due to a failure.
c. Transactions do not make the database inconsistent.
d. All of the above.
2. What is ACID properties of Transactions?
a. Atomicity, Consistency, Isolation, Database
b. Atomicity, Consistency, Inconsistent, Durability
c. Automatically, Concurrency, Isolation, Durability
d. Atomicity, Consistency, Isolation, Durability
3. A transaction completes its execution is said to be
a. Saved b. Loaded c. Rolled d. Committed
4. The deadlock state can be changed back to stable state by using _____________ statement.
a. Commit b. Rollback c. Savepoint d. Deadlock
5. A transaction for which all committed changes are permanent is called:
a. Atomic b. Consistent c. Isolated d. durable

Mais conteúdo relacionado

Mais procurados

Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database System
Sulemang
 
Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query Optimization
Ali Usman
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
koolkampus
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
koolkampus
 

Mais procurados (20)

Database recovery
Database recoveryDatabase recovery
Database recovery
 
DISTRIBUTED DATABASE WITH RECOVERY TECHNIQUES
DISTRIBUTED DATABASE WITH RECOVERY TECHNIQUESDISTRIBUTED DATABASE WITH RECOVERY TECHNIQUES
DISTRIBUTED DATABASE WITH RECOVERY TECHNIQUES
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database System
 
Transaction management DBMS
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
 
Recovery Techniques and Need of Recovery
Recovery Techniques and   Need of RecoveryRecovery Techniques and   Need of Recovery
Recovery Techniques and Need of Recovery
 
Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query Optimization
 
Acid properties
Acid propertiesAcid properties
Acid properties
 
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
Distributed DBMS - Unit 8 - Distributed Transaction Management & Concurrency ...
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
Query processing and optimization (updated)
Query processing and optimization (updated)Query processing and optimization (updated)
Query processing and optimization (updated)
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing Concept
 
DDBMS
DDBMSDDBMS
DDBMS
 
17. Recovery System in DBMS
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMS
 
Database System Architectures
Database System ArchitecturesDatabase System Architectures
Database System Architectures
 
Data Flow Diagram
Data Flow DiagramData Flow Diagram
Data Flow Diagram
 
Advanced DBMS presentation
Advanced DBMS presentationAdvanced DBMS presentation
Advanced DBMS presentation
 
Dbms acid
Dbms acidDbms acid
Dbms acid
 
Fragmentation and types of fragmentation in Distributed Database
Fragmentation and types of fragmentation in Distributed DatabaseFragmentation and types of fragmentation in Distributed Database
Fragmentation and types of fragmentation in Distributed Database
 

Semelhante a Introduction to transaction management

Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxUnit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Koteswari Kasireddy
 
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
 
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptxFALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
hritikraj888
 
Introduction to transaction processing
Introduction to transaction processingIntroduction to transaction processing
Introduction to transaction processing
Jafar Nesargi
 
Chapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingChapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processing
Jafar Nesargi
 
Chapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingChapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processing
Jafar Nesargi
 

Semelhante a Introduction to transaction management (20)

Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptxUnit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
 
DBMS UNIT IV.pptx
DBMS UNIT IV.pptxDBMS UNIT IV.pptx
DBMS UNIT IV.pptx
 
Sistem manajemen basis data 8
Sistem manajemen basis data   8Sistem manajemen basis data   8
Sistem manajemen basis data 8
 
Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011
 
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptxFALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
 
Recovery techniques
Recovery techniquesRecovery techniques
Recovery techniques
 
Transaction processing
Transaction processingTransaction processing
Transaction processing
 
DBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency ControlDBMS-chap 2-Concurrency Control
DBMS-chap 2-Concurrency Control
 
transaction_processing.ppt
transaction_processing.ppttransaction_processing.ppt
transaction_processing.ppt
 
chp13.pdf
chp13.pdfchp13.pdf
chp13.pdf
 
Dbms ii mca-ch11-recovery-2013
Dbms ii mca-ch11-recovery-2013Dbms ii mca-ch11-recovery-2013
Dbms ii mca-ch11-recovery-2013
 
Introduction to transaction processing
Introduction to transaction processingIntroduction to transaction processing
Introduction to transaction processing
 
Chapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingChapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processing
 
Chapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processingChapter 9 introduction to transaction processing
Chapter 9 introduction to transaction processing
 
Chapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error RecoveryChapter-10 Transaction Processing and Error Recovery
Chapter-10 Transaction Processing and Error Recovery
 
Transactions
TransactionsTransactions
Transactions
 
Tranasaction management
Tranasaction managementTranasaction management
Tranasaction management
 
Chapter 4 u
Chapter 4 uChapter 4 u
Chapter 4 u
 
E-Business Information System BBA AVI.pptx
E-Business Information System BBA AVI.pptxE-Business Information System BBA AVI.pptx
E-Business Information System BBA AVI.pptx
 
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
 

Mais de Dr. C.V. Suresh Babu

Mais de Dr. C.V. Suresh Babu (20)

Data analytics with R
Data analytics with RData analytics with R
Data analytics with R
 
Association rules
Association rulesAssociation rules
Association rules
 
Clustering
ClusteringClustering
Clustering
 
Classification
ClassificationClassification
Classification
 
Blue property assumptions.
Blue property assumptions.Blue property assumptions.
Blue property assumptions.
 
Introduction to regression
Introduction to regressionIntroduction to regression
Introduction to regression
 
DART
DARTDART
DART
 
Mycin
MycinMycin
Mycin
 
Expert systems
Expert systemsExpert systems
Expert systems
 
Dempster shafer theory
Dempster shafer theoryDempster shafer theory
Dempster shafer theory
 
Bayes network
Bayes networkBayes network
Bayes network
 
Bayes' theorem
Bayes' theoremBayes' theorem
Bayes' theorem
 
Knowledge based agents
Knowledge based agentsKnowledge based agents
Knowledge based agents
 
Rule based system
Rule based systemRule based system
Rule based system
 
Formal Logic in AI
Formal Logic in AIFormal Logic in AI
Formal Logic in AI
 
Production based system
Production based systemProduction based system
Production based system
 
Game playing in AI
Game playing in AIGame playing in AI
Game playing in AI
 
Diagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AIDiagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AI
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 

Último

An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Introduction to transaction management

  • 1. Department of Information Technology 1Data base Technologies (ITB4201) Introduction to Transaction concepts Dr. C.V. Suresh Babu Professor Department of IT Hindustan Institute of Science & Technology
  • 2. Department of Information Technology 2Data base Technologies (ITB4201) Action Plan • Transaction processing systems • Introduction to TRANSACTION • Need for TRANSACTION • Operations • Transaction Execution and Problems • Transaction States • Transaction Execution with SQL • Transaction Properties • Transaction Log • Quiz
  • 3. Department of Information Technology 3Data base Technologies (ITB4201) Transaction processing systems • Transaction is a logical unit of work that represents real-world events of any organisation. • Transaction processing systems execute database transactions with large databases and hundreds of concurrent users, for example, • railway and air reservations systems, • banking system, • credit card processing, • stock market monitoring, • super market inventory and • checkouts and so on.
  • 4. Department of Information Technology 4Data base Technologies (ITB4201) Introduction to TRANSACTION • A transaction is a logical unit of work of database processing that includes one or more database access operations. • A transaction can be defined as an action or series of actions that is carried out by a single user or application program to perform operations for accessing the contents of the database. The operations can include – retrieval (Read) – insertion (Write) – deletion and – modification. • A transaction must be either completed or aborted. It can either be embedded within an application program or can be specified interactively via a high- level query language such as SQL. • Its execution preserves the consistency of the database. Each transaction should access shared data without interfering with the other transactions and whenever a transaction successfully completes its execution; its effect should be permanent.
  • 5. Department of Information Technology 5Data base Technologies (ITB4201) Need for TRANSACTION This basic abstraction frees the database application programmer from the following concerns : • Inconsistencies caused by conflicting updates from concurrent users. • Partially completed transactions in the event of systems failure. • User-directed undoing of transactions. • A transaction is a sequence of READ and WRITE actions that are grouped together to from a database access. A transaction may consist of a simple SELECT operation to generate a list of table contents, or it may consist of a series of related UPDATE command sequences.
  • 6. Department of Information Technology 6Data base Technologies (ITB4201) Operations • A transaction can include the following basic database access operations: Operations Descriptions Retrieve To retrieve data stored ina database. Insert To store new data in database. Delete To delete existing data from database. Update To modify existing data in database. Commit To save the work done permanently. Rollback To undo the work done. • Transaction that changes the contents of the database must alter the database from one consistent state to another. • A consistent database state is one in which all data integrity constraints are satisfied. To ensure database consistency, every transaction must begin with the database in a known consistent state.
  • 7. Department of Information Technology 7Data base Technologies (ITB4201) Transaction Execution and Problems • A transaction which successfully completes its execution is said to have been committed. Otherwise, the transaction is aborted. • Thus, if a committed transaction performs any update operation on the database, its effect must be reflected on the database even if there is a failure.
  • 8. Department of Information Technology 8Data base Technologies (ITB4201) Transaction States • A transaction can be in one of the following states:
  • 9. Department of Information Technology 9Data base Technologies (ITB4201) State Description Active state • A transaction goes into an active state immediately after it starts execution, where it can issue READ and WRITE operations. • A transaction may be aborted when the transaction itself detects an error during execution which it cannot recover from, for example, a transaction trying to debit loan amount of an employee from his insufficient gross salary. • A transaction may also be aborted before it has been committed due to system failure or any other circumstances beyond its control. Partially committed • When the transaction ends, it moves to the partially committed state. When the last state is reached. • To this point, some recovery protocols need to ensure that a system failure will not result in an inability to record the changes of the transaction permanently. • Once this check is successful, the transaction is said to have reached its commit point and enters the committed state. Aborted • When the normal execution can no longer be performed. Failed or aborted transactions may be restarted later, either automatically or after being resubmitted by the user as new transactions. Committed • After successful completion of transaction. • A transaction is said to be in a committed state if it has partially committed and it can be ensured that it will never be aborted.
  • 10. Department of Information Technology 10Data base Technologies (ITB4201) Transaction Execution with SQL • The American National Standards Institute (ANSI) has defined standards that govern SQL database transactions. Transaction support is provided by two SQL statements namely COMMIT and ROLLBACK. The ANSI standards require that, when a transaction sequence is initiated by a user or an application program, it must continue through all succeeding SQL statements until one of the following four events occur : • A COMMIT statement is reached, in which case all changes are permanently recorded within the database. The COMMIT statement automatically ends the SQL transaction. The COMMIT operations indicates successful end-of-transaction. • A ROLLBACK statement is reached, in which case all the changes are aborted and the database is rolled back to its previous consistent state. The ROLLBACK operation indicates unsuccessful end-of- transaction. • The end of a program is successfully reached, in which case all changes are permanently recorded within the database. This action is equivalent to COMMIT. • The program is abnormally terminated, in which case the changes made in the database are aborted and the database is rolled back to its previous consistent state. This action is equivalent to ROLLBACK.
  • 11. Department of Information Technology 11Data base Technologies (ITB4201) Transaction Properties A transaction must have the following four properties, called ACID properties (also called ACIDITY of a transaction), to ensure that a database remains stable state after the transaction is executed: • Atomicity. • Consistency. • Isolation. • Durability.
  • 12. Department of Information Technology 12Data base Technologies (ITB4201) Atomicity • The atomicity property of a transaction requires that all operations of a transaction be completed, if not, the transaction is aborted. In other words, a transaction is treated as single, individual logical unit of work. Therefore, a transaction must execute and complete each operation in its logic before it commits its changes. • As stated earlier, the transaction is considered as one operation even though there are multiple read and writes. Thus, transaction completes or fails as one unit. • The atomicity property of transaction is ensured by the transaction recovery subsystem of a DBMS. • In the event of a system crash in the midst of transaction execution, the recovery techniques undo any effects of the transaction on the database.
  • 13. Department of Information Technology 13Data base Technologies (ITB4201) Consistency • Database consistency is the property that every transaction sees a consistent database instance. In other words, execution of a transaction must leave a database in either its prior stable state or a new stable state that reflects the new modifications (updates) made by the transaction. • If the transaction fails, the database must be returned to the state it was in prior to the execution of the failed transaction. • If the transaction commits, the database must reflect the new changes. Thus, all resources are always in a consistent state. • The preservation of consistency is generally the responsibility of the programmers who write the database programs or of the DBMS module that enforces integrity constraints. • A database program should be written in a way that guarantees that, if the database is in a consistent state before executing the transaction, it will be in a consistent state after the complete execution of the transaction, assuming that no interference with other transactions occur. In other words, a transaction must transform the database from one consistent state to another consistent state.
  • 14. Department of Information Technology 14Data base Technologies (ITB4201) Isolation • Isolation property of a transaction means that the data used during the execution of a transaction cannot be used by a second transaction until the first one is completed. • This property isolates transactions from one another. In other words, if a transaction T1 is being executed and is using the data item X, that data item cannot be accessed by any other transaction (T2………..Tn) until T1 ends. • The isolation property is enforced by the concurrency control subsystem of the DBMS.
  • 15. Department of Information Technology 15Data base Technologies (ITB4201) Durability • The durability property of transaction indicates the performance of the database's consistent state. It states that the changes made by a transaction are permanent. • They cannot be lost by either a system failure or by the erroneous operation of a faulty transaction. • When a transaction is completed, the database reaches a consistent state and that state cannot be lost, even in the event of system's failure. • Durability property is the responsibility of the recovery subsystem of the DBMS.
  • 16. Department of Information Technology 16Data base Technologies (ITB4201) Transaction Log (or Journal) To support transaction processing, DBMSs maintain a transaction record of every change made to the database into a log (also called journal). For each transaction, the following data is recorded on the log: A start-of-transaction marker. • The transaction identifier which could include who and where information. • The record identifiers which include the identifiers for the record occurrences. • The operation(s) performed on the records (for example, insert, delete, modify). • The previous value(s) of the modified data. This information is required for undoing the changes made by a partially completed transaction. It is called the undo log. Where the modification made by the transaction is the insertion of a new record, the previous values can be assumed to be null. • The updated value(s) of the modified record(s). This information is required for making sure that the changes made by a committed transaction are in fact reflected in the database and can be used to redo these modifications. This information is called the redo part of the log. In case the modification made by the transaction is the deletion of a record, the updated values can be assumed to be null. • A commit transaction marker if the transaction is committed, otherwise an abort or rollback transaction marker.
  • 17. Department of Information Technology 17Data base Technologies (ITB4201) Test Yourself 1. With regards to transaction processing, any DBMS should be capable of: a. Ensuring that transactions are free from interference from other users. b. Parts of a transaction are not lost due to a failure. c. Transactions do not make the database inconsistent. d. All of the above. 2. What is ACID properties of Transactions? a. Atomicity, Consistency, Isolation, Database b. Atomicity, Consistency, Inconsistent, Durability c. Automatically, Concurrency, Isolation, Durability d. Atomicity, Consistency, Isolation, Durability 3. A transaction completes its execution is said to be a. Saved b. Loaded c. Rolled d. Committed 4. The deadlock state can be changed back to stable state by using _____________ statement. a. Commit b. Rollback c. Savepoint d. Deadlock 5. A transaction for which all committed changes are permanent is called: a. Atomic b. Consistent c. Isolated d. durable
  • 18. Department of Information Technology 18Data base Technologies (ITB4201) Answers 1. With regards to transaction processing, any DBMS should be capable of: a. Ensuring that transactions are free from interference from other users. b. Parts of a transaction are not lost due to a failure. c. Transactions do not make the database inconsistent. d. All of the above. 2. What is ACID properties of Transactions? a. Atomicity, Consistency, Isolation, Database b. Atomicity, Consistency, Inconsistent, Durability c. Automatically, Concurrency, Isolation, Durability d. Atomicity, Consistency, Isolation, Durability 3. A transaction completes its execution is said to be a. Saved b. Loaded c. Rolled d. Committed 4. The deadlock state can be changed back to stable state by using _____________ statement. a. Commit b. Rollback c. Savepoint d. Deadlock 5. A transaction for which all committed changes are permanent is called: a. Atomic b. Consistent c. Isolated d. durable