<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
ACID	O
(	O
atomicity	B-Operating_System
,	I-Operating_System
consistency	I-Operating_System
,	I-Operating_System
isolation	I-Operating_System
,	I-Operating_System
durability	I-Operating_System
)	O
is	O
a	O
set	O
of	O
properties	O
of	O
database	B-General_Concept
transactions	I-General_Concept
intended	O
to	O
guarantee	O
data	O
validity	O
despite	O
errors	O
,	O
power	O
failures	O
,	O
and	O
other	O
mishaps	O
.	O
</s>
<s>
In	O
the	O
context	O
of	O
databases	O
,	O
a	O
sequence	O
of	O
database	O
operations	O
that	O
satisfies	O
the	O
ACID	B-Operating_System
properties	I-Operating_System
(	O
which	O
can	O
be	O
perceived	O
as	O
a	O
single	O
logical	O
operation	O
on	O
the	O
data	O
)	O
is	O
called	O
a	O
transaction	O
.	O
</s>
<s>
In	O
1983	O
,	O
Andreas	O
Reuter	O
and	O
Theo	O
Härder	O
coined	O
the	O
acronym	O
ACID	O
,	O
building	O
on	O
earlier	O
work	O
by	O
Jim	O
Gray	O
who	O
named	O
atomicity	B-General_Concept
,	O
consistency	B-General_Concept
,	O
and	O
durability	B-General_Concept
,	O
but	O
not	O
isolation	B-General_Concept
,	O
when	O
characterizing	O
the	O
transaction	O
concept	O
.	O
</s>
<s>
According	O
to	O
Gray	O
and	O
Reuter	O
,	O
the	O
IBM	B-Application
Information	I-Application
Management	I-Application
System	I-Application
supported	O
ACID	B-Operating_System
transactions	I-Operating_System
as	O
early	O
as	O
1973	O
(	O
although	O
the	O
acronym	O
was	O
created	O
later	O
)	O
.	O
</s>
<s>
Transactions	B-General_Concept
are	O
often	O
composed	O
of	O
multiple	O
statements	B-Language
.	O
</s>
<s>
Atomicity	B-General_Concept
guarantees	O
that	O
each	O
transaction	O
is	O
treated	O
as	O
a	O
single	O
"	O
unit	O
"	O
,	O
which	O
either	O
succeeds	O
completely	O
or	O
fails	O
completely	O
:	O
if	O
any	O
of	O
the	O
statements	B-Language
constituting	O
a	O
transaction	O
fails	O
to	O
complete	O
,	O
the	O
entire	O
transaction	O
fails	O
and	O
the	O
database	O
is	O
left	O
unchanged	O
.	O
</s>
<s>
An	O
atomic	O
system	O
must	O
guarantee	O
atomicity	B-General_Concept
in	O
each	O
and	O
every	O
situation	O
,	O
including	O
power	O
failures	O
,	O
errors	O
,	O
and	O
crashes	B-General_Concept
.	O
</s>
<s>
A	O
guarantee	O
of	O
atomicity	B-General_Concept
prevents	O
updates	O
to	O
the	O
database	O
from	O
occurring	O
only	O
partially	O
,	O
which	O
can	O
cause	O
greater	O
problems	O
than	O
rejecting	O
the	O
whole	O
series	O
outright	O
.	O
</s>
<s>
Consistency	B-General_Concept
ensures	O
that	O
a	O
transaction	O
can	O
only	O
bring	O
the	O
database	O
from	O
one	O
consistent	B-General_Concept
state	I-General_Concept
to	O
another	O
,	O
preserving	O
database	O
invariants	B-Application
:	O
any	O
data	O
written	O
to	O
the	O
database	O
must	O
be	O
valid	O
according	O
to	O
all	O
defined	O
rules	O
,	O
including	O
constraints	O
,	O
cascades	O
,	O
triggers	B-Language
,	O
and	O
any	O
combination	O
thereof	O
.	O
</s>
<s>
Referential	B-General_Concept
integrity	I-General_Concept
guarantees	O
the	O
primary	B-Application
key	I-Application
–	O
foreign	B-Application
key	I-Application
relationship	O
.	O
</s>
<s>
Transactions	B-General_Concept
are	O
often	O
executed	O
concurrently	B-Architecture
(	O
e.g.	O
,	O
multiple	O
transactions	B-General_Concept
reading	O
and	O
writing	O
to	O
a	O
table	O
at	O
the	O
same	O
time	O
)	O
.	O
</s>
<s>
Isolation	B-General_Concept
ensures	O
that	O
concurrent	O
execution	O
of	O
transactions	B-General_Concept
leaves	O
the	O
database	O
in	O
the	O
same	O
state	O
that	O
would	O
have	O
been	O
obtained	O
if	O
the	O
transactions	B-General_Concept
were	O
executed	O
sequentially	O
.	O
</s>
<s>
Isolation	B-General_Concept
is	O
the	O
main	O
goal	O
of	O
concurrency	B-Operating_System
control	I-Operating_System
;	O
depending	O
on	O
the	O
isolation	B-General_Concept
level	I-General_Concept
used	O
,	O
the	O
effects	O
of	O
an	O
incomplete	O
transaction	O
might	O
not	O
be	O
visible	O
to	O
other	O
transactions	B-General_Concept
.	O
</s>
<s>
Durability	B-General_Concept
guarantees	O
that	O
once	O
a	O
transaction	O
has	O
been	O
committed	O
,	O
it	O
will	O
remain	O
committed	O
even	O
in	O
the	O
case	O
of	O
a	O
system	O
failure	O
(	O
e.g.	O
,	O
power	O
outage	O
or	O
crash	B-General_Concept
)	O
.	O
</s>
<s>
This	O
usually	O
means	O
that	O
completed	O
transactions	B-General_Concept
(	O
or	O
their	O
effects	O
)	O
are	O
recorded	O
in	O
non-volatile	B-General_Concept
memory	I-General_Concept
.	O
</s>
<s>
The	O
following	O
examples	O
further	O
illustrate	O
the	O
ACID	B-Operating_System
properties	I-Operating_System
.	O
</s>
<s>
The	O
following	O
SQL	B-Language
code	O
creates	O
a	O
table	O
as	O
described	O
above	O
:	O
</s>
<s>
Atomicity	B-General_Concept
is	O
the	O
guarantee	O
that	O
series	O
of	O
database	O
operations	O
in	O
an	O
atomic	B-General_Concept
transaction	I-General_Concept
will	O
either	O
all	O
occur	O
(	O
a	O
successful	O
operation	O
)	O
,	O
or	O
none	O
will	O
occur	O
(	O
an	O
unsuccessful	O
operation	O
)	O
.	O
</s>
<s>
A	O
guarantee	O
of	O
atomicity	B-General_Concept
prevents	O
updates	O
to	O
the	O
database	O
from	O
occurring	O
only	O
partially	O
,	O
which	O
can	O
cause	O
greater	O
problems	O
than	O
rejecting	O
the	O
whole	O
series	O
outright	O
.	O
</s>
<s>
In	O
other	O
words	O
,	O
atomicity	B-General_Concept
means	O
indivisibility	O
and	O
irreducibility	O
.	O
</s>
<s>
Alternatively	O
,	O
we	O
may	O
say	O
that	O
a	O
logical	O
transaction	O
may	O
be	O
composed	O
of	O
several	O
physical	O
transactions	B-General_Concept
.	O
</s>
<s>
Unless	O
and	O
until	O
all	O
component	O
physical	O
transactions	B-General_Concept
are	O
executed	O
,	O
the	O
logical	O
transaction	O
will	O
not	O
have	O
occurred	O
.	O
</s>
<s>
An	O
example	O
of	O
an	O
atomic	B-General_Concept
transaction	I-General_Concept
is	O
a	O
monetary	O
transfer	O
from	O
bank	O
account	O
A	O
to	O
account	O
B	O
.	O
</s>
<s>
Performing	O
these	O
operations	O
in	O
an	O
atomic	B-General_Concept
transaction	I-General_Concept
ensures	O
that	O
the	O
database	O
remains	O
in	O
a	O
consistent	B-General_Concept
state	I-General_Concept
,	O
that	O
is	O
,	O
money	O
is	O
neither	O
debited	O
nor	O
credited	O
if	O
either	O
of	O
those	O
two	O
operations	O
fails	O
.	O
</s>
<s>
Consistency	B-General_Concept
is	O
a	O
very	O
general	O
term	O
,	O
which	O
demands	O
that	O
the	O
data	O
must	O
meet	O
all	O
validation	O
rules	O
.	O
</s>
<s>
All	O
validation	O
rules	O
must	O
be	O
checked	O
to	O
ensure	O
consistency	B-General_Concept
.	O
</s>
<s>
Because	O
consistency	B-General_Concept
is	O
checked	O
after	O
each	O
transaction	O
,	O
it	O
is	O
known	O
that	O
before	O
the	O
transaction	O
begins	O
.	O
</s>
<s>
If	O
the	O
transaction	O
removes	O
10	O
from	O
successfully	O
,	O
atomicity	B-General_Concept
will	O
be	O
achieved	O
.	O
</s>
<s>
If	O
there	O
had	O
been	O
other	O
constraints	O
,	O
triggers	B-Language
,	O
or	O
cascades	O
,	O
every	O
single	O
change	O
operation	O
would	O
have	O
been	O
checked	O
in	O
the	O
same	O
way	O
as	O
above	O
before	O
the	O
transaction	O
was	O
committed	O
.	O
</s>
<s>
Another	O
example	O
would	O
be	O
integrity	O
constraints	O
,	O
which	O
would	O
not	O
allow	O
us	O
to	O
delete	O
a	O
row	O
in	O
one	O
table	O
whose	O
primary	B-Application
key	I-Application
is	O
referred	O
to	O
by	O
at	O
least	O
one	O
foreign	B-Application
key	I-Application
in	O
other	O
tables	O
.	O
</s>
<s>
To	O
demonstrate	O
isolation	B-General_Concept
,	O
we	O
assume	O
two	O
transactions	B-General_Concept
execute	O
at	O
the	O
same	O
time	O
,	O
each	O
attempting	O
to	O
modify	O
the	O
same	O
data	O
.	O
</s>
<s>
One	O
of	O
the	O
two	O
must	O
wait	O
until	O
the	O
other	O
completes	O
in	O
order	O
to	O
maintain	O
isolation	B-General_Concept
.	O
</s>
<s>
Consider	O
two	O
transactions	B-General_Concept
:	O
</s>
<s>
If	O
these	O
operations	O
are	O
performed	O
in	O
order	O
,	O
isolation	B-General_Concept
is	O
maintained	O
,	O
although	O
T2	O
must	O
wait	O
.	O
</s>
<s>
By	O
interleaving	O
the	O
transactions	B-General_Concept
,	O
the	O
actual	O
order	O
of	O
actions	O
might	O
be	O
:	O
</s>
<s>
This	O
is	O
known	O
as	O
a	O
write-write	B-General_Concept
conflict	I-General_Concept
,	O
because	O
two	O
transactions	B-General_Concept
attempted	O
to	O
write	O
to	O
the	O
same	O
data	O
field	O
.	O
</s>
<s>
However	O
,	O
the	O
changes	O
are	O
still	O
queued	O
in	O
the	O
disk	B-Device
buffer	I-Device
waiting	O
to	O
be	O
committed	O
to	O
disk	O
.	O
</s>
<s>
There	O
are	O
two	O
popular	O
families	O
of	O
techniques	O
:	O
write-ahead	B-Algorithm
logging	I-Algorithm
and	O
shadow	B-Application
paging	I-Application
.	O
</s>
<s>
In	O
both	O
cases	O
,	O
locks	O
must	O
be	O
acquired	O
on	O
all	O
information	O
to	O
be	O
updated	O
,	O
and	O
depending	O
on	O
the	O
level	O
of	O
isolation	B-General_Concept
,	O
possibly	O
on	O
all	O
data	O
that	O
may	O
be	O
read	O
as	O
well	O
.	O
</s>
<s>
In	O
write	B-Algorithm
ahead	I-Algorithm
logging	I-Algorithm
,	O
durability	B-General_Concept
is	O
guaranteed	O
by	O
copying	O
the	O
original	O
(	O
unchanged	O
)	O
data	O
to	O
a	O
log	O
before	O
changing	O
the	O
database	O
.	O
</s>
<s>
That	O
allows	O
the	O
database	O
to	O
return	O
to	O
a	O
consistent	B-General_Concept
state	I-General_Concept
in	O
the	O
event	O
of	O
a	O
crash	B-General_Concept
.	O
</s>
<s>
Many	O
databases	O
rely	O
upon	O
locking	B-Operating_System
to	O
provide	O
ACID	O
capabilities	O
.	O
</s>
<s>
Locking	B-Operating_System
means	O
that	O
the	O
transaction	O
marks	O
the	O
data	O
that	O
it	O
accesses	O
so	O
that	O
the	O
DBMS	O
knows	O
not	O
to	O
allow	O
other	O
transactions	B-General_Concept
to	O
modify	O
it	O
until	O
the	O
first	O
transaction	O
succeeds	O
or	O
fails	O
.	O
</s>
<s>
The	O
lock	B-Operating_System
must	O
always	O
be	O
acquired	O
before	O
processing	O
data	O
,	O
including	O
data	O
that	O
is	O
read	O
but	O
not	O
modified	O
.	O
</s>
<s>
Non-trivial	O
transactions	B-General_Concept
typically	O
require	O
a	O
large	O
number	O
of	O
locks	O
,	O
resulting	O
in	O
substantial	O
overhead	O
as	O
well	O
as	O
blocking	O
other	O
transactions	B-General_Concept
.	O
</s>
<s>
Two-phase	B-Operating_System
locking	I-Operating_System
is	O
often	O
applied	O
to	O
guarantee	O
full	O
isolation	B-General_Concept
.	O
</s>
<s>
An	O
alternative	O
to	O
locking	B-Operating_System
is	O
multiversion	B-Operating_System
concurrency	I-Operating_System
control	I-Operating_System
,	O
in	O
which	O
the	O
database	O
provides	O
each	O
reading	O
transaction	O
the	O
prior	O
,	O
unmodified	O
version	O
of	O
data	O
that	O
is	O
being	O
modified	O
by	O
another	O
active	O
transaction	O
.	O
</s>
<s>
This	O
allows	O
readers	O
to	O
operate	O
without	O
acquiring	O
locks	O
,	O
i.e.	O
,	O
writing	O
transactions	B-General_Concept
do	O
not	O
block	O
reading	O
transactions	B-General_Concept
,	O
and	O
readers	O
do	O
not	O
block	O
writers	O
.	O
</s>
<s>
One	O
implementation	O
,	O
namely	O
snapshot	B-Operating_System
isolation	I-Operating_System
,	O
relaxes	O
the	O
isolation	B-General_Concept
property	O
.	O
</s>
<s>
Guaranteeing	O
ACID	B-Operating_System
properties	I-Operating_System
in	O
a	O
distributed	B-General_Concept
transaction	I-General_Concept
across	O
a	O
distributed	B-Operating_System
database	I-Operating_System
,	O
where	O
no	O
single	O
node	O
is	O
responsible	O
for	O
all	O
data	O
affecting	O
a	O
transaction	O
,	O
presents	O
additional	O
complications	O
.	O
</s>
<s>
The	O
two-phase	B-General_Concept
commit	I-General_Concept
protocol	I-General_Concept
(	O
not	O
to	O
be	O
confused	O
with	O
two-phase	B-Operating_System
locking	I-Operating_System
)	O
provides	O
atomicity	B-General_Concept
for	O
distributed	B-General_Concept
transactions	I-General_Concept
to	O
ensure	O
that	O
each	O
participant	O
in	O
the	O
transaction	O
agrees	O
on	O
whether	O
the	O
transaction	O
should	O
be	O
committed	O
or	O
not	O
.	O
</s>
