We are listening to your every feedback,
and taking action to constantly improve your learning experience.
If you have any feedback, please use this form:
- Click here to access our Premium Algorithms course.
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 transaction, certain properties are followed. T hese are called ACID properties.
Atomicity:Atomicity is also known as the ‘All or nothing rule’.
Each transaction is considered as one unit and either runs to completion or is not executed at all. There is no midway i.e. transactions do not occur partially. It involves following two operations.
- Abort: If a transaction aborts, changes made to database are not visible.
- Commit: If a transaction commits, changes made are visible.
Consistency:Database state is consistent before and after the transaction. It has to do with Referential Integrity: A transaction should not try to delete a row whose primary key is foreign key in at least one other table, if the record with the foreign key is not deleted before.
Isolation:Isolation is all about Concurrency Control i.e having concurrent transactions in safe and proper way. Two transactions should not try to modify the same data at the same time. If two transactions are to work on same data then one must wait for the other transaction to get complete. More on this here.
Durability:Durability is all about data persistence. All data modification done by a transaction should be stored in some non-volatile memory when a transaction succeeds. An example of durability failure is Consider a transaction that transfers 10 from A to B. First it removes 10 from A, then it adds 10 to B. At this point, the user is told the transaction was a success, however the changes are still queued in the disk buffer waiting to be committed to disk. Power fails and the changes are lost. The user assumes (understandably) that the changes persist.
The ACID properties, in totality, provide a mechanism to ensure correctness and consistency of a database in a way such that each transaction is a group of operations that acts a single unit, produces consistent results, acts in isolation from other operations and updates that it makes are durably stored.
Check out our other System Design content here.
Click here to access our Premium Content on Algorithms .
The above content is written by:
If you have any feedback, please use this form: https://thealgorists.com/Feedback.
Follow Us On LinkedIn