Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 25

INFO445 Advanced Database Design, Management, and Maintenance

Lecture 6: Advanced RDBMS


Professor Melody Y. Ivory-Ndiaye

Admin
Upcoming assignment(s)
Next Monday by noon
Lab Assignment #2

Exam #1 (wks 1-5)


Next Thursday

Last Time
QEPs
Optimization heuristics? How can understanding them help us to write more efficient queries?

Storing data
How is data stored and its implications? What DBMS components play a role?

Outline
Interface

Transaction Manager

SQL Commands

Reproduced from Database Management Systems, by Ramakrishnan and Gehrke, pg 20

Transactions
What is a transaction? What is the rationale for executing transactions concurrently? What can go wrong if transactions are not interleaved properly? What four properties need to be ensured for transactions? How does a DBMS ensure these four properties? How does the DBMS enable you to control transactions?
6

Transaction Operations
What sequences of operations are needed for the following transactions (reads/writes)?
deposit $50 to A compute total balance for A and C check balance and withdraw $100 from A transfer $100 from A to C

Scheduling Concurrent Transactions


The Scheduler
Establishes the order in which the operations within concurrent transactions are executed Interleaves the execution of database operations to ensure serializability
What does it mean to ensure serializability?

To determine the appropriate order, the scheduler bases its actions on concurrency control algorithms, such as locking or time stamping methods
Discussed next time

Makes sure that the computers CPU is used efficiently

Serializability
Schedule
Sequence of reads/writes by set of concurrent transactions
E.g., R1(a), R2(a), W2(a), W1(a)

Serial Schedule

Nonserial Schedule

Schedule where operations of each transaction are executed consecutively without any interleaved operations from other transactions Schedule where operations from set of concurrent transactions are interleaved Objective of serializability is to find nonserial schedules that allow transactions to execute concurrently without interfering with one another In other words, want to find nonserial schedules that are equivalent to some serial schedule; such a schedule is called serializable
Produces the same final state as a serial schedule

18

Serial vs. Nonserial Schedule?


Example
T: transfer $100 from A to C S: transfer $100 from B to C

18

10

Conflicts
Might there be conflicts
If two transactions only read a data item? If two transactions either read or write completely separate data items? If one transaction writes a data item and another reads or writes same data item?

20

11

Example Conflicts
Lost update (blind write or WW conflict)?
T: transfer $100 from A to C S: transfer $100 from B to C
T R(A) R(B) W(A) W(B) R(C) R(C) S

W(C) W(C)

12

Example Conflicts
Inconsistent retrieval (dirty read or WR conflict)?
T: transfer $100 from A to C S: compute total balance for A and C
T R(A) W(A) R(A) R(C) R(C) S

W(C)

13

Example Conflicts
Unrepeatable reads (RW conflict)?
T: transfer $100 from A to C S: check balance and withdraw $100 from A
T R(A) R(A) W(A) R(C) R(A) W(C) W(A) S

14

Serializable Schedules
How do we resolve schedule conflicts? A schedule is conflict serializable if it is conflict equivalent to some serial schedule
i.e., can be transformed into a serial schedule by a series of swaps of nonconflicting actions

15

Conflict Resolution
Avoid lost update (blind write or WW conflict)?
T: transfer $100 from A to C S: transfer $100 from B to C
T R(A) R(B) W(A) W(B) R(C) R(C) S

W(C) W(C)

16

Conflict Resolution
Avoid inconsistent retrieval (dirty read or WR conflict)?
T: transfer $100 from A to C S: compute total balance for A and C
T R(A) W(A) R(A) R(C) R(C) S

W(C)

17

Conflict Resolution
Avoid unrepeatable reads (RW conflict)?
T: transfer $100 from A to C S: check balance and withdraw $100 from A
T R(A) R(A) W(A) R(C) R(A) W(C) W(A) S

18

Precedence (Serializability) Graph


Captures potential conflicts between transactions in a schedule Create:
A node for each transaction An arc from Ti to Tj if an action of Ti precedes and conflicts with an action of Tj
if Tj reads the value of an item written by Ti if Tj writes a value into an item after it has been read or written by Ti

A schedule S is conflict serializable IFF P(S) is acyclic


23

19

Example
T3 T1 T2

20

Break

21

Activity I

22

Project Discussion
Each project
Status Report Challenges Design evolution How might understanding DBMS functionality influence future design evolution?

23

In Summary
Transaction operations need to be interleaved to improve performance
How is interleaving accomplished? How are conflicts identified? How are conflicts resolved? What is a precedence graph and what is its role?

24

25

You might also like