Introduction

ACID is an acronym for a set of properties for database transactions used to make sure data is valid.

Atomicity

A transaction is made up of multiple statements. For example, if you had $100 in your bank account then transferred $50 to another account with $100 that would be a transaction. Atomicity treats the entire transaction as one unit so that if one statement fails the entire transaction fails. In the previous example if the first part of the transaction succeeded and the second part failed but the transaction went through anyway that would just be a lost of money. Overall it would be better to just reject the entire transaction than to allow parts of it to succeed.

Consistency

Consistency ensures that integrity restraints are followed. This makes sure that after a transaction is completed the data is valid. In the previous example if you had $100 and transferred $50 to another account with $100 you would end up with $50 in the first one and $150 in the second one. If either part of the transaction failed you would either lose $50 or would gain $50, in that case the data would not be consistent and the transaction would fail.

Isolation

Transaction often occurs concurrently, at the same time, and isolation ensures that this does not lead to inconsistent data. It basically makes sure that if different transaction were executed one and a time the end result would be the same. An example of why you would need this is if two people accessed the same account of $100 and one person deposited $50 but the other person withdrew $50. Without isolation after the person deposited $50 the amount should be $150 but the other person still sees $100 and withdraws from that updating the amount to $50.

Durability

Durability is a simple principle where after a transaction has been committed the outcome will be saved even if the system fails for any reason. So if the transaction has been processed the data should be saved even if the system has to be restarted. If a person deposits $50 the person should still see the $50 in their account regardless if the system has gone down for any reason.

Conclusion

ACID are basic principles that all databases should follow to ensure data is safe and consistent when data is modified.

Written by

Hi

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store