Showing posts with label Database Quizzes. Show all posts
Showing posts with label Database Quizzes. Show all posts

Sunday, December 12, 2021

DBMS MCQ - System crash and the state of a transaction

Multiple choices questions in DBMS, Transaction states in database, What will go wrong to a transaction in case a system crash happens during its execution? Aborted, partially committed, committed and active states of transaction. What are the different possibilities that lead a transaction to fail?

DBMS MCQ - System crash and state of a transaction

< Previous                      

Next >

 

7. Consider the transaction T1 as given below; T1 enters into which of the following states if there is a system crash after the instruction 5?

T1

1

2

3

4

5

6

7

8

Begin_transaction

Read(A)

A:=A-500;

Write(A);

Read(B)

B:=B+500;

Write(B);

Commit;

 

a) Partially committed

b) Committed

c) Aborted

d) Failed

Answer: (d) Failed

A transaction enters into FAILED state if the transaction cannot be committed or the transaction is aborted while in the ACTIVE state, perhaps due to the user aborting the transaction or as a result of system failures (system crash, transaction errors, disk failures etc.) or as a result of the concurrency control protocol aborting the transaction to ensure serializability.

The transaction at FAILED state is rolled back to undo the changes made to the data items and ABORTED.

Transaction states

Active - if a transaction starts its execution it is said to be in active state

Partially committed - if a transaction successfully executed it last statement

Committed - if a transaction successfully executed commit statement.

Failed - if a transaction is not able to proceed for various reasons (refer above)

Aborted - if a transaction reached a failed state, then it will be aborted.

 



< Previous                      

Next >


************************
Related posts:


What will happen to a transaction if a system crash has occurred during its execution?

List down different situations that lead a transaction to fail

What are the possible causes that make a transaction to fail its execution?

Different states of transactions in dbms

Serializability and Concurrency control in DBMS

Wednesday, December 8, 2021

DBMS MCQ - What is dirty read in DBMS transactions

Multiple choices questions in DBMS, What is dirty read in database? What will go wrong if a transaction is allowed to read a data item that was written by an uncommitted transaction? Why dirty read is not a preferable one? Can we permit a transaction that has used a data item written by another uncommitted transaction to commit? What are the problems with dirty read?

DBMS MCQ - Dirty read by transactions

< Previous                      

Next >

 

1. If a transaction is allowed to read a data item that was produced by an uncommitted transaction, what do we call this read? 

a) Repeatable read

b) Phantom read

c) Dirty read

d) Conflict read

Answer: (c) Dirty read

Reading the value of a data item that was produced by an uncommitted transaction is referred as dirty read problem. This will be avoided if we permit transactions to read the values that are produced by committed transactions.

Possible problems with dirty read in database

  • It may result in non-recoverable schedule. This is possible if a transaction T1 consumes the data written by T2 but commits before T2, and T2 decided to rollback.
  • It may lead to cascading rollback. This situation is possible if a transaction T3 consumes the data written by T2 which in turn read the data from another transaction T1, and T1 decided to rollback.
  • A dirt read can cause duplicate rows to be returned where none exist. alternatively, a dirty read can cause no rows to be returned when one (or more) exists. In some cases, dirty reads can return data that was never in the database at all (eg. rolled back before commit).

How you may avoid dirty read?

You can set the TRANSACTION ISOLATION LEVEL as READ COMMITTED. This specifies that the statements cannot read data that has been modified but not committed by other transaction. This prevents dirty reads.


< Previous                      

Next >


************************
Related posts:


What is non-recoverable schedule?

How dirty read may lead to non-recoverable schedules?

How to avoid deadlock in database environment?

List down the possible problems with dirty read

Concurrency control in DBMS

What would go wrong if a transaction is allowed to go for dirty read?

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