You are on page 1of 4

A SHORT NOTE ON

TRANSACTION IN DATABASE
MANAGEMENT SYSTEM

Course No: CSE 3101


Course title: Database System

Submitted To:
Professor Dr. Md. Anisur Rahman
Computer Science & Engineering Discipline
Khulna University, Khulna

Submitted By:
Mridha Imran Kabir
Student Id: 180202
3rd year, I term
Computer Science and Engineering Discipline
Khulna University, Khulna
What is Database Transaction?
A transaction is an action or series of actions that are being performed by a single user or
application program, which reads or updates the contents of the database. A transaction can be
defined as a logical unit of work on the database. This may be an entire program, a piece of a
program, or a single command (like the SQL commands such as INSERT or UPDATE), and it may
engage in any number of operations on the database.

ACID properties: A transaction is a single logical unit of work which accesses and possibly
modifies the contents of a database. Transactions access data using read and write operations.
In order to maintain consistency in a database, before and after the transaction, certain
properties are followed. These are called ACID properties.

Atomicity: A transaction is a single unit of operation. You either execute it entirely or do not
execute it at all. There cannot be partial execution.
Consistency: Once the transaction is executed, it should move from one consistent state to
another.

Isolation: Transaction should be executed in isolation from other transactions (no Locks). During
concurrent transaction execution, intermediate transaction results from simultaneously
executed transactions should not be made available to each other. (Level 0,1,2,3)
Durability: After successful completion of a transaction, the changes in the database should
persist. Even in the case of system failures.

States of Transaction: Each transaction has following 5 states:


Active: This is the first state of transaction and here the transaction is being executed. For
example, updating or inserting or deleting a record is done here. But it is still not saved to the
database. When we say transaction it will have a set of small steps, and those steps will be
executed here.
Partially Committed: This is also an execution phase where the last step in the transaction is
executed. But data is still not saved to the database.
Committed: In this state, all the transactions are permanently saved to the database. This step is
the last step of a transaction, if it executes without fail.
Failed: If a transaction cannot proceed to the execution state because of the failure of the system
or database, then the transaction is said to be in a failed state.
Aborted: If a transaction is failed to execute, then the database recovery system will make sure
that the database is in its previous consistent state. If not, it brings the database to consistent
state by aborting or rolling back the transaction. If the transaction fails in the middle of the
transaction, all the executed transactions are rolled back to its consistent state before executing
the transaction. Once the transaction is aborted it is either restarted to execute again or fully
killed by the DBMS.

Facts about Database Transactions :


o A transaction is a program unit whose execution may or may not change the contents of
a database.
o The transaction concept in DBMS is executed as a single unit.
o If the database operations do not update the database but only retrieve data, this type of
transaction is called a read-only transaction.
o A successful transaction can change the database from one CONSISTENT STATE to
another.
o DBMS transactions must be atomic, consistent, isolated and durable.
o If the database were in an inconsistent state before a transaction, it would remain in the
inconsistent state after the transaction.
What is a Schedule?
A Schedule is a process creating a single group of the multiple parallel transactions and executing
them one by one. It should preserve the order in which the instructions appear in each
transaction. A schedule can be of two types:

• Serial Schedule: When one transaction completely executes before starting another
transaction, the schedule is called serial schedule. A serial schedule is always consistent.
• Concurrent Schedule: When operations of a transaction are interleaved with operations
of other transactions of a schedule, the schedule is called Concurrent schedule.

What is Serializability?
Serializability is the process of search for a concurrent schedule who output is equal to a serial
schedule where transactions are executed one after the other. Depending on the type of
schedules, there are two types of Serializability:

• Conflict: A schedule is called conflict serializable if it can be transformed into a serial


schedule by swapping non-conflicting operations.
• View: A Schedule is called view serializable if it is view equal to a serial schedule (no
overlapping transactions).
What is Recoverability?
Sometimes a transaction may not execute completely due to a software issue, system crash or
hardware failure. In that case, the failed transaction has to be rollback. But some other
transaction may also have used value produced by the failed transaction. So, we also have to
rollback those transactions.

Concurrency in Transactions: A database is a shared resource accessed. It is used by many users


and processes concurrently. For example, the banking system, railway, and air reservations
systems, stock market monitoring, supermarket inventory, and checkouts, etc.
Not managing concurrent access may create issues like:
o Hardware failure and system crashes
o Concurrent execution of the same transaction, deadlock, or slow performance

You might also like