{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CS122aSlides15

CS122aSlides15 - ICS122A EECS116 Introduction to Data...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
ICS122A / EECS116 Introduction to Data Management Spring 2009 Prof. Mike Carey Bren School of ICS UC Irvine Slides based on previous CS122a lecture notes as well as  material borrowed from U-Wisconsin, Stanford, & Berkeley
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CS122A/EECS116 Notes 15 2 Announcements Midterms Alex will have your leftover graded midterm exams available for pickup in the discussion section on Friday Homework and project related notes Project Part 3 is due tonight by midnight (Please include your latest E-R and relational schemas, as usual) HW #6 is available and due next Wednesday night (Note: A B+ tree can be built either by loading or by repeated insertions, with rather different shape consequences in the two cases) This week: Database programming concepts Last time: Client programming and stored procedures Today: Transactions and transaction management Any questions…?
Background image of page 2
Transactions So far you have studied how to: Write SQL queries and updates SELECT ; INSERT, DELETE UPDATE Write business logic that requires multiple SQL statements (plus control flow/logic) Stored procedures C/C++/Java client applications But what happens if … Other client programs run at the same time as yours? The system fails while your program is running? CS122A/EECS116 Notes 15 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Concurrent Execution Consider running two instances of the following business logic:            EXEC SQL  SELECT  A.balance                     INTO  :balance                  FROM   Accounts A                  WHERE  A.id = :accountId;          // now show the customer his/her balance and find out if they          // want to deposit ( delta > 0 ) or withdraw ( delta < 0 ) money          …          newBalance = balance + delta;           EXEC SQL   UPDATE  Accounts                     SET  balance = :newBalance                  WHERE  id = :accountId; CS122A/EECS116 Notes 15 4 S1 S2 S1: Read current account balance S2: Write new account balance (Compute new account balance) Reads + Writes:
Background image of page 4
Concurrent Execution ( cont. ) Let’s look at what can go wrong if user 1 tries to deposit $500 while user 2 tries to withdraw $200 from the same bank account (with $1000 initially) – User 1: S1 1 ; S2 1 (Therefore: R 1 ; W 1 ) – User 2: S1 2 ; S2 2 (Therefore: R 2 ; W 2 ) – Serial execution 1: R 1 ; W 1 ; R 2 ; W 2    1000; 1500; 1500; 1300 – Serial execution 2: R 2 ; W 2 ; R 1 ; W 1; 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 19

CS122aSlides15 - ICS122A EECS116 Introduction to Data...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online