Download presentation
Presentation is loading. Please wait.
1
cs44321 CS4432: Database Systems II Lecture #19 Database Consistency and Transactions Professor Elke A. Rundensteiner
2
cs44322 Transactions, etc. Crash recovery Ch.8 [17] Concurrency control Ch.9 [18] Transaction processing Ch.10 [19]
3
cs44323 Integrity or correctness of data ? We would like data in our database to be “accurate” ( “correct” ) at all times. EMP How DBMS decides if data is consistent? Name White Green Gray Age 52 3421 1
4
cs44324 Integrity or consistency constraints Utilize predicates data must satisfy Examples: - x is key of relation R - x y holds in R - Domain(x) = {Red, Blue, Green} is valid index for attribute x of R - no employee should make more than twice the average salary
5
cs44325 Definitions: Consistent state: satisfies all constraints Consistent DB: DB in consistent state
6
cs44326 Such constraints may not capture “full correctness” Example 1 : Transaction constraints When salary is updated, new salary > old salary When account record is deleted, balance = 0
7
cs44327 Example 2 Database should reflect real world DB Reality Constraints ( as we use here) may not capture “full correctness”
8
cs44328 in any case, continue with constraints... Observation: DB cannot be consistent always Example: Constraint : a 1 + a 2 +…. a n = TOT Action: Deposit $100 in a 2 : a 2 a 2 + 100 TOT TOT + 100
9
cs44329 a 2 TOT.... 50.... 1000.... 150.... 1000.... 150.... 1100 Example: a 1 + a 2 +…. a n = TOT ( constraint ) Deposit $100 in a 2 : a 2 a 2 + 100 TOT TOT + 100
10
cs443210 Transaction: a collection of actions that preserve consistency Consistent DBConsistent DB’ T
11
cs443211 Big assumption: If T starts with consistent state AND T executes in isolation T leaves consistent state
12
cs443212 Correctness (informally) If we stop running transaction(s), DB left consistent Each transaction sees a consistent DB
13
cs443213 How can constraints be violated? Transaction bug DBMS bug Hardware failure e.g., disk crash alters balance of account Data sharing e.g.: T1: give 10% raise to programmers T2: change programmers systems analysts
14
cs443214 Will not consider: How to write correct transactions How to write correct DBMS system Constraint checking & repair
15
cs443215 How can we prevent/fix violations? Chapter 8[17]: due to failures only Chapter 9[18]: due to data sharing only Chapter 10[19]: due to failures and sharing
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.