liveBook · Manning

ACID

As explained in Digital Twins in Action

An ACID transaction is a database transaction characterized by atomicity, consistency, isolation, and durability guarantees.

ACID stands for atomicity, consistency, isolation, and durability. Together, these properties make database transactions reliable even when errors or system failures occur. section 4.3.1

Relational databases are useful for operational records that require these guarantees. For example, a relational model can store an industrial asset once and link it to multiple work orders and maintenance tasks. section 4.3.1

ACID guarantees can add latency and limit horizontal scalability. Critical operational data may justify that cost, while analytical workloads can sometimes accept eventual consistency for better performance and lower cost. High-volume sensor telemetry is often directed to storage that relaxes some constraints in favor of throughput. section 4.3.1 section 4.6

In a lakehouse, Delta tables add a transaction log and metadata layer over Parquet. This enables record-level inserts, updates, and deletes without manually rewriting entire files, bringing transactional guarantees to object-storage-based analytics. section 4.3.5

Listing 4.5 An example of using Delta tables to provide ACID transactions
import pandas as pd
from deltalake import DeltaTable, write_deltalake

def main():
  table_path = "./delta_demo/sensor_data"

  df1 = pd.DataFrame(  #1
      {
          "sensor_id": ["temp_001", "temp_002", "humidity_001"],
          "location": ["factory", "warehouse", "factory"],
          "value": [23.5, 18.2, 65.4],
          "timestamp": pd.to_datetime(["2024-01-15 10:30:00"] * 3),
      }
  )

  write_deltalake(table_path, df1)  #2
  print("Created Delta table with columns:", list(df1.columns))

  dt = DeltaTable(table_path)

  df_update = pd.DataFrame(  #3
      {
          "sensor_id": ["temp_001"],
          "location": ["factory"],
          "value": [24.1],  # Updated temperature
          "timestamp": pd.to_datetime(["2024-01-15 12:00:00"]),
          "unit": ["celsius"],
      }
  )

  dt.merge(  #4
      df_update,
      predicate="target.sensor_id = source.sensor_id",
      source_alias="source",
      target_alias="target",
  ).when_matched_update_all().when_not_matched_insert_all().execute()

The truncated Python listing creates a local Delta table of sensor readings and begins a merge with an updated reading. section 4.3.5

How Digital Twins in Action covers it

How deep it goes
Defines the four-property acronym and discusses storage tradeoffs, without explaining each property or transaction internals separately.
Examples
Illustrates transactional storage with linked asset and work-order records and a local Delta table containing sensor readings.
What you can do after
Evaluate/understand ACID tradeoffs when selecting storage for operational and analytical workloads.
How it connects
Connects ACID to relational databases, lakehouses, transaction logs, Parquet, and eventual consistency.

Also explained in

Compare how 7 books explain ACID →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Digital Twins in Action. The section links point to the parts of the book it draws on.