* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download What is a Transaction? - CSE341DatabaseSystems
Microsoft Access wikipedia , lookup
Oracle Database wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Global serializability wikipedia , lookup
Microsoft SQL Server wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Functional Database Model wikipedia , lookup
Relational model wikipedia , lookup
Clusterpoint wikipedia , lookup
Database model wikipedia , lookup
Versant Object Database wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Commitment ordering wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Advanced Database Concepts Transaction Management and Concurrency Control 1 What is a Transaction?   A logical unit of work that must be either entirely completed or aborted Successful transaction changes the database from one consistent state to another   One in which all data integrity constraints are satisfied Most real-world database transactions are formed by two or more database requests  The equivalent of a single SQL statement in an 2 application program or transaction The Relational Schema for the Ch09_SaleCo Database 3 Evaluating Transaction Results  Improper or incomplete transactions can have a devastating effect on database integrity   Some DBMSs provide means by which user can define enforceable constraints based on business rules Other integrity rules are enforced automatically by the DBMS when table structures are properly defined, thereby letting the DBMS validate some transactions 4 Transaction Properties (ACID)  Atomicity   Consistency   Ensures that the concurrent execution of several transactions yields consistent results Isolation   Requires that all operations (SQL requests) of a transaction be completed Data used during execution of a transaction cannot be used by second transaction until first one is completed Durability  Indicates permanence of database’s consistent state 5 Transaction Management with SQL  Transaction support is provided by following SQL statements:  BEGIN TRANSACTION  COMMIT  ROLLBACK 6 The Transaction Log  Stores   A record for the beginning of transaction For each transaction component (SQL statement) Type of operation being performed (update, delete, insert)  Names of objects affected by the transaction (the name of the table)  “Before” and “after” values for updated fields  Pointers to previous and next transaction log entries for the same transaction The ending (COMMIT) of the transaction   7 A Transaction Log 8 Concurrency Control  Coordination of simultaneous transaction execution in a multiprocessing database system  Objective is to ensure transaction serializability in a multiuser database environment  Serial Vs Interleaved Execution 9 Concurrency Control  Simultaneous execution of transactions over a shared database can create several data integrity and consistency problems  Lost Updates  Dirty Read/Uncommitted Data Read  Inconsistent Retrievals 10 Normal Execution of Two Transactions 11 Lost Updates 12 Correct Execution of Two Transactions 13 An Uncommitted Data Problem 14 Retrieval During Update 15 Transaction Results: Data Entry Correction 16 Inconsistent Retrievals 17 Read/Write Conflict Scenarios: Conflicting Operations Matrix 18 Serializability & Precedence Graph 19 Concurrency Control with Locking Methods   Lock  Guarantees exclusive use of a data item to a current transaction  Required to prevent another transaction from reading inconsistent data Lock manager  Responsible for assigning and policing the locks used by the transactions 20 Lock Granularity  Indicates the level of lock use  Locking can take place at following levels:  Database  Table  Page  Row  Field (attribute) 21 Lock Granularity (continued)  Database-level lock   Table-level lock   Entire database is locked Entire table is locked Page-level lock  Entire diskpage is locked 22 Lock Granularity (continued)  Row-level lock   Allows concurrent transactions to access different rows of the same table, even if the rows are located on the same page Field-level lock  Allows concurrent transactions to access the same row, as long as they require the use of different fields (attributes) within that row 23 Lock Types  Exclusive lock    Access is specifically reserved for the transaction that locked the object Must be used when the potential for conflict exists Shared lock  Concurrent transactions are granted Read access on the basis of a common lock 24 Summary  Transaction  Sequence of database operations that access the database  Represents real-world events  Must be a logical unit of work   No portion of the transaction can exist by itself Takes a database from one consistent state to another  One in which all data integrity constraints are satisfied 25 Summary (continued)  SQL provides support for transactions through the use of two statements: COMMIT and ROLLBACK  Concurrency control coordinates the simultaneous execution of transactions  Lock guarantees unique access to a data item by a transaction 26
 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
									 
                                             
                                             
                                             
                                             
                                             
                                             
                                             
                                             
                                             
                                             
                                            