Docsity

Transaction and serializability, Study notes of Database Management Systems (DBMS)

Partial preview of the text

Download Transaction and serializability and more Study notes Database Management Systems (DBMS) in PDF only on Docsity!

MCS

Advanced Database Theory and

Application^ Lecture-1-

Concepts of TransactionsAnd Serializability

Transaction

• Programming abstraction• Implement real-world transactions^ – Banking transaction– Airline reservation

Transaction: System’s Role

• Atomicity^ – All changes

of the transaction

recorded or

none

at all

• Durability^ – All future transactions see the changes made

by this transaction if it completes

• Isolation^ – Net effect as if the transaction executed in

isolation

Transaction: States

Begin

Run

Abort Commit

Transaction: Programmer’s View

Issues with Concurrency: Example

A = 500B = 500C = 500

AccountBalances

Bank database: 3 AccountsProperty: A + B + C = 1500 Money does not leave the system

Issues with Concurrency: Example

Read (A, s)s = s - 100Write (A, s)Read (C, s)s = s + 100Write (C, s)

Transaction T2: Transfer 100 from A to C

Read (A, t)t = t - 100 Write (A, t)Read (B, t)t = t + 100Write (B, t)

Read (A, s)s = s - 100Write (A, s) Read (C, s)s = s + 100Write (C, s)

Transaction T

Transaction T

A^

B^

C

Terminology

• Schedule:^ – The exact sequence of (relevant) actions of

one or more transactions

Problems

• Which schedules are “correct”?^ – Mathematical characterization • How to build a system that allows only“correct” schedules?^ – Efficient procedure to enforce correctness

Read (A, t)t = t - 100Write (A, t)Read (B, t)t = t + 100Write (B, t)

Read (A, s)s = s - 100Write (A, s)Read (C, s)s = s + 100Write (C, s)

A^

B^

C

Serial Schedule T1 T

Read (A, t)t = t - 100Write (A, t)Read (B, t)t = t + 100Write (B, t)

Read (A, s)s = s - 100Write (A, s)Read (C, s)s = s + 100Write (C, s)

A^

B^

C

Serial Schedule^ T2 T

Read (A, t)t = t - 100Write (A, t) Read (B, t)t = t + 100Write (B, t)

Read (A, s)s = s - 100Write (A, s) Read (C, s)s = s + 100Write (C, s) Transaction T

Transaction T Is this Serializable?

Read (A, t)t = t - 100Write (A, t)Read (B, t)t = t + 100Write (B, t)

Read (A, s)s = s - 100Write (A, s)Read (C, s)s = s + 100Write (C, s)

Equivalent Serial Schedule

Transaction T

Transaction T