0% found this document useful (0 votes)
34 views17 pages

ACID Properties in DBMS

The document explains the ACID properties of database transactions, which include Atomicity, Consistency, Isolation, and Durability, ensuring reliable data processing. Each property is detailed with its significance, implementation methods, and examples, emphasizing the importance of maintaining data integrity and reliability in databases. The document also discusses various isolation levels and mechanisms used by Database Management Systems to manage transactions effectively.

Uploaded by

Krisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views17 pages

ACID Properties in DBMS

The document explains the ACID properties of database transactions, which include Atomicity, Consistency, Isolation, and Durability, ensuring reliable data processing. Each property is detailed with its significance, implementation methods, and examples, emphasizing the importance of maintaining data integrity and reliability in databases. The document also discusses various isolation levels and mechanisms used by Database Management Systems to manage transactions effectively.

Uploaded by

Krisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Sharannyo Basu

Big Data | Data Structures

Understanding
ACID Properties
in Depth

SWIPE
ACID Properties 01

ACID Properties
Let's dive deep into the ACID properties of
database transactions. These four properties
are fundamental principles that guarantee
database transactions are processed
reliably, ensuring data validity despite errors,
power failures, and concurrent access.

Atomicity Consistency

Isolation Durability

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 02

Atomicity
The "All or Nothing" Principle

Atomicity ensures that a transaction is treated as a


single, indivisible unit of work.

This means that either all the operations within the


transaction are successfully completed
(committed), or none of them are (rolled back).

There's no in-between state where some operations


of a transaction are applied while others are not.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 03

Why it's Crucial?


Imagine a bank transfer. It involves debiting one
account and crediting another.

If the system fails after debiting the first account but


before crediting the second, the money would be lost
in transit, leading to an inconsistent database state.

Atomicity prevents this by ensuring that both the


debit and the credit happen together, or neither
happens at all. If any part of the transaction fails, the
entire transaction is rolled back to its original state.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 04

Implementation
Database Management Systems (DBMS) achieve
atomicity through mechanisms like transaction logs.

These logs record all the operations performed


within a transaction.

If a transaction fails before completion, the DBMS can


use the log to undo the partially completed
operations, effectively rolling back the database to
its state before the transaction began

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 05

Consistency
Consistency ensures that a transaction brings the
database from one valid state to another valid state.
A valid state is one that adheres to all the defined
rules and constraints of the database, including:

Integrity Constraints: Primary keys, foreign keys,


unique constraints, check constraints, and not-null
constraints.  

Business Rules: Application-specific rules that


govern the data.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 06

The Role of Transactions


A transaction must not violate these rules. If a
transaction attempts to perform an operation that
would violate a constraint or rule, the transaction will
be rolled back, and the database will remain in its
consistent state.

It's Not About External Reality


Consistency is about maintaining the internal
integrity of the database based on its defined rules. It
doesn't guarantee that the data in the database
perfectly reflects the real world, but it ensures that
the data within the database is logically sound
according to its schema and constraints.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 07

Implementation
The DBMS enforces consistency by checking all
constraints and rules before allowing a transaction
to commit. If any violation is detected, the
transaction is typically aborted and rolled back.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 08

Isolation
Concurrency Control: Isolation deals with how
multiple concurrent transactions interact with each
other.

It ensures that the execution of one transaction does


not interfere with the execution of other concurrent
transactions.

The goal is to make it appear as if each transaction


is running in isolation, even though they might be
executing simultaneously.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 09

Levels of Isolation 1/3


Achieving perfect isolation (where transactions are
truly serializable, meaning their concurrent execution
produces the same result as if they were executed
one after the other in some order) can impact
performance.

Therefore, SQL standards and DBMS


implementations define different isolation levels that
offer varying degrees of protection against
concurrency issues.

Common isolation levels (from least to most


restrictive) are listed in the next slide...

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 09

Levels of Isolation 2/3


Read Uncommitted: Allows a transaction to read
uncommitted changes made by other transactions.

This offers the lowest level of isolation and can lead


to "dirty reads."

Read Committed: Ensures that a transaction only


reads changes that have been committed by other
transactions.

This prevents dirty reads but can still lead to "non-


repeatable reads" and "phantom reads."

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 10

Levels of Isolation 3/3


Repeatable Read: Guarantees that within a
transaction, multiple reads of the same data will
return the same result.

This prevents dirty reads and non-repeatable reads


but can still allow phantom reads.  

Serializable: Provides the highest level of isolation.


It ensures that the concurrent execution of
transactions is equivalent to some serial execution of
those transactions.

This prevents dirty reads, non-repeatable reads, and


phantom reads but can have a significant
performance overhead.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 11

Implementation
DBMS use various locking mechanisms (shared locks
for reading, exclusive locks for writing) and multi-
version concurrency control (MVCC) to manage
isolation levels.

These mechanisms prevent conflicting operations


between concurrent transactions.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 12

Durability
Persistence of Data: Durability ensures that once a
transaction is committed, the changes made to the
database are permanent and will survive any
subsequent system failures, such as power outages,
crashes, or disk errors.

Why is it crucial?
Without durability, the benefits of atomicity and
consistency would be undermined. If a committed
transaction's changes could be lost due to a system
failure, the database would not be reliable.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 13

Implementation
Durability is typically achieved through

Transaction Logs: The DBMS writes a record of all


committed transactions to a persistent storage (the
transaction log) before acknowledging the commit
to the application.

Disk Writes: The actual data changes are


eventually written to the database files on disk.

Redundancy and Backups: Robust systems often


employ techniques like disk mirroring, RAID
configurations, and regular backups to further
ensure data persistence in the face of hardware
failures.

Sharannyo Basu
Big Data | Data Structures SWIPE
ACID Properties 14

The Commit Point


The point at which a transaction is considered
durable is usually when the log records of the
transaction have been successfully written to stable
storage (e.g., disk).

Sharannyo Basu
Big Data | Data Structures SWIPE
Thanks for reading!

Follow me for daily content on Big Data

You might also like