What is a Transaction ?
In Database Management system, A Transaction is a single unit of many logical operations/work. In simple words, Any logical calculations done in a consistent mode in Database is known as Transaction. Best one example is ATM that we use on regular basis.
Example – Lets say person A is with having 300 Rs. & person B is having 200 Rs. Now person B wants to send 100 rs to person A. From the definition, Here the total unit of logical work are –
|Person A with Having 300 Rs|
and have supposed to receive 100 Rs from Person B
|Person B with having 200 Rs and wants to transfer 100 Rs to Person A|
|R(A);// Reading the data of A||R(B); // Reading the data of B|
|A= A+ 100; // Plus in total of A||B= B-100; // Minus in total of B|
|W(A); //Writing the data of A||W(B); //Writing the data of B|
|R(A) ; // Output comes as 400 Rs||R(B); // Output comes as 100 Rs.|
⇒ Now, What is consistent ?
- Consistency means the transaction will remain intact with the state prior to the transaction and later to the transaction. Like In this case, The person A gotten what he wants and person B also satisfied with his steps.
How all the transaction in ATM goes so that much fast ?
It is a very interesting thing that we can’t able to see with our real-time working with ATM like withdrawing or querying or etc. There are lots of code there but the main system is working, called as ‘ Schedule ‘
⇒ What is a Schedule ?
Schedule is nothing but, a combination of many transaction and determining how all the transactions can be performed. Whether the transactions can be interleaved or non-interleaved, the main focus is always to Increase the CPU utilization time by keep the CPU running while other transactions are doing I/O operations (Input-Output). Again if we take our main example, Writing & Reading the data of A or B is a I/O operation and A=A+100; is a logical work which is done by the CPU.
So, It is well clear that In ATM’s, transactions follow a speed process routine, combinations of schedules which is no doubt incredibly fast.
Ask your questions in the comment box, will try to answer each one and if you want more about “Transaction”, just leave your feedback.