
- •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

In addition, since the database will hold a large amount of data, you must be able to perform searches at high speeds. The new system must have the power to handle that.
Let’s start studying databases together with Princess Ruruna and Cain to learn how to solve these problems. Onward to Chapter 2!
Summary
•File-based management can create conflicting data and data duplication.
•A database allows you to share data easily and prevents conflicting and duplicated data.
Using Software to Manage Databases
The database we are going to study is managed by software called a database management system (DBMS). A DBMS has many useful functions—it allows you to do things like input data into a database, prevent conflicting data, and retrieve a large
amount of data at high speed. Thanks to our DBMS, the database can be used by many people simultaneously. In addition, a DBMS can protect the security of the database— for example, it allows the database to operate properly even if a failure occurs. In addition, the DBMS provides an easy-to-use interface between the database and its users. We’ll study databases and the functions of a DBMS in the next chapter.
What Is a Database? 21


2
What Is a Relational Database?

Database Terms
Take these flowers...
Ruruna, my darling.
floomp
...
Oh,
What's
wrong?
beautiful Princess.
Both my father and mother are away from the castle, so I'm very busy!
I thought you'd be lonely. That's why I am here.
No, Cain is here with me.
Hmm
Cain?
awkward Fidget
You can't |
Prince |
|
mean your |
||
Raminess! |
||
aide is more |
||
|
||
dependable |
|
|
than a prince! |
|
RaaaMiiiNeeesss!!
Bang!!
Bang!!
Eek!
Ha ha ha!

Trapped!
You promised to go out on a date with me today.
Gee, Who is she?
... |
Drag, |
Drag |
|
||
|
|
... |
|
Princess |
|
|
Ruruna, |
|
What |
I'll be |
|
about my |
back... |
|
flowers? |
|
|
No…uhm… |
This is |
well... |
for you. |
Phew!
He is so annoying.
Plop!
But Raminess is |
Don't I |
|
the prince of |
||
know it... |
||
the neighboring |
||
|
||
country. |
|
|
You shouldn't |
|
|
treat him so |
|
|
lightly. |
Good morning! |
|
|

AAAH!!
Gee! How long
have you been
there? Since you opened the
book a little while ago.
Hello!
Let's start to design a database.
It's not a good |
|
|
morning at all. |
You surprise |
|
You are so carefree. |
||
me every |
||
|
||
|
time. |
But that's okay. Anyway, Raminess left.
Squeeze
squeeze
Wait a minute.
You can't design a |
A good |
|
database without |
||
foundation |
||
any knowledge. |
||
is important. |
Yeah...
Let's do
Awww... our best.
First of all, let's learn database terms.
Stay here.
Hop!
!!!
Diving
into...
26 Chapter 2

|
What did |
N...No, |
|
What? |
nothing... |
|
|
you say? |
|
||
|
Wriggle wriggle |
She went into |
And |
|
the laptop..! |
pulled |
|
|
|
||
|
|
|
some |
|
|
|
thing |
|
|
|
out... |
zzz
zzz
This is one of the files you are using.
Uh-huh.
code Product
Unit
Product
name
Melon
Strawberry
Apple
Lemon
Chestnut
Persimmon
Remarks
seeds with
0G
200G
160G
A piece of data in |
|
the file is called a |
|
record. |
Field |
|
|
R |
|
e |
|
c |
|
o |
|
r |
|
d |
|
and each item in the record is called a field.
One product is one record, right?
Uh-huh.
then the Product Code, Product Name, Unit Price, and
Remarks are fields, correct?
What Is a Relational Database? 27

Each record contains fields of the same type.
Record
I see.
For example,
Product Code is a three-digit value...
Product code Product name |
Unit price |
Remarks |
Melon |
800G |
With seeds |
Strawberry |
150G |
|
Apple |
120G |
|
Lemon |
200G |
Sour |
|
||
Chestnut |
100G |
With bur |
Persimmon |
160G |
|
Peach |
130G |
|
Kiwi |
200G |
valuable |
Field
and Product Name |
Product |
Then, next, let's think |
|
Code |
|||
|
|
||
is ten characters |
|
about the Product |
|
|
Code in a little more |
||
or less. |
|
||
|
detail. |
||
|
|
Product
code
Product name m e l o n
s t r a a p p l
l e m o n
c h e s t n u t p e r s i m mo n
Here!
Hmmm...
Record...
Field...
mutter...
mutter...
Cain?
28 Chapter 2

No two product codes are the same.
That makes sense.
I understand.
But in the case of Unit Price...
Oh, I found the same number.
And there are no duplicated records. So, if you know the product code is 101,
you can identify it
as Melon.
Yes.
Unit Price?
What will happen?
You will not know whether it indicates Lemon or Kiwi.
Even if you know a fruit's price is 200G...
What Is a Relational Database? 29

So we can identify data with its Product Code, but not with its Unit Price.
Exactly.
In the database world, such a field...
is called unique.
|
Product |
code |
|
||
|
|
|
|
is |
|
|
|
|
|
|
|
Unique? |
|
|
|
unique |
|
|
|
|
|
||
Other people |
|
Ummmm... |
|||
often say that |
|
||||
about my father... |
|
|
|||
|
|
ha, |
King |
Kod |
|
Ha, ha, |
|
|
|||
|
|
|
|||
. Mwahaha |
|
||||
is |
unique |
|
|
|
It means the one and only.
Only!
One!
It has a specific meaning, you know.
Then, next, let's think about
Remarks.
Remarks?
Remarks are remarks, aren't they?
Person Remarks
Blonde
Ruruna Active
Cain
Brunet
Relaxed
- Characterlike istics ... this
Take a look from |
Some values under |
the point of view |
Remarks have no |
of a database. |
entries, right? |
Remarks |
I see your |
|
eeds |
||
point... |
||
S |
||
With |
|
Relaxed?
Sour
ur B With

|
This does not |
|
mean that a space |
Remarks |
is entered… |
|
|
With seeds |
|
|
It is truly empty. |
Sour |
|
With bur |
|
valuable
Cannot be null.
Product |
Product |
Unit price |
Remarks |
|
code |
name |
|||
|
|
|||
|
Melon |
800G |
With seeds |
|
|
Strawberry |
150G |
|
|
|
Apple |
120G |
|
|
|
Lemon |
200G |
Sour |
If that's so, you can't identify the product even if you look at the remarks.
Nope.
The absence of a value is called a null in the database world.
nullA
Chestnut |
100G |
With bur |
A null is acceptable for |
|
Remarks, but not for |
||||
Persimmon |
160G |
|
||
|
Product Code, which |
|||
|
|
|
||
Peach |
130G |
|
identifies data. |
|
Kiwi |
200G |
|
|
That's all for |
Yeah.... |
Null? |
Empty? |
|
Unique? |
||||
database terms. |
|
|||
|
|
|
||
Do you |
|
mutter... |
|
|
understand? |
Well, |
mutter... |
|
|
|
|
|
vaguely...
What Is a Relational Database? 31

But, if you continue using the current independent files,
there are all kinds of problems you can't solve.
So, tell me, tell |
|
me now. |
Hold on! |
|
When you say database, you must understand that there are many kinds of databases.
Just like fruit.
Is that so?
That's right.
That's why I want to create a database.
Boink! |
Data |
Boink! |
|
||
|
|
|
For example, |
|
|
Data |
|
Data |
Data Data |
Data Data |
|
Shazam! |
|
this is a hierarchical data model, in which
there is a tree-like relationship between data.
Ack, something appeared.
32 Chapter 2

Next is the network data model, in which pieces of data have overlapping relationships with each other.
B...B...
Boink! Data
Data Data Data
Data Data |
Data |
Data |
|
||
|
|
Are you not |
|
B |
|
|
I'm ready for |
... |
B |
|
|
|
... |
astonished at |
anything! |
|
Boink! |
|
|
||
all, Cain? |
|
|
|
|
|
|
Shazam!
Then, are we going to use one of them?
Humph!
Data
|
Data |
|
Data |
Data |
|
|
||
Data |
Data |
Data |
|
||
|
|
|
Hierarchical |
||
Data |
model |
|
|
|
Nope!
ZZZT!
Bang
Bang!
Tensed up
ZZZT! |
As a matter of |
||
fact, another kind |
|||
|
|||
|
is much easier to |
||
|
use than these |
||
Bang! |
|
two. |
|
|
|
||
|
You were |
|
|
|
scared, |
|
|
|
weren't |
No, not |
|
|
you? |
at all. |
giggle
It is called…
A relational data model.
Relational?
What Is a Relational Database? 33