
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How Locks are Used in DBMS
In a transaction, a data item which we want to read or write should first be locked before any read or write operation. After the operation is over, the transaction unlocks the data item so that other transactions can lock that same data item for their use.
Example
Let us see how locking mechanisms help us to create error free schedules.
An erroneous schedule is as follows −
Here t2 reads A, before A is modified in T1. This will result in inconsistency.
Now we use locking mechanism in the above schedule which is shown below −
Until T1 performs Unlock(A) T2 cannot access A. So, the inconsistency is removed automatically, and the schedule becomes a correct schedule. The use of locks helps to create a correct concurrent schedule.
Advertisements