# Database Transaction Models

## ACID Model

> *The ACID model provides a consistent system.*

* The ACID model ensures that a performed transaction is always consistent. This makes it a good fit for businesses that deal with online transaction processing (e.g., finance institutions) or online analytical processing (e.g., data warehousing).&#x20;

<table data-header-hidden><thead><tr><th width="142.33333333333331"></th><th></th></tr></thead><tbody><tr><td><strong>A</strong>tomicity</td><td><ul><li>"all or nothing"</li><li>If any part of the transaction fails entire transaction is aborted keeping the database unchanged.</li><li>each transaction is treated as a single unit, which succeeds completely or fails completely.</li></ul></td></tr><tr><td><strong>C</strong>onsistency</td><td><ul><li>enforces rules on data.</li><li>A processed transaction will never endanger the structural integrity of the database.</li><li>transactions can only take the data in the database from one valid state to another.</li></ul></td></tr><tr><td><strong>I</strong>solation</td><td><ul><li>Transactions cannot compromise the integrity of other transactions by interacting with them while they are still in progress.</li><li>concurrent transactions cannot interfere with one another and must result in a consistent database state.</li></ul></td></tr><tr><td><strong>D</strong>urability</td><td><ul><li>guarantees that once a transaction is committed, it will remain committed even in the state of power failure, or crash.</li><li>when a transaction has been committed, it will remain committed.</li></ul></td></tr></tbody></table>

#### Use Case Example&#x20;

* Financial institutions will almost exclusively use ACID databases. Money transfers depend on the atomic nature of ACID.
* An interrupted transaction that is not immediately removed from the database can cause a lot of issues. Money could be debited from one account and, due to an error, never credited to another.

## BASE Model

> *The BASE model provides high availability.*

<table data-header-hidden><thead><tr><th width="213"></th><th></th></tr></thead><tbody><tr><td><strong>B</strong>asically <strong>A</strong>vailable</td><td>BASE-modelled No-SQL databases ensure the availability of data by spreading and replicating it across the nodes of the database cluster.</td></tr><tr><td><strong>S</strong>oft State</td><td>Due to the lack of immediate consistency, data values may change over time.</td></tr><tr><td><strong>E</strong>ventually Consistent</td><td>The BASE model does not enforce immediate consistency. However, until it does, data reads are possible.</td></tr></tbody></table>

#### Use Case Example <a href="#ftoc-heading-6" id="ftoc-heading-6"></a>

* Marketing and customer service companies that deal with sentiment analysis will prefer the elasticity of BASE when conducting their social network research.&#x20;
* Social network feeds are not well structured but contain huge amounts of data that a BASE-modeled database can easily store.

{% hint style="info" %}
Which one to choose?

* Given their highly structured nature, ACID-compliant databases will be a better fit for those who require consistency, predictability, and reliability.
* Those who consider growth to be among their priorities will likely want to choose the BASE model because it enables easier scaling up and provides more flexibility.
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dailyjournal.gitbook.io/notes/databases/database/database-transaction-models.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
