Presentation is loading. Please wait.

Presentation is loading. Please wait.

Managing Multi-User Databases (2) IS 240 – Database Management Lecture #19 – 2004-04-22 Prof. M. E. Kabay, PhD, CISSP Norwich University

Similar presentations


Presentation on theme: "Managing Multi-User Databases (2) IS 240 – Database Management Lecture #19 – 2004-04-22 Prof. M. E. Kabay, PhD, CISSP Norwich University"— Presentation transcript:

1

2 Managing Multi-User Databases (2) IS 240 – Database Management Lecture #19 – 2004-04-22 Prof. M. E. Kabay, PhD, CISSP Norwich University mkabay@norwich.edu

3 2 Copyright © 2004 M. E. Kabay. All rights reserved. ACID Transactions Transactions sometimes described as ideally ACID Atomic: all changes committed or none Consistent: see later slides Isolated: see later slides Durable: not reversible once committed

4 3 Copyright © 2004 M. E. Kabay. All rights reserved. Consistency Statement-level consistency If change is supposed to apply to group of records, then no changes to any of those records will be permitted until all records have been changed Transaction-level consistency Same principle applied to multiple steps Not always easy to achieve If locking applied around very long processes, will see performance / throughput degradation for other users May want to limit long updates to batch processing during off-hours

5 4 Copyright © 2004 M. E. Kabay. All rights reserved. Transaction Isolation Level Can have difficulties / inconsistencies when concurrent processes access intermediate results during transactions Dirty read: access a record changed by another process but not yet committed Nonrepeatable read: some other process has altered the original record (e.g., during optimistic locking) Phantom read: a new movie by George Lucas – NO NO – means new records inserted or deleted since last read

6 5 Copyright © 2004 M. E. Kabay. All rights reserved. ANSI SQL Isolation Levels Can specify degree of protection desired

7 6 Copyright © 2004 M. E. Kabay. All rights reserved. Cursors (1) Cursor = pointer for records / rows Application program opens cursor, Starts reading data at first row = Points at the first row May have more than 1 cursor open in table SQL: DECLARE CURSOR TransCursor AS SELECT * FROM TRANSACTION WHERE PurchasePrice > 10000

8 7 Copyright © 2004 M. E. Kabay. All rights reserved. Cursors (2) Cursors establish buffers in memory Can take considerable resources Therefore save resources using reduced- functionality cursors Four types in Windows 2000 Forward only Static Keyset Dynamic See Figure 11-11 (information broken down into following slides) Scrollable cursors

9 8 Copyright © 2004 M. E. Kabay. All rights reserved. Forward-Only Cursor Simplest Move forward through recordset If changes occur in recordset due to activity using other cursors, will be invisible to this cursor unless they occur ahead of cursor

10 9 Copyright © 2004 M. E. Kabay. All rights reserved. Static Cursor Snapshot of file when it was opened Like making a copy of (part of) a file Can move forward and backward through recordset Changes made using this cursor can be seen (read) by this cursor No other changes are visible to this cursor

11 10 Copyright © 2004 M. E. Kabay. All rights reserved. Keyset Cursor Similar to static cursor Snapshot (copy) of records But keeps track of original primary key value in each record When application moves cursor to a record, DBMS goes to the actual table and Reads record into cursor buffer using original key value Updates are visible as are deletions New records from other cursors are invisible Because there is no key for them in the keyset cursor

12 11 Copyright © 2004 M. E. Kabay. All rights reserved. Dynamic Cursor Constantly retrieves current data from file Changes of any type and any source are visible All inserts, updates, deletes potentially visible Isolation level will determine details Dirty Read implies uncommitted changes also visible to this cursor All other levels imply only committed changes are visible to this cursor

13 12 Copyright © 2004 M. E. Kabay. All rights reserved. Choosing Cursors No easy general rule Type influences overhead and performance Each DBMS can implement cursors differently Be careful about default levels Can be contrary to your intentions Can lead to race conditions and data corruption Forward-only Static Keyset Dynamic

14 13 Copyright © 2004 M. E. Kabay. All rights reserved. Homework Study Chapter 11, pp. 307-311 thoroughly. Read the rest of Chapter 11 in preparation for the next (LAST!) class on Tuesday REQUIRED: By Thursday 29 April 2004, for 32 points, complete questions 11.21-11.36 (remember to include the questions in your answer sheets). OPTIONAL: Also by Tuesday 29 April, for 3 points each, complete either or both of 11.50 & 11.51 on p. 327.

15 14 Copyright © 2004 M. E. Kabay. All rights reserved. Final Exam Thursday 6 May 2004 08:00-10:30 Dewey 211 Covers entire course material T/F, short answer, diagrams, short essay,

16 15 Copyright © 2004 M. E. Kabay. All rights reserved. DISCUSSION


Download ppt "Managing Multi-User Databases (2) IS 240 – Database Management Lecture #19 – 2004-04-22 Prof. M. E. Kabay, PhD, CISSP Norwich University"

Similar presentations


Ads by Google