第 2 页
Integrity or correctness of data • Would like data to be “accurate” or “correct” at all times EMP Name Age White 52 Green 3421 Blue 1 2
Integrity or correctness of data • Would like data to be “accurate” or “correct” at all times EMP Name Age White 52 Green 3421 Blue 1 2
Integrity or consistency constraints • Predicates data must satisfy • Examples: - x is key of relation R - x → y holds in R (functional dependency) - Domain(x) = {Red, Blue, Green} - a is valid index for attribute x of R - no employee should make more than twice the average salary 3
Constraints (as we use here) may not capture “full correctness” Example 1 Transaction constraints • When salary is updated, new salary > old salary • When account record is deleted, balance = 0 5
Constraints (as we use here) may not capture “full correctness” Example 2 Database should reflect real world Reality DB 7
in any case, continue with constraints... Observation: DB cannot be consistent always! Example: a1 + a2 +…. an = TOT (constraint) Deposit $100 in a2: a2 a2 + 100 TOT TOT + 100 8
Example: a1 + a2 +…. an = TOT (constraint) Deposit $100 in a2: a2 a2 + 100 TOT TOT + 100 .. .. .. a2 50 150 150 .. .. .. TOT 1000 1000 1100 9
Assumption: If T starts with DB in consistent state + T executes in isolation T leaves DB in consistent state 11
Correctness (informally) • If we stop running transactions, DB left consistent • Each transaction sees a consistent DB 12
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 13
How can we prevent/fix violations? • Due to failures only • Due to data sharing only • Due to failures and sharing 14
Will not consider: • How to write correct transactions • How to write correct DBMS • Constraint checking & repair That is, solutions studied here do not need to know constraints 15
Desired events: see product manuals…. Undesired expected events: System crash - memory lost - cpu halts, resets that’s it!! Undesired Unexpected: Everything else! 19
Undesired Unexpected: Everything else! Examples: • Software bugs • Disk data is lost • Memory lost without CPU halt • CPU implodes wiping out universe…. 20
显示前 20 页。下载资料查看完整内容。
暂无评论。快来抢沙发吧!
评论 (0)
暂无评论。快来抢沙发吧!