Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
16 views4 pages

DBMS Transaction QA

A transaction in a DBMS is a unit of work that includes multiple SQL operations, ensuring data integrity through properties known as ACID (Atomicity, Consistency, Isolation, Durability). Concurrency control manages simultaneous transactions to prevent inconsistencies, while schedules dictate the execution order of these transactions. Serial schedules execute transactions one after another, whereas non-serial schedules interleave operations, potentially leading to concurrency issues, but both aim for a consistent final database state.

Uploaded by

sethpratham2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views4 pages

DBMS Transaction QA

A transaction in a DBMS is a unit of work that includes multiple SQL operations, ensuring data integrity through properties known as ACID (Atomicity, Consistency, Isolation, Durability). Concurrency control manages simultaneous transactions to prevent inconsistencies, while schedules dictate the execution order of these transactions. Serial schedules execute transactions one after another, whereas non-serial schedules interleave operations, potentially leading to concurrency issues, but both aim for a consistent final database state.

Uploaded by

sethpratham2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.What is a transaction in DBMS?

Answer:
A transaction is a single unit of work that consists of one or more SQL operations (like read,
write, update, delete), which must either be completed entirely or not at all. It ensures the
integrity of data in the database.
Example: -
Let’s consider an online banking application:
 Transaction: When a user performs a money transfer, several operations occur, such as:
o Reading the account balance of the sender.
o Writing the deducted amount from the sender’s account.
o Writing the added amount to the recipient’s account.
In a transaction, all these steps should either complete successfully or, if any error occurs, the
database should rollback to its previous state, ensuring no partial data is written to the system.

2. What are the properties of a transaction (ACID properties)?

Answer:
ACID stands for:

 Atomicity – All operations in a transaction are completed; if not, the transaction is


aborted.
Example:
If a user is transferring money from one account to another, both the debit and credit operations
must be successful, or none should happen. If any step fails, the transaction will be rolled back
entirely.

 Consistency – The database remains in a valid state before and after the transaction.

Example:
If an account balance before the transaction is 1000, after a successful deduction of transaction
of 200, the new balance should be 800, ensuring the database stays in a consistent state.

 Isolation – Transactions are isolated from each other until completed.

Example:
 Transaction 1: Withdraw $100 from account A.
 Transaction 2: Withdraw $200 from account A.
Both transactions should execute as if they are isolated from each other, and their changes
should not conflict.

 Durability – Once a transaction is committed, its changes are permanent, even in case of
system failure.
Example:
After transferring money between two accounts, if the system crashes, the changes made by the
transaction should still be saved when the system restarts.

3. What is the difference between commit and rollback?

Answer:

 COMMIT – Saves all the changes made by the transaction permanently in the database.
 ROLLBACK – Undoes all the changes made by the transaction if an error occurs or if
the transaction is not completed.

4. What is concurrency control in DBMS?

Answer:
Concurrency control ensures that multiple transactions can execute simultaneously without leading to
inconsistencies or data loss. It manages conflicts between transactions accessing the same data
concurrently.

5.What is schedule?

Answer:- A schedule is an execution sequence of operations from one or more transactions. The
process of queuing up transactions and executing them one by one is known as scheduling. When
there are numerous transactions operating at the same time, and the order of operations needs to
be determined so that the operations do not overlap, scheduling is used, and the transactions are
timed properly.

6. What is serial schedule and non-serial schedule?

Answer:- Serial Schedule:-

As the name says, all the transactions are executed serially one after the other. In serial Schedule,
a transaction does not start execution until the currently running transaction finishes execution.
This type of execution of the transaction is also known as non-interleaved execution. Serial
Schedules are always recoverable, cascades, strict, and consistent. A serial schedule always gives
the correct result.

T1 T2

R(A)

W(A)
T1 T2

R(B)

W(B)

R(A)

R(B)

In the above example T1 will execute first and then T2.

Non –serial Schedule: -

This is a type of Scheduling where the operations of multiple transactions are interleaved. This
might lead to a rise in the concurrency problem. The transactions are executed in a non-serial
manner, keeping the end result correct and same as the serial schedule. Unlike the serial
schedule where one transaction must wait for another to complete all its operation, in the non-
serial schedule, the other transaction proceeds without waiting for the previous transaction to
complete.

7. Write down the difference between serial and non-serial schedule?

Aspect Serial Schedule Non-Serial Schedule


Transactions execute one
Execution Transactions are interleaved
after another
Simplicity Simple and easy to implement More complex to manage
Naturally maintains May lead to inconsistency if not
Data Consistency
consistency controlled properly
No concurrency (slow Supports concurrency (better
Concurrency
performance) performance)
Risk of problems like dirty reads,
Risk of Conflicts No risk
lost updates
Concurrency Control
No Yes
Needed
Use in Practice Rare, mostly theoretical Common in real-world systems

8. What is serializability in DBMS?


Serializability is a key concept in concurrency control that ensures the correctness of a

schedule when multiple transactions are executed concurrently.

A schedule is serializable if its final outcome (database state) is the same as if the transactions were
executed one after another in some serial order.

Why is Serializability Important?

 Ensures data consistency during concurrent transaction execution.


 Allows the benefits of concurrency (speed and efficiency) without compromising
correctness.
 Types of Serializability:

Type Description
1. Conflict Based on conflicting operations (read/write) and ensures the schedule can
Serializability be transformed into a serial one by swapping non-conflicting operations.
2. View Based on views (read and write operations); more general but harder to
Serializability check than conflict serializability.

You might also like