Transaction Management & Concurrency Control (a) Week 1 1 (MO1, Chapter 10-1 to 10-2) Flashcards
What is a transaction?
Is a logical unit of work that must be completed or entirely aborted; no intermediate states are acceptable.
What does a transaction consist of?
Consists of:
SELECT statement
Series of related UPDATE statements
Series of INSERT statements
Combination of SELECT, UPDATE, and INSERT statements
What is a consistent database state?
A state in which all data integrity constraints are satisfied, Must begin with the database in a known consistent state to ensure
consistency. Most are formed by two or more database requests
What is a database request?
a single SQL statement in an application program or transaction.
What does the DBMS do if the database is in an inconsistent state
It rolls back the database to the previous consistent state.
What effects can Improper or incomplete transactions have on
database integrity:
Users can define enforceable constraints based on business rules.
Other integrity rules are automatically enforced by the DBMS.
Can you identify more examples?
What are the individual properties of transactions?
Atomicity
Consistency
Isolation
Durability
Serializability
Explain each of the individual properties of transactions. Consistency
A transaction takes place from one consistent state to another
Explain each of the individual properties of transactions. Atomicity
Atomicity: Requres ALL operations of a transaction to be completed if not the transaction is aborted, a transaction is treated as a single, indivisable unit of work.
Explain each of the individual properties of transactions. Isolation
Means that data used during the execution of a transaction cant be used by a second transaction until the first one is completed.
Explain each of the individual properties of transactions. Durability
Once transactions changes are done they cannot be undone or lost even if the system fails.
Explain each of the individual properties of transactions. Serializability
The schedule for the concurrent execution transaction yields consistent results
How do we manage transactions in SQL
The ANSI (American national standards institute has defined standards that govern SQL database transactions. Transaction support is provided by 2 sql statements
1. COMMIT
2 ROLLBACK
Describe the two SQL statements COMMIT and ROLLBACK
Commit: is reached when all statements are permanently recorded within the database, automatically ends the SQL statement.
ROLLBACK : is reached in which case all changes are aborted and the database is rolled back to a consistent state.
- Transaction sequence must continue until one of four events occur:
COMMIT statement is reached
* ROLLBACK statement is reached
* End of program is reached
* Program is abnormally terminated
The transaction log
Keeps track of all transactions that update the database
DBMS uses the information stored in a log for
Recovery requirement triggered by a ROLLBACK statement
* Program’s abnormal termination
* System failure
Transaction log stores the following ?
Record for the begginijng of a transaction
A SQL statement for each transaction component
The names of objects affected by the component
The before and after values for tge fields being updated
Pointers to the previous and next transaction log entries for the same transaction
The ending COMMIT statement.
RSNBAPC
What are some dangers of the transaction log?
diskcrashes, disk full conditions
CONCURRENCY CONTROL and objectives
Coordination of the simultaneous transactions execution in a multiuser
database system:
* Objective: ensures serializability of transactions in a multiuser database
environment.
What are most concurrency controls coordinated to
Isloation property.
Why is concurrency control important
Important because the simultaneous execution of transactions over a
shared database can create several data integrity and consistency
problems:
What are the three main problems in several simultaneous executions of transactions
Lost Updates
Uncommitted Data
Inconsistent Retrievals
Lost Updates Learn Tables
Lost Updates:
Occurs in two concurrent transactions when:
* Same data element is updated
* One of the updates is lost
Uncommitted Data (Learn Tables)
Occurs when:
* Two transactions are executed concurrently
* First transaction is rolled back after the second transaction has already accessed
uncommitted data