Atomicity of ACID Properties | System Design | SDE Interview

Ganesh Prasad
3 min readJan 22, 2023

Atomicity is one of the four properties of the ACID (Atomicity, Consistency, Isolation, Durability) model, which is used to ensure the reliability and consistency of database transactions in a system design.

Atomicity refers to the ability of a transaction to be executed as a single, indivisible unit of work. This means that either all the operations in a transaction are completed successfully, or none of them are. If any operation in a transaction fails, the entire transaction is rolled back, and all changes made during the transaction are undone. This ensures that the database remains in a consistent state, even in the event of an error or system failure.

Example: Any transaction through an ATM is atomic in nature

An Example of Atomicity in the real world

To illustrate this concept, consider a banking system that allows customers to transfer money between accounts. In this system, a transaction might involve debiting one account and crediting another. If the debit operation is successful, but the credit operation fails, the database would be inconsistent.

This would mean that money would be missing from one account and not appear in the other. To avoid this, the transaction is rolled back, and all changes are undone so that the money remains in the original account.

To achieve atomicity, database systems use a technique called “transaction logging.” This involves recording all the changes made during a transaction in a log file. If a transaction is committed successfully, the changes are permanent and are written to the main database. If the transaction is rolled back, the changes are discarded, and the database is restored to its previous state.

Conclusion

In summary, atomicity is an important aspect of the ACID model and ensures the consistency and reliability of database transactions in a system design. It allows multiple operations to be executed as a single unit, and if any operation fails, the entire transaction is rolled back, ensuring that the database remains in a consistent state.

That’s all 👍🏼.

Thanks 🤗.

Want to Hire/Connect? LinkedIn

P.S.: If you like this uninterrupted reading experience on this beautiful platform of Medium.com, consider supporting the writers of this community by signing up for a membership HERE. It only costs $5 per month and helps all the writers.

A clap would be highly appreciated if you liked what you just read. You can be generous in clapping; it shows me how much you enjoyed this story. And if you didn’t like it? Please do comment😋!

--

--

Ganesh Prasad

Backend Developer at Appscrip | C++ veteran, 💜 Dart