| |
| |
Foreword | |
| |
| |
Preface | |
| |
| |
About the Authors | |
| |
| |
Introduction | |
| |
| |
Are You a Mere Mortal? | |
| |
| |
About This Book | |
| |
| |
What This Book Is Not | |
| |
| |
How to Use This Book | |
| |
| |
Reading the Diagrams Used in This Book | |
| |
| |
Sample Databases Used in This Book | |
| |
| |
"Follow the Yellow Brick Road" | |
| |
| |
| |
Relational Databases and SQL | |
| |
| |
| |
What Is Relational? | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
Types of Databases | |
| |
| |
A Brief History of the Relational Model | |
| |
| |
Anatomy of a Relational Database | |
| |
| |
What's in It for You? | |
| |
| |
Where Do You Go from Here? | |
| |
| |
Summary | |
| |
| |
| |
Ensuring Your Database Structure Is Sound | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
Why Is This Chapter Here? | |
| |
| |
Why Worry about Sound Structures? | |
| |
| |
Fine-Tuning Fields | |
| |
| |
Fine-Tuning Tables | |
| |
| |
Establishing Solid Relationships | |
| |
| |
Is That All? | |
| |
| |
Summary | |
| |
| |
| |
A Concise History of SQL | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
The Origins of SQL | |
| |
| |
Early Vendor Implementations | |
| |
| |
". . . And Then There Was a Standard" | |
| |
| |
Evolution of the ANSI/ISO Standard | |
| |
| |
Commercial Implementations | |
| |
| |
What the Future Holds | |
| |
| |
Why Should You Learn SQL? | |
| |
| |
Summary | |
| |
| |
| |
SQL Basics | |
| |
| |
| |
Creating a Simple Query | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
Introducing SELECT | |
| |
| |
The SELECT Statement | |
| |
| |
A Quick Aside: Data versus Information | |
| |
| |
Translating Your Request into SQL | |
| |
| |
Eliminating Duplicate Rows | |
| |
| |
Sorting Information | |
| |
| |
Saving Your Work | |
| |
| |
Sample Statements | |
| |
| |
Summary | |
| |
| |
Problems for You to Solve | |
| |
| |
| |
Getting More Than Simple Columns | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
What Is an Expression? | |
| |
| |
What Type of Data Are You Trying to Express? | |
| |
| |
Changing Data Types: The CAST Function | |
| |
| |
Specifying Explicit Values | |
| |
| |
Types of Expressions | |
| |
| |
Using Expressions in a SELECT Clause | |
| |
| |
That "Nothing" Value: Null | |
| |
| |
Sample Statements | |
| |
| |
Summary | |
| |
| |
Problems for You to Solve | |
| |
| |
| |
Filtering Your Data | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
Refining What You See Using WHERE | |
| |
| |
Defining Search Conditions | |
| |
| |
Using Multiple Conditions | |
| |
| |
Nulls Revisited: A Cautionary Note | |
| |
| |
Expressing Conditions in Different Ways | |
| |
| |
Sample Statements | |
| |
| |
Summary | |
| |
| |
Problems for You to Solve | |
| |
| |
| |
Working with Multiple Tables | |
| |
| |
| |
Thinking in Sets | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
What Is a Set, Anyway? | |
| |
| |
Operations on Sets | |
| |
| |
Intersection | |
| |
| |
Difference | |
| |
| |
Union | |
| |
| |
SQL Set Operations | |
| |
| |
Summary | |
| |
| |
| |
Inner Joins | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
What Is a JOIN? | |
| |
| |
The Inner Join | |
| |
| |
Uses for Inner Joins | |
| |
| |
Sample Statements | |
| |
| |
Summary | |
| |
| |
Problems for You to Solve | |
| |
| |
| |
Outer Joins | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
What Is an Outer Join? | |
| |
| |
The Left/Right Outer Join | |
| |
| |
The Full Outer Join | |
| |
| |
Uses for Outer Joins | |
| |
| |
Sample Statements | |
| |
| |
Summary | |
| |
| |
Problems for You to Solve | |
| |
| |
| |
Unions | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
What Is a Union? | |
| |
| |
Writing Requests with Union | |
| |
| |
Uses for Union | |
| |
| |
Sample Statements | |
| |
| |
Summary | |
| |
| |
Problems for You to Solve | |
| |
| |
| |
Subqueries | |
| |
| |
Topics Covered in This Chapter | |
| |
| |
What Is a Subquery? | |
| |
| |
Subqueries as Column Expressions | |
| |
| |
Subqueries as Filters | |
| |
| |
Uses for Subqueries | |
| |
| |
Sample Statements 394 Summary | |
| |
| |
Problems for You to Solve | |
| |
| |
| |
Summarizing and Grouping Data | |
| |
| |
| |
Simple Totals | |
| |
| |
Topics Cover | |