



























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




























Oct 2017
✥ What is a transaction? ✥ What properties transactions have? ✥ Why do we want to interleave transactions? ✥ How does the DMBS deal with transactions? ✥ How do we use transactions from SQL?
✥ The DBMS must ensure 4 important properties of transactions:
✥ Users are responsible for the consistency of their transactions ✥ Each transaction must leave the database in a consistent state if the database is consistent when the transaction begins. ✥ The DBMS will enforce ICs and other constraints ✥ Beyond this, the database does not really understand the semantics of the data. (e.g., it does not understand how the interest on a bank account is computed). ✥ Database consistency is the property that every transaction sees a consistent database instance
✥ If a transaction ends, we say its commits , otherwise it aborts ✥ Transactions can be incomplete for three reasons:
✥ The DBMS uses a log to ensure that incomplete transactions can be undone, if necessary
✥ A schedule is a potential execution sequence of a set of transactions ✥ It describes actions as seen by the DBMS: T 1 T 2 R(A) W(A) R(C) W(C) Commit R(B) W(B) Abort ✥ If the actions are not interleaved, it is called a serial schedule.
T 1 T 2 R (A ) W (A ) R (A ) W (A ) R (B ) W (B ) R(B) W(B) Com mit
Com mit
T^1 T^2 R(A) W(A) R(A) R(B) W(B) W(A) R(B) W(B) Commit Commit
T 1 T 2 R(A) W(A) R(B) W(B) Commit R(A) W (A) R(B) W(B) Commit
✥ Note: SQL programmers can instruct the database to use non-serializable schedules.
✥ Concurrency can leave to an inconsistent state ✥ Two actions in the same object conflict it at least one is a write ✥ 3 types of anomalies (assume transactions T 1 , T 2 )
✥ T 2 reads data that has not been committed yet T 1 T 2 R(A) W(A)
R (B) W (B) Commit
R(A) W(A)
✥ T 2 overwrites the value of an object A, already modified by T 1 , while T 1 is still in progress T 1 T 2 W(A)
10–14 Introduction to Transaction Management (1.1.0)
W(B) Com mit
W(A) W