Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Chapter 5 Database Transaction Management

5,358 views

Published on

Database Transaction Management

Published in: Education
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Chapter 5 Database Transaction Management

  1. 1. CHAPTER 5 DATABASE TRANSACTION MANAGEMENT DFC2033 DATABASE SYSTEM
  2. 2. Course Learning Outcome CLO2 : Develop a database using a concurrency control and data recovery technique to manage the database system.
  3. 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. 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. 5. 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.
  6. 6. 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).
  7. 7. Concurrency Control Interference problem arise from simultaneous access to database: ¨  Lost Update ¨  Uncommitted Dependency ¨  Inconsistent Retrieval
  8. 8. 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.
  9. 9. 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.
  10. 10. Inconsistent Retrieval ¨  Occurs when transaction reads several values but second transaction updates some of them during execution of first.
  11. 11. 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.
  12. 12. 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.
  13. 13. 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
  14. 14. 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.

×