Introduction of Week 13 Return assignment 11-1 and 3-1-5 Collect assignment 12-1. Questions? Review of week 12 DBA activities Oracle DBMS tools Oracle data dictionary Privileges Database Management Systems
Module 6 Advanced Database Concepts Section 2: Transaction Processing Module 6 Advanced Database Concepts
DML Action Simple SELECT statement to generate a list of table contents A series of related UPDATE statements to change the values of attributes in various tables A series of INSERT statements to add rows to one or more tables A combination of SELECT, UPDATE, and INSERT statements Database Management Systems
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, in which all data integrity constraints are satisfied Most real-world database transactions are formed by two or more database DML requests Database Management Systems
Transaction Properties Atomicity - all operations (SQL requests) of a transaction be completed Durability – indicates permanence of database’s consistent state Serializability - ensures that the concurrent execution of several transactions yields consistent results Isolation - Data used during execution of a transaction cannot be used by second transaction until first one is completed Database Management Systems
The Transaction Log 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 Database Management Systems
A Transaction Log Database Management Systems
Database Audit Trail From the backup and logs, databases can be restored in case of damage or loss Database Management Systems
Concurrency Control Coordination of simultaneous transaction execution in a multiprocessing database system Objective is to ensure transaction serializability in a multiuser database environment Database Management Systems
Concurrency Control Important simultaneous execution of transactions over a shared database can create several data integrity and consistency problems lost updates uncommitted data inconsistent retrievals Database Management Systems
Lost Updates: Normal Execution Database Management Systems
Lost Updates: Concurrency Problem Database Management Systems
Uncommitted Data: Correct Executions Database Management Systems
Uncommitted Data: Concurrency Problem Database Management Systems
Inconsistent Retrievals: Two Transactions Database Management Systems
Inconsistent Retrievals: Correct Transaction Results Database Management Systems
Inconsistent Retrievals: Concurrency Problem Database Management Systems
The Scheduler Special DBMS program: establishes order of operations within which concurrent transactions are executed Interleaves the execution of database operations to ensure serializability and isolation of transactions Database Management Systems
The Scheduler (continued) Bases its actions on concurrency control algorithms Ensures computer’s central processing unit (CPU) is used efficiently Facilitates data isolation to ensure that two transactions do not update the same data element at the same time Database Management Systems
Conflicting Database Operations Matrix Database Management Systems
Concurrency Control with Locking Methods 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 Database Management Systems
Updates with locking for Concurrency Control This prevents the lost update problem Database Management Systems
Lock Granularity Indicates the level of lock use Locking can take place at the following levels: Database Table Block or page Record (row) Field (attribute) Database Management Systems
Lock Types Binary lock Exclusive lock Shared lock Has only two states: locked (1) or unlocked (0) 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 Database Management Systems
An Example of a Binary Lock Database Management Systems
Two-Phase Locking to Ensure Serializability Defines how transactions acquire and relinquish locks Guarantees serializability, but it does not prevent deadlocks Growing phase, in which a transaction acquires all the required locks without unlocking any data Shrinking phase, in which a transaction releases all locks and cannot obtain any new lock Database Management Systems
Two-Phase Locking to Ensure Serializability (continued) Governed by the following rules: Two transactions cannot have conflicting locks No unlock operation can precede a lock operation in the same transaction No data are affected until all locks are obtained—that is, until the transaction is in its locked point Database Management Systems
Two-Phase Locking Protocol Database Management Systems
Deadlocks Condition that occurs when two transactions wait for each other to unlock data Possible only if one of the transactions wants to obtain an exclusive lock on a data item No deadlock condition can exist among shared locks Database Management Systems
How a Deadlock Condition Is Created Database Management Systems
Deadlocks Control Prevention – a transaction requesting a new lock is aborted if it might cause a deadlock Detection Allow deadlocks to occur Mechanisms for detecting and breaking them, such as resource usage matrix Avoidance – a transaction must obtain all the locks it needs before it can be executed. Database Management Systems
Concurrency Control with Time Stamping Methods Assigns a global unique time stamp to each transaction Produces an explicit order in which transactions are submitted to the DBMS Uniqueness - ensures that no equal time stamp values can exist Monotonicity - ensures that time stamp values always increase Database Management Systems
Deadlock Resolution Schemes Wait/die - older transaction continues and the younger is rolled back Wound/wait - older transaction rolls back the younger transaction continues Database Management Systems
Concurrency Control with Optimistic Methods Based on the assumption that the majority of database operations do not conflict Does not require locking or time stamping techniques Transaction is executed without restrictions until it is committed Phases are read, validation, and write Database Management Systems
Database Recovery Management Restores database from a given state, usually inconsistent, to a previously consistent state Based on the atomic transaction property - all portions of the transaction must be treated as a single logical unit of work If transaction operation cannot be completed, transaction must be aborted, and any changes to the database must be rolled back Database Management Systems
Database Backup Level of backup Failures that plague databases Full backup Differential backup, incremental backup Transaction log backup Failures that plague databases Software – OS, DBMS, applications Hardware – memory errors, disk crashes Human errors Database Management Systems
Wrap Up No new assignment! Database Management Systems