SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
CHAPTER 5
DATABASE TRANSACTION
MANAGEMENT
DFC2033 DATABASE SYSTEM
Course Learning Outcome
CLO2 : Develop a database using a
concurrency control and data recovery
technique to manage the database system.
Learning Outcome
¨  Describe the properties of database transaction:
a. Atomic
b. Consistent
c. Isolated
d. Durable
¨  Perform a transaction of a given database using SQL statements.
¨  Use START TRANSACTION and COMMIT statements.
¨  State the purpose of concurrency control.
¨  Explain the interference problems arise from simultaneous access to database:
a. Lost update
b. Uncommitted dependency
c. Inconsistent retrieval
¨  Describe the tools used by DBMS to prevent the interference problems : locks, Two-Phase
Locking (2PL) protocol.
¨  Describe the recovery tools:
a. Transaction log
b. Checkpoint
c. Database back-up
What is Transaction ?
¨  A transaction is a unit of work that should be
processed reliably without interference from other
users and without loss of data due to failures.
¨  Examples of transactions are withdrawing cash at
an ATM, making an airline reservation and
registering for a course.
Concurrency Control
¨  The purpose of concurrency control is to prevent
two different users (or two different connections by
the same user) from trying to update the same
data at the same time. Concurrency control can
also prevent one user from seeing out-of-date
data while another user is updating the same data.
Concurrency Control
The following examples explain why concurrency control is needed. For both examples,
suppose that your checking account contains $1,000. During the day you deposit $300 and
spend $200 from that account. At the end of the day your account should have $1,100.
¨  Example 1: No concurrency control
At 11:00 AM, bank teller #1 looks up your account and sees that you have $1,000. The
teller subtracts the $200 check, but is not able to save the updated account balance ($800)
immediately. At 11:01 AM, another teller #2 looks up your account and still sees the $1,000
balance. Teller #2 then adds your $300 deposit and saves your new account balance as
$1,300. At 11:09 AM, bank teller #1 returns to the terminal, finishes entering and saving
the updated value that is calculated to be $800. That $800 value writes over the $1300. At
the end of the day, your account has $800 when it should have had $1,100 ($1000 + 300 -
200).
¨  Example 2: Concurrency control
When teller #1 starts working on your account, a lock is placed on the account. When teller
#2 tries to read or update your account while teller #1 is updating your account, teller #2
will not be given access and gets an error message. After teller #1 has finished the update,
teller #2 can proceed. At the end of the day, your account has $1,100 ($1000 - 200 +
300).
Concurrency Control
Interference problem arise from simultaneous access
to database:
¨  Lost Update
¨  Uncommitted Dependency
¨  Inconsistent Retrieval
Lost Update
¨  Successfully completed update is overridden by
another user.
¨  Lost updates occur when two or more transactions
select the same row and then update the row
based on the value originally selected.
¨  Each transaction is unaware of other transactions.
The last updates overwrites updates made by the
other transactions which results in lost data.
Uncommitted Dependency
¨  Occurs when one transaction can see intermediate
results of another transaction before it has
committed.
¨  Uncommitted dependency occurs when a second
transaction selects a row that is being updated by
another transaction.
¨  The second transaction is reading data that has not
been committed yet and may be changed by the
transaction updating the row.
Inconsistent Retrieval
¨  Occurs when transaction reads several values but
second transaction updates some of them during
execution of first.
Database Concurrency Control
Two-Phase Locking Techniques -The algorithm
(a) Locking (Growing)
(b) Unlocking (Shrinking).
¨  Locking (Growing) Phase: A transaction applies locks (read
or write) on desired data items one at a time.
¨  Unlocking (Shrinking) Phase: A transaction unlocks its locked
data items one at a time.
Requirement:
For a transaction these two phases must be mutually exclusively,
that is, during locking phase unlocking phase must not start and
during unlocking phase locking phase must not begin.
Slide	
  18-­‐	
  18	
  
Deadlock
¨  Deadlock 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-phase locking uses this approach.
Slide	
  18-­‐	
  19	
  
Deadlock
¨  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 in the cycle is selected
(victim) and rolled-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. One of the transaction o
Types of Recovery Tools
¨  Transaction Log
¤  A table that contains a history of database changes.
The recovery manager uses the log table to recover
from failures.
¨  Checkpoint
¤  The act of writing a checkpoint to log and writing log
and database buffer to disk.
¨  Database Backup
¤  A copy of all or part of disk. Is used when the disk
containing the database or log is damaged.

Weitere ähnliche Inhalte

Was ist angesagt?

Concurrency control!
Concurrency control!Concurrency control!
Concurrency control!Ashish K
 
Query decomposition in data base
Query decomposition in data baseQuery decomposition in data base
Query decomposition in data baseSalman Memon
 
Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)yourbookworldanil
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimizationKumar
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management SystemJanki Shah
 
Characteristic of dabase approach
Characteristic of dabase approachCharacteristic of dabase approach
Characteristic of dabase approachLuina Pani
 
Software engineering lecture notes
Software engineering lecture notesSoftware engineering lecture notes
Software engineering lecture notesSiva Ayyakutti
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteRaj vardhan
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMSkoolkampus
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency controlDhani Ahmad
 
Distributed concurrency control
Distributed concurrency controlDistributed concurrency control
Distributed concurrency controlBinte fatima
 
Concurrency Conrol
Concurrency ConrolConcurrency Conrol
Concurrency Conrollubna19
 

Was ist angesagt? (20)

Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Concurrency control!
Concurrency control!Concurrency control!
Concurrency control!
 
ACID Property in DBMS
ACID Property in DBMSACID Property in DBMS
ACID Property in DBMS
 
Advanced DBMS presentation
Advanced DBMS presentationAdvanced DBMS presentation
Advanced DBMS presentation
 
Database security
Database securityDatabase security
Database security
 
Concurrency control
Concurrency controlConcurrency control
Concurrency control
 
Query decomposition in data base
Query decomposition in data baseQuery decomposition in data base
Query decomposition in data base
 
Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)Presentation on dbms(relational calculus)
Presentation on dbms(relational calculus)
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimization
 
Concurrency Control in Database Management System
Concurrency Control in Database Management SystemConcurrency Control in Database Management System
Concurrency Control in Database Management System
 
Characteristic of dabase approach
Characteristic of dabase approachCharacteristic of dabase approach
Characteristic of dabase approach
 
Database System Architectures
Database System ArchitecturesDatabase System Architectures
Database System Architectures
 
Database recovery
Database recoveryDatabase recovery
Database recovery
 
Software engineering lecture notes
Software engineering lecture notesSoftware engineering lecture notes
Software engineering lecture notes
 
Unit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 CompleteUnit 1: Introduction to DBMS Unit 1 Complete
Unit 1: Introduction to DBMS Unit 1 Complete
 
1. Introduction to DBMS
1. Introduction to DBMS1. Introduction to DBMS
1. Introduction to DBMS
 
Database language
Database languageDatabase language
Database language
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency control
 
Distributed concurrency control
Distributed concurrency controlDistributed concurrency control
Distributed concurrency control
 
Concurrency Conrol
Concurrency ConrolConcurrency Conrol
Concurrency Conrol
 

Andere mochten auch

Andere mochten auch (9)

Transaction management
Transaction managementTransaction management
Transaction management
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
Database chapter 10 questions
Database chapter 10 questionsDatabase chapter 10 questions
Database chapter 10 questions
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
Stored procedure
Stored procedureStored procedure
Stored procedure
 
Oracle: Cursors
Oracle: CursorsOracle: Cursors
Oracle: Cursors
 
Transaction states PPT
Transaction states PPTTransaction states PPT
Transaction states PPT
 
Transaction states and properties
Transaction states and propertiesTransaction states and properties
Transaction states and properties
 
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)
Transaction Management - Lecture 11 - Introduction to Databases (1007156ANR)
 

Ähnlich wie Chapter 5 Database Transaction Management

Chapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlChapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlAbDul ThaYyal
 
Unit iv -Transactions
Unit iv -TransactionsUnit iv -Transactions
Unit iv -TransactionsDhivyaa C.R
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing ConceptNishant Munjal
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptxPravinBhargav1
 
Transaction management and concurrency
Transaction management and concurrencyTransaction management and concurrency
Transaction management and concurrencyVenkata Sreeram
 
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...DrCViji
 
Database Transactions and SQL Server Concurrency
Database Transactions and SQL Server ConcurrencyDatabase Transactions and SQL Server Concurrency
Database Transactions and SQL Server ConcurrencyBoris Hristov
 
TRANSACTION CONCEPTppt.pptx
TRANSACTION CONCEPTppt.pptxTRANSACTION CONCEPTppt.pptx
TRANSACTION CONCEPTppt.pptxDummyTest9
 
7. transaction mang
7. transaction mang7. transaction mang
7. transaction mangkhoahuy82
 
transaction ,concurrency , and DDBMS
transaction ,concurrency , and DDBMStransaction ,concurrency , and DDBMS
transaction ,concurrency , and DDBMSzahidHussain373
 
Concurrency note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdfBijayNag1
 
Distributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlDistributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlbalamurugan.k Kalibalamurugan
 
Intro to tsql unit 12
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12Syed Asrarali
 
CONCURRENCY CONTOL notes.pdf
CONCURRENCY CONTOL notes.pdfCONCURRENCY CONTOL notes.pdf
CONCURRENCY CONTOL notes.pdfBijayNag1
 
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 RECOVERYRohit Kumar
 

Ähnlich wie Chapter 5 Database Transaction Management (20)

Chapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency controlChapter 12 transactions and concurrency control
Chapter 12 transactions and concurrency control
 
Unit iv -Transactions
Unit iv -TransactionsUnit iv -Transactions
Unit iv -Transactions
 
Transaction Processing Concept
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing Concept
 
Transaction management transparencies
Transaction management transparenciesTransaction management transparencies
Transaction management transparencies
 
DBMS Presentation.pptx
DBMS Presentation.pptxDBMS Presentation.pptx
DBMS Presentation.pptx
 
Transaction management and concurrency
Transaction management and concurrencyTransaction management and concurrency
Transaction management and concurrency
 
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
 
Database Transactions and SQL Server Concurrency
Database Transactions and SQL Server ConcurrencyDatabase Transactions and SQL Server Concurrency
Database Transactions and SQL Server Concurrency
 
TRANSACTION CONCEPTppt.pptx
TRANSACTION CONCEPTppt.pptxTRANSACTION CONCEPTppt.pptx
TRANSACTION CONCEPTppt.pptx
 
CH09.ppt
CH09.pptCH09.ppt
CH09.ppt
 
7. transaction mang
7. transaction mang7. transaction mang
7. transaction mang
 
Dbms
DbmsDbms
Dbms
 
transaction ,concurrency , and DDBMS
transaction ,concurrency , and DDBMStransaction ,concurrency , and DDBMS
transaction ,concurrency , and DDBMS
 
Concurrency note.pdf
Concurrency note.pdfConcurrency note.pdf
Concurrency note.pdf
 
Distributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlDistributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency control
 
Tybsc cs dbms2 notes
Tybsc cs dbms2 notesTybsc cs dbms2 notes
Tybsc cs dbms2 notes
 
Intro to tsql unit 12
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12
 
CONCURRENCY CONTOL notes.pdf
CONCURRENCY CONTOL notes.pdfCONCURRENCY CONTOL notes.pdf
CONCURRENCY CONTOL notes.pdf
 
Transaction
TransactionTransaction
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
 

Mehr von Eddyzulham Mahluzydde

Mehr von Eddyzulham Mahluzydde (7)

Primitive types
Primitive typesPrimitive types
Primitive types
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
Chapter 3 Entity Relationship Model
Chapter 3 Entity Relationship ModelChapter 3 Entity Relationship Model
Chapter 3 Entity Relationship Model
 
Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2Chapter 2 Relational Data Model-part 2
Chapter 2 Relational Data Model-part 2
 
Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3Chapter 2 Relational Data Model-part 3
Chapter 2 Relational Data Model-part 3
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1
 
Chapter 1 Fundamentals of Database Management System
Chapter 1 Fundamentals of Database Management SystemChapter 1 Fundamentals of Database Management System
Chapter 1 Fundamentals of Database Management System
 

Kürzlich hochgeladen

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
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Ữ Â...Nguyen Thanh Tu Collection
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Kürzlich hochgeladen (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
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Ữ Â...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Chapter 5 Database Transaction Management

  • 2. Course Learning Outcome CLO2 : Develop a database using a concurrency control and data recovery technique to manage the database system.
  • 3. Learning Outcome ¨  Describe the properties of database transaction: a. Atomic b. Consistent c. Isolated d. Durable ¨  Perform a transaction of a given database using SQL statements. ¨  Use START TRANSACTION and COMMIT statements. ¨  State the purpose of concurrency control. ¨  Explain the interference problems arise from simultaneous access to database: a. Lost update b. Uncommitted dependency c. Inconsistent retrieval ¨  Describe the tools used by DBMS to prevent the interference problems : locks, Two-Phase Locking (2PL) protocol. ¨  Describe the recovery tools: a. Transaction log b. Checkpoint c. Database back-up
  • 4. What is Transaction ? ¨  A transaction is a unit of work that should be processed reliably without interference from other users and without loss of data due to failures. ¨  Examples of transactions are withdrawing cash at an ATM, making an airline reservation and registering for a course.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Concurrency Control ¨  The purpose of concurrency control is to prevent two different users (or two different connections by the same user) from trying to update the same data at the same time. Concurrency control can also prevent one user from seeing out-of-date data while another user is updating the same data.
  • 12. Concurrency Control The following examples explain why concurrency control is needed. For both examples, suppose that your checking account contains $1,000. During the day you deposit $300 and spend $200 from that account. At the end of the day your account should have $1,100. ¨  Example 1: No concurrency control At 11:00 AM, bank teller #1 looks up your account and sees that you have $1,000. The teller subtracts the $200 check, but is not able to save the updated account balance ($800) immediately. At 11:01 AM, another teller #2 looks up your account and still sees the $1,000 balance. Teller #2 then adds your $300 deposit and saves your new account balance as $1,300. At 11:09 AM, bank teller #1 returns to the terminal, finishes entering and saving the updated value that is calculated to be $800. That $800 value writes over the $1300. At the end of the day, your account has $800 when it should have had $1,100 ($1000 + 300 - 200). ¨  Example 2: Concurrency control When teller #1 starts working on your account, a lock is placed on the account. When teller #2 tries to read or update your account while teller #1 is updating your account, teller #2 will not be given access and gets an error message. After teller #1 has finished the update, teller #2 can proceed. At the end of the day, your account has $1,100 ($1000 - 200 + 300).
  • 13. Concurrency Control Interference problem arise from simultaneous access to database: ¨  Lost Update ¨  Uncommitted Dependency ¨  Inconsistent Retrieval
  • 14. Lost Update ¨  Successfully completed update is overridden by another user. ¨  Lost updates occur when two or more transactions select the same row and then update the row based on the value originally selected. ¨  Each transaction is unaware of other transactions. The last updates overwrites updates made by the other transactions which results in lost data.
  • 15. Uncommitted Dependency ¨  Occurs when one transaction can see intermediate results of another transaction before it has committed. ¨  Uncommitted dependency occurs when a second transaction selects a row that is being updated by another transaction. ¨  The second transaction is reading data that has not been committed yet and may be changed by the transaction updating the row.
  • 16. Inconsistent Retrieval ¨  Occurs when transaction reads several values but second transaction updates some of them during execution of first.
  • 17. Database Concurrency Control Two-Phase Locking Techniques -The algorithm (a) Locking (Growing) (b) Unlocking (Shrinking). ¨  Locking (Growing) Phase: A transaction applies locks (read or write) on desired data items one at a time. ¨  Unlocking (Shrinking) Phase: A transaction unlocks its locked data items one at a time. Requirement: For a transaction these two phases must be mutually exclusively, that is, during locking phase unlocking phase must not start and during unlocking phase locking phase must not begin.
  • 18. Slide  18-­‐  18   Deadlock ¨  Deadlock 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-phase locking uses this approach.
  • 19. Slide  18-­‐  19   Deadlock ¨  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 in the cycle is selected (victim) and rolled-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. One of the transaction o
  • 20. Types of Recovery Tools ¨  Transaction Log ¤  A table that contains a history of database changes. The recovery manager uses the log table to recover from failures. ¨  Checkpoint ¤  The act of writing a checkpoint to log and writing log and database buffer to disk. ¨  Database Backup ¤  A copy of all or part of disk. Is used when the disk containing the database or log is damaged.