Tuesday, February 28, 2023

RDBMS MCQ - Phantom read problem in database transactions

Multiple choices questions in DBMS, Interview questions in RDBMS, What is phantom read? Example transactions that result in phantom read, define phantom read, given a schedule find the problem in it

RDBMS solved MCQ - Phantom read and concurrency control

< Previous                      

Next >


1. What is the problem with the following schedule?

Phantom read example

a) Repeatable read problem

b) Lost update problem

c) Phantom read problem

d) Dirty read problem

Answer: (c) Phantom read problem

Transaction T1 finds the number of records (count) of Employee table, updates the salary of all employees using the count, and then commits. Transaction T2 inserts a new record into Employee table and commits.

Suppose that Employee has 50 records before T2 starts. That makes the value of X 50. Now, T2 inserts a new record and commits. Hence, the actual count becomes 51. So, UPDATE statement in T1 updates all the salaries (including the one which is newly inserted – the phantom read) by using the X value as 50 (not as 51).

What is phantom read?

The so-called phantom problem occurs within a transaction when the same query produces different sets of rows at different times. For example, if a SELECT is executed twice, but returns a row the second time that was not returned the first time, the row is a “phantom” row.

A phantom read occurs when a transaction retrieves a set of rows twice and new rows are inserted into or removed from that set by another transaction that is committed in between.


< Previous                      

Next >

Related posts:

What is phantom read?

When phantom read is unwanted

Phantom read in concurrency control example

Example schedule that results in phantom read

Transaction isolation levels in dbms and phantom read

DBMS solved MCQ; database management system MCQ solved questions 

No comments:

Post a Comment

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

data recovery