CSC-313 Advanced Database Systems Lecture 4 PDF

Summary

Lecture notes from CSC-313 Advanced Database Systems, covering concurrency control, resource locking, and locking terminology. Authored by Farah Shaheen at The University of Haripur, the notes discuss implicit, explicit, exclusive, and shared locks.

Full Transcript

CSC-313 Advanced Database Systems Lecture 4 Concurrency Control By Farah Shaheen Acknowledgement: D...

CSC-313 Advanced Database Systems Lecture 4 Concurrency Control By Farah Shaheen Acknowledgement: Department of Information Technology – The UniversityLecture slides material from of Haripur Stuart Russell Resource Locking  One way to prevent concurrency problems is to lock the shared data.  Locking ensure that the shared data can be used by one user at one time.  When a user accesses the data, the second user to wait until the first user finishes its work.  For example: There is an item in the database with a value of 100.  If two users try to access the item to update it. Department of Information Technology – The University of Haripur 15 Example Department of Information Technology – The University of Haripur 16 Locking Terminology  Some important terms: Implicit Lock: It is a type of lock placed automatically by DBMS. Explicit Lock: It is a type of lock placed by application program by issuing a command. Exclusive Lock: A type of lock that locks an item from any type of access is known as exclusive lock. If a transaction locks an item using exclusive lock, no other transaction can read or change data. Shared Lock: A type of lock that locks an item from change but not from read is known as shared lock. If a transaction has locked an item using shared lock, the other transaction can only read the item but cannot modify it. Department of Information Technology – The University of Haripur 16 Locking Terminology Lock Granularity: The level of the lock applied on an item is known as lock granularity. Different levels of locks are as follows: Row level (Smallest lock granularity) Page level Table Level Database level (Largest lock granularity) A lock with large granularity is easy to maintain for DBMS but may cause problems. A lock with small granularity is difficult to maintain for DBMS but causes less problems. Department of Information Technology – The University of Haripur 16