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

Using SQL
Walking through town makes me remember my childhood.
Ha, ha, ha!
You often skipped class and snuck out of the castle.
man y y e a r
s ag
o . . .
Princess!!
Princess
Ruruna!!
Clatter
Did I? |
You can’t just |
|
leave the castle |
|
whenever you want! |
Huff
Huff
Huff
Pant
Pant
Pant

You know what, Cain? |
It is the |
You follow me |
|
because it's your |
|
||
attendant’s job |
|
||
You should just stay |
duty? |
|
|
to follow the |
|
||
in the castle if all |
|
|
|
Princess! |
|
|
|
you’re going to do |
I thought you |
|
|
|
|
||
is yell at me! |
|
Well… |
|
|
followed me |
|
because you |
|
are my friend. |
Wheeze |
Huff! |
|
Pant
B...but...
Sense of responsibility!
You jerk!
Oh, no, I didn’t mean that...!
Swish!
Princess.... |
Ouch! |
I found you, |
|
|
|
|
Princess Ruruna!! |
|
|
|
! |
|
|
|
|
|
|
|
|
O |
M |
|
B |
O |
|
|
Guard Captain |
|
|
||
I…Igor...! |
|
|
|
|
Let me see…
Let's Learn About SQL! 87

Ruruna, you |
No, you don’t |
|
understand...!! |
||
have gone |
||
|
||
too far. |
|
|
|
Thwock |
It’s my fault...
I convinced Cain...
Princess Ruruna to leave the castle…!!
Ack!
Oh, really?
...
Cain has taken
care of me...
Let’s go |
|
home, |
since I was |
Princess. |
a child. |
88 Chapter 4

What’s the |
|
What’s the |
|
|
matter with |
||
matter with |
Oh, no, no... |
||
me... |
|||
you? |
|||
|
|||
|
|
What?
!!
Nothing!!
Ha, ha, ha
Prince
Raminess...
Zowie!!
Neigh,
neigh
How are |
Oh no, he is |
|
coming this |
||
you lovely |
||
way. |
||
ladies? |
||
|
Ha, ha, ha
What a
Dreamboat!!
RaMiNess!!
Cain!! Let's go in
this café.
Let’s study databases here for a while.
twinkle
What?
Squeal!E |
||
Ha, |
ek! |
|
ha, |
||
|
||
|
ha |

Here I am!
Oh, a new place to study!
There you are!!
Flap
It’s refreshing outside.
flit
Flap
So, we’ve gotten |
The next thing to |
|
to the point where |
||
do is to study how |
||
we can design a |
||
to use the database |
||
database. |
||
we created. |
||
|
||
You could |
|
|
say that. |
|
Finally...
Hip, hip, hurray!
When you use the |
|
|
database, you have |
To do that, |
Squeal?? |
to input data or |
retrieve data, as |
we’ll use SQL. |
|
|
|
|
you already know. |
|
|
|
|
It sounds |
|
Hee |
difficult... |
|
|
|
|
hee! |
|
90 Chapter 4

For example, when you have a conversation in the Swimmy region across the sea,
Swimmy
Region
Oh, you speak Swimmy language.
|
Splish, |
you need to |
splash.... |
speak Swimmy |
|
language. |
|
In the same manner, you use a language called
Structured Query Language (SQL)
to have a
conversation Really? with a
database.
That’s great!!
Wait,
what?
Sales Table
|
|
|
|
Export |
Report code |
Date |
|
|
|
|
destination code |
|||
|
|
|
||
1101 |
3/5 |
|
|
12 |
1102 |
3/7 |
|
|
23 |
1103 |
3/8 |
|
|
25 |
1104 |
3/10 |
|
|
12 |
1105 |
3/12 |
|
|
25 |
Sales Statement |
|
|
||
Table |
|
|
|
|
Report code |
Product |
Quantity |
||
code |
|
|||
|
|
|
||
1101 |
101 |
|
1,100 |
|
1101 |
102 |
|
300 |
|
1102 |
103 |
|
1,700 |
|
1103 |
104 |
|
500 |
|
1104 |
101 |
|
2,500 |
|
1105 |
103 |
|
2,000 |
|
1105 |
104 |
|
700 |
The database does not really speak, you understand?
Of course, I know that!
Export Destination
Table
Export |
Export destination name |
||
destination code |
|||
|
|
||
12 |
The Kingdom of Minanmi |
||
23 |
Alpha Empire |
||
25 |
The Kingdom of Ritol |
||
Product Table |
|
||
Product |
Product |
Unit price |
|
code |
name |
||
|
|||
101 |
Melon |
800G |
|
102 |
Strawberry |
150G |
|
103 |
Apple |
120G |
|
104 |
Lemon |
200G |
You designed these kinds of tables the other day. Remember?
Let's Learn About SQL! 91

But now, you need to use SQL to put these tables and data into the database.
By using SQL, you can have a conversation with the database to do tasks like these…
S
It sounds like we can do all sorts of things!!
|
|
Features |
|
||
|
|
• |
|
|
|
|
• |
Creation |
|
|
|
• |
|
Input |
and |
of |
QL |
|
|
|
|
tables |
|
|
Management |
||||
|
|
||||
|
|
|
|
retrieval |
|
|
|
|
|
of |
users |
|
|
|
|
|
Features of SQL
Creation of tables
Input and retrieval of data
Management of users
But...it seems like it would be a lot of work.
No problem.
We have learned |
Well…that’s true... |
I have input the tables |
And I want to use a |
and data we designed |
|
so much |
database as soon |
earlier. |
already! |
as possible. |
|
|
|
Beep |
That’s the spirit!
Let’s retrieve some
data.
Exactly.
92 Chapter 4