DEV Community

Cover image for A.C.I.D. and The Database: An intro
Larry Schwall
Larry Schwall

Posted on • Edited on

A.C.I.D. and The Database: An intro

A.C.I.D. refers to a compliance checklist that is followed to create a working and reliable database. In order to work with the database and transfer information, we use something called a transaction.

A transaction is a single instance of work which performs some actions or modifies content in a database. Using A.C.I.D. compliance, we can ensure that our databases are built with consistency.


A.C.I.D.

A- atomicity
C- consistency
I- isolation
D- durability


Atomicity

Atomicity defines itself using the 'All or nothing' rule. It is treated as an atomic unit - meaning all the operations are done or none. There is to be no state in the storage that is partially completed. It uses two operations:

  • Abort
  • Commit

Abort: if the transaction aborts at anytime, changes mades in the database are not visible.

Commit: if a transactions commits, the changes are visible.

This atomicity type system must assure atomicity in every instance, including - but not limited to - errors/crashes, and power failures.


Consistency

Consistency defines itself using constraints. This holds the databases integrity to a very high standard. It makes sure that the database is consistent before and after the transaction.

This compliance makes sure a transaction can bring the database from one valid state to another. It checks on the correctness of the database. The state of the database should not change before or after any instance of work.

Consistency refers to pre-conditions, post-conditions, and transformational-conditions on any instance of work.


Isolation

Isolation defines itself using separation tactics. This ensures that every transaction will never interfere with another transaction. It also ensures that multiple transactions can occur without losing consistency in the database. Isolation persists that any transaction occurring a certain way will not be visible to any other until it has completed successfully.

According to Jim gray there are various degrees of isolation:

0 deg... a transaction does not overwrite data updated by another user or process ("dirty data") of other transactions

1 deg... degree 0 plus a transaction does not commit any writes until it completes all its writes (until the end of transaction)

2 deg... degree 1 plus a transaction does not read dirty data from other transactions

3 deg... degree 2 plus other transactions do not dirty data read by a transaction before the transaction commits


Durability

Durability defines itself using storage techniques. This ensures that once a transactions is completed successfully, it will be stored onto a server/hard disk and will persist. Persist meaning that even if the system fails, the data will stay the same. The updates to the data are now permanent and stored in memory. The recovery system of databases makes sure that each transactions complies to this durability measurement.

Some things to consider in regards to failures:

  • Recovery to most recent successful commit after database failure
  • Recovery to most recent successful commit after failure of CPU
  • Recovery to most recent successful commit after failure of Hard disk
  • Recovery to most recent successful commit after failure of software ___ ### Summary

The A.C.I.D. compliances ensure that databases retain their sustainability. These checks also make sure the correctness and consistency of databases. Each transaction will act as a single entity, consistent each time they are executed, isolated from one another, be stored in disks that are checked for durability over time.

Top comments (0)