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

Division
Finally, let’s look at division. Division is an operation that extracts the rows whose column values match those in the second table, but only returns columns that don’t exist in the second table. Let’s look at an example.
Sales Table |
export Destination Table |
Export dest. code |
Export dest. name |
Date |
|
|
|
12 |
The Kingdom of Minanmi |
3/5 |
|
|
|
12 |
The Kingdom of Minanmi |
3/10 |
|
|
|
23 |
Alpha Empire |
3/5 |
25 |
The Kingdom of Ritol |
3/21 |
|
|
|
30 |
The Kingdom of Sazanna |
3/25 |
|
|
|
Export dest. code |
Export dest. name |
|
|
12 |
The Kingdom of Minanmi |
|
|
23 |
Alpha Empire |
|
|
Dividing the Sales Table by the Export Destination Table results in the following table. This allows you to find the dates when fruit was exported to both the Alpha Empire and the Kingdom of Minanmi.
Date
3/5
Questions
Now, let’s answer some questions to see how well you understand relational databases. The answers are on page 48.
Q1
What do you call the key referring to a column in a different table in a relational database?
Q2
The following table displays information about books. Which item can you use as a primary key? The ISBN is the International Standard Book Number, a unique identifying number given to every published book. Some books may have the same title.
ISBN |
Book name |
Author name |
Publication date |
Price |
|
|
|
|
|
What Is a Relational Database? 45

Q3
What do you call the operation used here to extract data?
Export dest. code |
Export dest. name |
|
|
12 |
The Kingdom of Minanmi |
|
|
23 |
Alpha Empire |
25 |
The Kingdom of Ritol |
|
|
30 |
The Kingdom of Sazanna |
|
|
Q4 |
|
Export dest. code |
Export dest. name |
|
|
25 |
The Kingdom of Ritol |
|
|
What do you call the operation used here to extract data?
Export dest. code |
Export dest. name |
|
|
12 |
The Kingdom of Minanmi |
|
|
23 |
Alpha Empire |
|
|
25 |
The Kingdom of Ritol |
30 |
The Kingdom of Sazanna |
|
|
Export dest. code |
Export dest. name |
|
|
15 |
The Kingdom of Paronu |
|
|
22 |
The Kingdom of Tokanta |
|
|
31 |
The Kingdom of Taharu |
33 |
The Kingdom of Mariyon |
|
|
Export dest. code |
Export dest. name |
|
|
12 |
The Kingdom of Minanmi |
|
|
15 |
The Kingdom of Paronu |
|
|
22 |
The Kingdom of Tokanta |
23 |
Alpha Empire |
|
|
25 |
The Kingdom of Ritol |
|
|
30 |
The Kingdom of Sazanna |
|
|
31 |
The Kingdom of Taharu |
33 |
The Kingdom of Mariyon |
|
|
46 Chapter 2

Q5
What do you call the operation used here to extract data?
Export dest. code |
Export dest. name |
|
|
12 |
The Kingdom of Minanmi |
23 |
Alpha Empire |
|
|
25 |
The Kingdom of Ritol |
|
|
30 |
The Kingdom of Sazanna |
|
|
Export dest. code |
Date |
|
|
12 |
3/1 |
23 |
3/1 |
|
|
12 |
3/3 |
|
|
30 |
3/5 |
|
|
12 |
3/6 |
25 |
3/10 |
|
|
Export dest. code |
Date |
Export dest. name |
|
|
|
12 |
3/1 |
The Kingdom of Minanmi |
|
|
|
23 |
3/1 |
Alpha Empire |
|
|
|
12 |
3/3 |
The Kingdom of Minanmi |
30 |
3/5 |
The Kingdom of Sazanna |
|
|
|
12 |
3/6 |
The Kingdom of Minanmi |
|
|
|
25 |
3/10 |
The Kingdom of Ritol |
The Relational Database Prevails!
In a relational database, you can use eight different operations to extract data. The extracted results are tabulated. If you combine the operations explained in this section, you can extract data for any purpose. For example, you can use the name and price of a product to create gross sales aggregate data for it. Relational databases are popular because they’re easy to understand and provide flexible data processing.
What Is a Relational Database? 47

Summary
•One row of data is called a record, and each column is called a field.
•A column that can be used to identify data is called a primary key.
•In a relational database, you can process data using the concept of a table.
•In a relational database, you can process data based on mathematical operations.
Answers
Q1 Foreign key
Q2 ISBN
Q3 Selection
Q4 Union
Q5 Join
48 Chapter 2

3
Let’s Design a Database!