当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

《数据库系统概念 Database System Concepts》原书教学资源(第五版,PPT课件讲稿,英文版)Chapter 15 Transactions

资源类别:文库,文档格式:PPT,文档页数:45,文件大小:1.29MB,团购合买
Transaction Concept Transaction State Concurrent Executions Serializability Recoverability Implementation of Isolation Transaction Definition in SQL Testing for Serializability.
点击下载完整版文档(PPT)

Chapter 15:Transactions Transaction Concept Transaction state Concurrent Executions Serializability Recoverability Implementation of Isolation Transaction Definition in SQL Testing for Serializability. Database System Concepts-5th Edition,Sep 10,2005. 15.2 @Silberschatz,Korth and Sudarshan

Database System Concepts - 5 15.2 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Chapter 15: Transactions Transaction Concept Transaction State Concurrent Executions Serializability Recoverability Implementation of Isolation Transaction Definition in SQL Testing for Serializability

Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various data items. A transaction must see a consistent database. During transaction execution the database may be temporarily inconsistent. When the transaction completes successfully(is committed),the database must be consistent. After a transaction commits,the changes it has made to the database persist,even if there are system failures. Multiple transactions can execute in parallel. Two main issues to deal with: Failures of various kinds,such as hardware failures and system crashes Concurrent execution of multiple transactions Database System Concepts-5th Edition,Sep 10,2005. 15.3 ©Silberschat乜,Korth and Sudarshan

Database System Concepts - 5 15.3 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Transaction Concept A transaction is a unit of program execution that accesses and possibly updates various data items. A transaction must see a consistent database. During transaction execution the database may be temporarily inconsistent. When the transaction completes successfully (is committed), the database must be consistent. After a transaction commits, the changes it has made to the database persist, even if there are system failures. Multiple transactions can execute in parallel. Two main issues to deal with: Failures of various kinds, such as hardware failures and system crashes Concurrent execution of multiple transactions

ACID Properties A transaction is a unit of program execution that accesses and possibly updates various data items.To preserve the integrity of data the database system must ensure: Atomicity.Either all operations of the transaction are properly reflected in the database or none are. Consistency.Execution of a transaction in isolation preserves the consistency of the database. Isolation.Although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions.Intermediate transaction results must be hidden from other concurrently executed transactions. That is,for every pair of transactions Ti and Ti,it appears to Ti that either Ti,finished execution before T;started,or T;started execution after 7;finished. Durability.After a transaction completes successfully,the changes it has made to the database persist,even if there are system failures. Database System Concepts-5th Edition,Sep 10,2005. 15.4 ©Silberschat乜,Korth and Sudarshan

Database System Concepts - 5 15.4 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. ACID Properties Atomicity. Either all operations of the transaction are properly reflected in the database or none are. Consistency. Execution of a transaction in isolation preserves the consistency of the database. Isolation. Although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions. Intermediate transaction results must be hidden from other concurrently executed transactions. That is, for every pair of transactions Ti and Tj , it appears to Ti that either Tj , finished execution before Ti started, or Tj started execution after Ti finished. Durability. After a transaction completes successfully, the changes it has made to the database persist, even if there are system failures. A transaction is a unit of program execution that accesses and possibly updates various data items.To preserve the integrity of data the database system must ensure:

Example of Fund Transfer Transaction to transfer $50 from account A to account B: 1.read(A) 2.A:=A-50 3.write(A) 4.read(B) 5.B:=B+50 6.write(B) Atomicity requirement-if the transaction fails after step 3 and before step 6,the system should ensure that its updates are not reflected in the database,else an inconsistency will result. Consistency requirement-the sum of A and B is unchanged by the execution of the transaction. Database System Concepts-5th Edition,Sep 10,2005. 15.5 @Silberschatz,Korth and Sudarshan

Database System Concepts - 5 15.5 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Example of Fund Transfer Transaction to transfer $50 from account A to account B: 1. read(A) 2. A := A – 50 3. write(A) 4. read(B) 5. B := B + 50 6. write(B) Atomicity requirement — if the transaction fails after step 3 and before step 6, the system should ensure that its updates are not reflected in the database, else an inconsistency will result. Consistency requirement – the sum of A and B is unchanged by the execution of the transaction

Example of Fund Transfer(Cont.) Isolation requirement-if between steps 3 and 6,another transaction is allowed to access the partially updated database,it will see an inconsistent database(the sum A B will be less than it should be). Isolation can be ensured trivially by running transactions serially, that is one after the other. However,executing multiple transactions concurrently has significant benefits,as we will see later. Durability requirement-once the user has been notified that the transaction has completed (i.e.,the transfer of the $50 has taken place),the updates to the database by the transaction must persist despite failures. Database System Concepts-5th Edition,Sep 10,2005. 15.6 ©Silberschat乜,Korth and Sudarshan

Database System Concepts - 5 15.6 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Example of Fund Transfer (Cont.) Isolation requirement — if between steps 3 and 6, another transaction is allowed to access the partially updated database, it will see an inconsistent database (the sum A + B will be less than it should be). Isolation can be ensured trivially by running transactions serially, that is one after the other. However, executing multiple transactions concurrently has significant benefits, as we will see later. Durability requirement — once the user has been notified that the transaction has completed (i.e., the transfer of the $50 has taken place), the updates to the database by the transaction must persist despite failures

Transaction State Active-the initial state;the transaction stays in this state while it is executing Partially committed-after the final statement has been executed. Failed--after the discovery that normal execution can no longer proceed. Aborted-after the transaction has been rolled back and the database restored to its state prior to the start of the transaction. Two options after it has been aborted: restart the transaction;can be done only if no internal logical error kill the transaction Committed -after successful completion. Database System Concepts-5th Edition,Sep 10,2005. 15.7 @Silberschatz,Korth and Sudarshan

Database System Concepts - 5 15.7 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Transaction State Active – the initial state; the transaction stays in this state while it is executing Partially committed – after the final statement has been executed. Failed -- after the discovery that normal execution can no longer proceed. Aborted – after the transaction has been rolled back and the database restored to its state prior to the start of the transaction. Two options after it has been aborted: restart the transaction; can be done only if no internal logical error kill the transaction Committed – after successful completion

Transaction State (Cont.) partially committed committed active failed aborted Database System Concepts-5th Edition,Sep 10,2005. 15.8 @Silberschatz,Korth and Sudarshan

Database System Concepts - 5 15.8 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Transaction State (Cont.)

Implementation of Atomicity and Durability The recovery-management component of a database system implements the support for atomicity and durability. The shadow-database scheme: assume that only one transaction is active at a time. a pointer called db_pointer always points to the current consistent copy of the database. all updates are made on a shadow copy of the database,and db_pointer is made to point to the updated shadow copy only after the transaction reaches partial commit and all updated pages have been flushed to disk. in case transaction fails,old consistent copy pointed to by db pointer can be used,and the shadow copy can be deleted. Database System Concepts-5th Edition,Sep 10,2005. 15.9 ©Silberschat乜,Korth and Sudarshan

Database System Concepts - 5 15.9 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Implementation of Atomicity and Durability The recovery-management component of a database system implements the support for atomicity and durability. The shadow-database scheme: assume that only one transaction is active at a time. a pointer called db_pointer always points to the current consistent copy of the database. all updates are made on a shadow copy of the database, and db_pointer is made to point to the updated shadow copy only after the transaction reaches partial commit and all updated pages have been flushed to disk. in case transaction fails, old consistent copy pointed to by db_pointer can be used, and the shadow copy can be deleted

Implementation of Atomicity and Durability (Cont.) The shadow-database scheme: db-pointer db-pointer old copy of old copy of database new copy of database database (to be deleted) (a)Before update (b)After update Assumes disks do not fail Useful for text editors,but extremely inefficient for large databases(why?) Does not handle concurrent transactions Will study better schemes in Chapter 17. Database System Concepts-5th Edition,Sep 10,2005. 15.10 ©Silberschat乜,Korth and Sudarshan

Database System Concepts - 5 15.10 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Implementation of Atomicity and Durability (Cont.) Assumes disks do not fail Useful for text editors, but extremely inefficient for large databases (why?) Does not handle concurrent transactions Will study better schemes in Chapter 17. The shadow-database scheme:

Concurrent Executions Multiple transactions are allowed to run concurrently in the system. Advantages are: increased processor and disk utilization,leading to better transaction throughput:one transaction can be using the CPU while another is reading from or writing to the disk reduced average response time for transactions:short transactions need not wait behind long ones. Concurrency control schemes-mechanisms to achieve isolation;that is,to control the interaction among the concurrent transactions in order to prevent them from destroying the consistency of the database Will study in Chapter 16,after studying notion of correctness of concurrent executions. Database System Concepts-5th Edition,Sep 10,2005. 15.11 ©Silberschat乜,Korth and Sudarshan

Database System Concepts - 5 15.11 ©Silberschatz, Korth and Sudarshan th Edition, Sep 10, 2005. Concurrent Executions Multiple transactions are allowed to run concurrently in the system. Advantages are: increased processor and disk utilization, leading to better transaction throughput: one transaction can be using the CPU while another is reading from or writing to the disk reduced average response time for transactions: short transactions need not wait behind long ones. Concurrency control schemes – mechanisms to achieve isolation; that is, to control the interaction among the concurrent transactions in order to prevent them from destroying the consistency of the database Will study in Chapter 16, after studying notion of correctness of concurrent executions

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共45页,可试读15页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有