170 likes | 198 Views
Database Management System. Lecture - 42. Transaction. Generally reflects the activities in the real world system One transaction in our exam system may be computing gpa of a student, Operations involved….. More complex transactions. Consistent State of DB. Consistent state of the database
E N D
DatabaseManagement System Lecture - 42
Transaction • Generally reflects the activities in the real world system • One transaction in our exam system may be computing gpa of a student, Operations involved….. • More complex transactions
Consistent State of DB • Consistent state of the database • Duplicated data does not conflict • DB properly reflect the real-world system, i.e. follows the business rules • A transaction should transform database from one consistent state to another consistent state, may be inconsistent temp
Transaction Termination • Two ways a transaction terminates or ends • It may Commit or Abort • If executed successfully, brings the database in a new consistent state, said to be committed
Transaction Termination • If otherwise, database has to be brought in prior consistent state • Such transaction is rolled back or undone • A committed transaction cannot be undone; compensating transaction
Transaction Boundaries • Means being and end of Tr • Generally responsibility of programmer • Otherwise approach varies from DBMS to DBMS
ACID Properties • Atomicity: all or none • Consistency: maintains consistency of the DB • Isolation: Tr should be protected form the effect of other Trs • Durability: changes by Tr are permanent
Database Updates • Updates are first made in the buffers in RAM, then transferred to database • There may be some delay between the two
Database Recovery • If a crash occurs during this delay then the database is in in consistent state • On restart DBMS has to identify it and recover DB into a consistent state
Reasons of Failure • Natural disaster • Sabotage • Carelessness • Disk crash • System software errors • Generally, improper shut down of DBMS
Recovery Techniques • System crashes, buffers are lost but the disk copy is safe • Need to determine the transactions that need to redone or undone
Log File • Tool used for database recovery • Transaction Record • <T, starts> • <T, commits> or <T, aborts> • Data entries?
Transaction Operations Read (X) X = X + 5 Write (X) Y = Y * 3 Write (Y) Commit • Operations of DBMS concern • Concern of Recovery Manager • So log file contains entries only for write operations
Deferred Updates • Called incremental log with deferred updates • Updates are not performed until commit is encountered • Data entries in the log file of the form <T, X, c>; simplified
Log File Entries <T, starts> <T, X, 55> <T, Y, 30> <T, commit> Read (X) X = X + 5 Write (X) Y = Y * 15 Write (Y) Commit Supposing X = 50 Y = 10
DatabaseManagement System Lecture - 42