
- •Contents
- •Preface
- •Why Do We Need Databases?
- •What’s Up in the Kingdom?
- •A Database—That’s Our Solution!
- •Summary
- •Database Terms
- •Relational Databases
- •Types of Data Models
- •Data Extraction Operations
- •Questions
- •The Relational Database Prevails!
- •Summary
- •Answers
- •The E-R Model
- •Normalizing a Table
- •What Is the E-R Model?
- •How to Analyze the E-R Model
- •Normalizing a Table
- •Steps for Designing a Database
- •Answers
- •Using SQL
- •Searching for Data Using a SELECT Statement
- •Using Aggregate Functions
- •Joining Tables
- •Creating a Table
- •SQL Overview
- •Searching for Data Using a SELECT Statement
- •Creating Conditions
- •Aggregate Functions
- •Searching for Data
- •Joining Tables
- •Creating a Table
- •Summary
- •Answers
- •What Is a Transaction?
- •What Is a Lock?
- •Database Security
- •Speeding Things Up with Indexing
- •Disaster Recovery
- •Properties of Transactions
- •When Disaster Strikes
- •Indexes
- •Optimizing a Query
- •Summary
- •Answers
- •Databases in Use
- •Databases and the Web
- •Distributed Databases
- •Stored Procedures and Triggers
- •Databases on the Web
- •What Is a Distributed Database?
- •Partitioning Data
- •Preventing Inconsistencies with a Two-Phase Commit
- •Database Replication
- •Further Application of Databases
- •Summary
- •Answers
- •Closing Remarks
- •References
- •Index
- •About the Author
- •Updates
- •More Manga Guides

What Is a Transaction?
Click, click, click...
Beep
Beep
Click,
click,
clack, click...
Click, clack,
click...
You see, this one and this one are new orders.
Yes, sir. I'll add |
|
Argh, show up |
|
them to the |
|
||
We’re finally |
normally, will |
||
database right |
|||
learning to use a |
you? |
||
away. |
|||
database, aren't we? |
Tico! |
||
|
|||
|
|
Sorry |
|
|
|
'bout that. |
Geez!!
Gee!
*
*Hop!
126 Chapter 5

Actually, |
|
For example, I wonder |
|
I should |
|
||
but we still |
why a database can still |
||
thank you… |
|||
have so much |
operate when so many |
||
|
|||
|
to learn. |
users are accessing it at |
|
|
|
the same time. |
|
For that matter, |
|
|
|
the issue of |
|
|
|
security also |
|
|
|
concerns me a |
|
|
|
bit. |
|
|
|
|
Well, |
|
|
|
To better |
|
Apparently, you have |
|
understand |
|
some worries about |
|
the issues, |
|
|
|
|
|
your database. |
|
|
Ahem! |
|
|
|
|
|
|
I have done |
|
|
|
a little |
|
|
Sort of. |
research. |
Oh, yeah? |
|
|
||
|
|
|
|
The title of my |
|
|
|
presentation is: |
|
|
|
How can a database |
|
Flash! |
|
|
|
|
|
let a large number |
|
|
I have even |
of users access it |
|
|
|
simultaneously? |
|
|
prepared |
|
|
|
illustrations |
|
|
|
to help your |
|
|
|
understanding! |
|
|
|
Gee, |
|
|
that's great. |
|
|
|
|
Database |
Oh! |
|
|
Theater |
I love a good show!

Now let me begin. |
One day, Andy |
|
|
and Becky |
Database |
|
accessed the |
|
Clap, |
database at the |
|
same time. |
|
|
clap, |
|
|
|
|
|
clap |
|
|
Whoopee!
From this database, Andy read the Product Table, namely apples.
He then added 10 to the inventory by writing a database operation.
30 apples
I see 30
now.
Uh-huh.
I'll add 10.
I'll have 40, then.
Meanwhile, Becky also read the number of apples, 30, and added 10 herself.
But after that operation, the database shows the current number of apples as 40.
30 |
Just |
|
tryin’ to |
||
apples |
help! |
|
I see |
|
|
30 |
|
|
now. |
Is that |
|
|
right? |
|
I'll add 10. |
I'll add 10. |
|
|
I'll |
|
|
have |
|
I'll have |
40, |
|
then. |
||
40, then. |
||
|
||
40 |
|
|
apples |
|
128 Chapter 5

Shouldn't it |
That's |
So where have |
|
right. |
the 10 apples |
||
be 50 now? |
|||
|
gone? |
||
|
|
||
Andy has |
|
Think |
|
added 10. |
|
||
|
hard! |
||
Becky has |
|
|
|
added 10. |
|
|
|
|
|
Let me see... |
Eaten up. |
No way! They |
|
weren’t there to |
||
By Cain! |
||
begin with! |
||
|
Me?!
j'accuse!
In order to allow |
|
So the question is, how |
Andy and Becky to |
|
does a database control |
use the database at |
|
user operations? |
the same time, |
|
|
there must be a |
He's |
I'll explain that now! |
In fact, in this |
|
add 10. |
sequence, Becky can’t |
Database |
|
perform any database |
So 10 apples |
|
operation while Andy’s |
||
would never |
||
working. |
||
disappear. |
||
|
||
mechanism to prevent |
groovy! |
|
|
||
inconsistencies and |
|
|
duplications such as |
|
|
this. |
Indeed. |
|
|
Cain's terrific today.

First of all, a database is designed to process data operations in a
lump.
Hm-hm
A unit of data operations is called a transaction.
Transaction?
In this example, a read operation, an add operation, and a write operation are processed as a single transaction.
Transaction
Read |
Read |
data. |
data. |
add 10. |
add 10. |
Write |
Write |
the |
the |
result. |
result. |
Transaction
So, Andy's |
And Becky's |
operations form |
operations form |
one transaction, |
another. |
130 Chapter 5