Database Transaction in database management system
Database Transactions

Database Transaction in database management system

Hello friends! today we are going to learn another interesting topic. That is database transaction in database management system. Database transactions come as the advance concepts of database. Therefore lot’s of students troubles in these topics. Don’t worry go through the full post. You can learn easily. So let’s learn about database transactions.

We will discuss one by one topics. Firstly we will discuss What is transaction explain with examples. What is transaction in database with example. Then we will discuss What is transaction with it’s states. Transactions has states and you have to learn about the meaning of each. You might struggle with this chapter this might be the reason. You don’t know the basics. Therefore learn basics first. To understand transaction it’s mandatory to learn about read and write operations works in DBMS. It is the core to understand about transactions. What is read write operation in database and also what are the operation in a transaction. We will learn today

What is a database transaction in database management system

Firstly we will learn what is a database transaction. When we look at the database we have database implementations and execution sides. transactions are part of execution side of a database. I hope you know about implementation theories about databases. When we talk about database we have a physical and logical side. Physical means the data tables which we can see. Logical means the conceptual part that we cannot see. Query execution and all.

Database transaction definition

Transaction is a logical unit. It is something we cannot see. It is something logically happening. And also it is happening at the time database is processing, at the execution time. So transaction is a logical unit of database processing.

So let’s see what includes to this logical unit. You know in a database operations are executing. The queries. Basically databases executable queries consist two operations. They are read and write operations. So for a transaction can be one read or write operation or set of read and write operations.

Transaction boundaries

As you every thing has a end and start. For some UML diagrams as well as we draw start and end point. Transaction boundary means area that transaction has. So transaction has a begin then transaction operations are executing then transaction comes to the end. So it has a start and end. it is not something infinite. We can see the boundary of transaction.

Transaction states in database management system

Image showing transactions states
Image showing transactions states

Next we will discuss about transaction states. This is the foundation of transaction leaning. If you didn’t understand this topic you may fell in to problems later. This might be the reason that you couldn’t understand other topics. Don’t worry. We will learn one by one.

Transactions has six (6) states. As we discussed earlier transaction has start and end point. So when a transaction has started it has to come to the end point. Because it has a end. It can’t run infinite. So transactions in database is either completely executed or not executed at all. It has two states. Either executed or not. So how a transaction can be act as it was not executed at all. Since it was initially started. This is happening through transaction states. When transaction started to executed it has success path states and unsuccessful path states.

Successful path sates are Active -> partially committed -> Committed ->Terminated. Unsuccessful path states are Active -> Failed -> Abort ->Terminated. So all together these are the steps, states of a transaction. Active, Partially committed, committed, Terminate, Failed, Abort.

Transaction states in explanation

Active state – As long as a transaction is executing it’s operations that transaction is in the active state. In this time all the changes make by the transaction will be store in the memory buffer. We will discuss about that later.

Partially commit – You know a transaction can consist one or more operations. When last operation of the transaction has successfully executed the transaction is now moving from active status to partially commit state.

Commit – The changes making by a transaction stores in the memory buffer at the active time. When those changes permanently  will write to the actual database. We can identify that transaction was committed. It’s state is commit. That means the transaction executed successfully and the database values also updated successfully. Once the transaction has come to the commit state the transaction cannot be rollback. Rollback means undo the changes to the database that was done by the transaction.

Failed – When a transaction is in the active state and executing it’s operations. A transaction can face issues. When it faces those issues it cannot complete the rest of the operations successfully. Then the transactions are moving from active state to failure or failed state.

Abort – When a transaction couldn’t execute it’s operations successfully the changes made by that transaction up until now has to be undone. Other wise if not the transaction ACID properties cannot met. We will discuss about ACID properties later. Simply the consistency and accuracy of the data in the database will not met. So when a transaction came to the failed state the transaction will rollback and come to the abort state.

Terminate – This is the end state of a transaction. We previously discussed a transaction is either success or unsuccess. Either transaction was success or unsuccess the transactions will come to the terminate state. In the success path after the transaction enters to the committed state it will come to terminate state. When a transaction comes to the abort state then it will come to the terminate state.

Database transaction properties

Up until now we have discussed so many things about the transactions. Now we are going to discuss about properties of a transaction. We call the ACID properties. Let’s have a look about database transaction acid properties.

Atomicity – This property includes the details we have discussed until now. Transaction is atomic unit of database processing and we know it is the logical unit as well as. And  a transaction is either perform or not perform at all.

Consistency – When a database is updating by the changes that made by the transactions. It has to be the changes which made by correctly executed transactions. So the database is move from one consist state to another consist state.

Isolation – There can be thousand transactions execute in a one database. There is not one single transaction is execute in one database. The transactions can executed concurrently. But it can leads to the problems. We will discuss concurrency problems later. Because of that transaction should work as isolated and they should not see the changes made by other transaction to the same variables that they are working on. The transactions should work as isolated until it come to the commit state.

Durability – Once the changes has made to the database. Those changes has to available in the database. The changes can not be lost.

Conclusion

Today we learned about database transaction in database management system. I hope this article brought you many information. If you like this post please share this. You can comment your ideas and suggestions about this post. We are warmly accept your suggestions. You can comment from below comment box either go to our contact us page.  We provided so many valuable articles related to the database transactions. Please have a look if you are interested. Timestamping in database is one of them. We will meet with another interesting topic. Till then goodbye!

 

 

Audy Ranathunga

Audy Ranathunga, Author of myexamnote is our most experienced author. She has been working as a blog post writer for 4 years. She joined with myexamnote before 1 year ago and she has contribute lots of valuable posts for readers.

Leave a Reply