Transactions are a unit of logical program execution that accesses and possibly updates various items in a database. It has its basic fundamental properties called ACID properties. ACID properties refer to the act of maintaining a transaction in a way that transaction can be done in isolation and properly updated in a database, and maintain atomicity and consistency of a transaction.
They are the required properties of a transaction described below in brief:
a. Atomicity: The full process must be completed at once or it doesn’t happen at all.
b. Consistency: The concept of not changing other data of a database only if it is affected by any users.
c. Isolation: Multiple transactions occur independently without interference.
d. Durability: Transaction done means the completion of the transaction, as well as the database update, will happen even in hardware failure.
It believes in the concept of either all or none. The failed transaction cannot be resumed it will be restarted again. Examples are ATM transactions, sessions expired.
In T1, there is no complete transaction, so it will not happen, it will just roll back for the complete transaction.
Before the transaction starts and after a transaction ends, the sum of money must be equal in both states.
E.g: A to B:Before transaction If A=2000, B=3000 sum=A+B=5000.
R(A) gives 2000
W(A) gives 1000 in local memory
R(B) gives 3000
W(B) gives 4000 in local memory
Commit //will update these trasactions in database hardware//
After transaction, A=1000, B=4000 sum=A+B=5000.
So, in this way, the example fulfills the concept of consistency.
Concept of converting parallel transactions into serial transactions. Independently the transaction is a logical unit operation that has several operations and those operations can work in isolation and gets the desired output without any distractions from another transaction that occurred. It maintains the transactional integrity of other systems.
While attempting to maintain the highest level of isolation, a DBMS usually acquires locks on data which may result in a loss of concurrency or implements multiple concurrency control. In a sense, it actually works to provide an environment where multiple transactions can take place at the same time without hampering one another.
It means once the transaction is done, and updated in the database it is not going to change except the user changes or deletes the transaction.
Durable means here the transaction is once done and saved in a database in a hardware form as a permanent change.
So, from the example of consistency, we can find the value of A=1000 and B=4000 as permanent changes. Conclusion: Committed data would never be lost, even in hardware failure. It is actually a backup of the database.
This is a brief description of ACID properties. You may also like Instances and Schemas.