0% found this document useful (0 votes)
12 views5 pages

U4T1 Transaction Concept

A transaction in a Database Management System (DBMS) is a set of logically related operations that involve tasks such as reading, writing, updating, deleting, and inserting data. Transactions can go through various states including active, partially committed, committed, failed, and aborted, depending on the success or failure of the operations performed. The document illustrates these concepts with an example of transferring money between accounts, detailing how transactions are managed and the implications of each state.

Uploaded by

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

U4T1 Transaction Concept

A transaction in a Database Management System (DBMS) is a set of logically related operations that involve tasks such as reading, writing, updating, deleting, and inserting data. Transactions can go through various states including active, partially committed, committed, failed, and aborted, depending on the success or failure of the operations performed. The document illustrates these concepts with an example of transferring money between accounts, detailing how transactions are managed and the implications of each state.

Uploaded by

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

Transaction Management

Transaction

What is transaction in DBMS?

· A transaction is a set of logically related operations. It contains a group of tasks.

· here set of operations nothing but (read, write ,update , delete , insert,commit)

· A transaction is an action or series of actions. It is performed by a single user to perform


operations for accessing the contents of the database.

Example:

· In Database what is means by Transaction , It means in Database the data is changing is called
Transaction.

· A transaction generally represent change in Database

· For Example :

Transfer of 50.Rs Amount from account X to account Y what are the taske may be occure
means

X's Account

1. Open_account(x) ---> open X's Account at the begining


2.old_balance=x.balance --> to retrive the a/c balance of X's and store the balance in buffer

3. new_bal=old_balance-50 --> to subtract 50Rs from X's account and after update X's balance

4.close_account(x) ---> finally close X's Account

Y's Account

1. Open_account(Y) ---> open Y's Account at the begining

2.old_balance=Y.balance --> to retrive the a/c balance of Y's and store the balance in buffer

3. new_bal=old_balance+50 --> to add 50Rs To Y's account and after update Y's balance

4.close_account(Y) ---> finally close Y's Account

· This group of taks is called Transaction

There are 4-operation Generally will happen in Transaction

A Transactio can include the following basic database access operation

1. Read(X) : Read operation is used to read the value of X from the database and stores it in a
buffer in main memory.

2. Write (X)- Write operations is used to write the value back to the database from the buffer.

Example

1. R(X); --> here 'R' read X value from Database

2. X=X-50 --> here reduce X value as 50 and update in same X

3. W(X) --> write 'X' value in DB

while the above both operation is running maybe the Hardware and software will failure ,that time the
transaction maybe not successfully , for that problem we can use the following two properties like
commit and rollback

3. Commit - commit is a transaction control language that is used to permanently save the
changes done in a transaction.

4. Rollback - it is used to undo the work done.

Transaction States
1. Active States

2. Partially Committed

3. Committed State

4. Failed State

5. Aborted Sate

Active State

· Transaction is currenctly being executed , and operations are taking place.

· it is in progress , and no error have occurred yet.

· When the instructions of the transaction are running then the transaction is in active state.

· If all the "read and write" operations are performed without any error then it goes to the "
partially committed state" , if any instruction fails , it goes to the " failed state"

Example :

Alice is transferring Rs 100 to John Account

The transaction is in the Active state while the system is deducting from Alice's Account and adding to
john account.

Partially Committed

· The Transaction has finished executing , but changes have not yet been permanently saved to
the data base.
· The system is checking if all the operations were successful.

· After completion of all the read and write operation the changes are made in main memory or
local buffer.

· if the changes are made permanent on the database then the state will change to "committed
state" and in case of failure it will go to the "failed state".

Example

After Alice's transfer , the system has updated Alice's account , bu john's account hasn't been updated
yet.

The transaction is partially committed while the system is making sure everything is okay.

Committed state:

· The transaction has completed successfully , and all changes have been permanently saved to
the database.

· The database is now in a consistent state.

· It is the state when the changes are made permanent on the data base and the transaction is
complete and therefore terminated in the "terminated state".

Example : Alice's Rs100 has been deducted from her account , and john's acccount is updated with the
Rs 100.

The transaction is now committed , meaning all changes are final.

Failed State:

· Something went wrong during the transaction , and it cannot proceed.

· The transaction is stuck and needs to be rolled back.

· the system cannot guarantee consistency unless the transaction is handled correctly.

· When any instruction of the transaction fails , it goes to the "failed state" or it failure occurs in
making a permanent change of data on Data base.

Example: Suppose the system crashes after deducting Rs100 from Alice's account , but before adding it
to john's .

The transaction is now failed because the operation was incomplete.

Aborted state

· The transaction is canceled and rolled back due to an error or failure.


· All changes made during the transaction are undone, and the database is returned to its
previous consistent state.

· After having any type of failure the transaction goes from "failed state" to "Aborted state" and
since in previouse states , the changes are only made to local buffer or main memory and hence
these changes are deleted or rolled-back

Example : After the crash , the system detects the incomplete transfer and rolls back the changes.

Allice's balance is restored to its original amount , and john's balance remains unchanged.

The transaction is aborted.

You might also like