About the Author |
|
xv | |
About the Technical Reviewer |
|
xvii | |
Acknowledgments |
|
xix | |
Introduction |
|
xxi | |
|
Chapter 1 Relational Database Overview |
|
|
1 | (14) |
|
Introducing Database Tables |
|
|
1 | (5) |
|
|
2 | (1) |
|
|
3 | (1) |
|
Inserting and Updating Rows in a Table |
|
|
3 | (2) |
|
Designing Appropriate Tables |
|
|
5 | (1) |
|
|
6 | (3) |
|
Retrieving Information from a Database |
|
|
9 | (4) |
|
|
10 | (1) |
|
|
11 | (1) |
|
Why We Consider Two Approaches |
|
|
12 | (1) |
|
|
13 | (2) |
|
Chapter 2 Simple Queries on One Table |
|
|
15 | (18) |
|
Subsets of Rows and Columns |
|
|
15 | (3) |
|
|
18 | (1) |
|
|
19 | (1) |
|
Specifying Conditions for Selecting Rows |
|
|
19 | (4) |
|
|
19 | (2) |
|
|
21 | (2) |
|
|
23 | (2) |
|
|
24 | (1) |
|
Comparisons Involving Null Values |
|
|
24 | (1) |
|
|
25 | (3) |
|
|
28 | (1) |
|
|
29 | (1) |
|
|
29 | (3) |
|
Incorrectly Using a WHERE Clause to Answer Questions with the Word "both" |
|
|
30 | (2) |
|
Incorrectly Using a WHERE Clause to Answer Questions with the Word "not" |
|
|
32 | (1) |
|
|
32 | (1) |
|
Chapter 3 A First Look at Joins |
|
|
33 | (18) |
|
The Process Approach to Joins |
|
|
33 | (3) |
|
|
33 | (2) |
|
|
35 | (1) |
|
Outcome Approach to Joins |
|
|
36 | (2) |
|
|
38 | (6) |
|
|
39 | (2) |
|
|
41 | (1) |
|
|
42 | (1) |
|
Expressing Joins Through Diagrammatic Interfaces |
|
|
43 | (1) |
|
|
44 | (4) |
|
|
45 | (3) |
|
|
48 | (3) |
|
|
51 | (16) |
|
|
51 | (1) |
|
|
52 | (2) |
|
Being Careful with NOT and <> |
|
|
54 | (3) |
|
|
57 | (3) |
|
Different Types of Subqueries |
|
|
60 | (3) |
|
Inner Queries Returning a Single Value |
|
|
60 | (2) |
|
Inner Queries Returning a Set of Values |
|
|
62 | (1) |
|
Inner Queries Checking for Existence |
|
|
62 | (1) |
|
Using Subqueries for Updating |
|
|
63 | (1) |
|
|
64 | (3) |
|
Examples of Different Types of Subqueries |
|
|
65 | (1) |
|
Examples of Different Uses for Subqueries |
|
|
66 | (1) |
|
|
67 | (18) |
|
|
67 | (12) |
|
|
70 | (1) |
|
Queries Involving a Self Join |
|
|
71 | (5) |
|
An Outcome Approach to Self Joins |
|
|
76 | (3) |
|
Questions Involving "Both" |
|
|
79 | (3) |
|
An Outcome Approach to Questions Involving "Both" |
|
|
80 | (1) |
|
A Process Approach to Questions Involving "Both" |
|
|
81 | (1) |
|
|
82 | (3) |
|
|
82 | (1) |
|
Questions Involving the Word "Both" |
|
|
82 | (3) |
|
Chapter 6 Multiple Relationships Between Tables |
|
|
85 | (14) |
|
Two Relationships Between the Same Tables |
|
|
85 | (4) |
|
Extracting Information from Multiple Relationships |
|
|
89 | (5) |
|
|
90 | (3) |
|
|
93 | (1) |
|
|
94 | (3) |
|
|
97 | (2) |
|
|
99 | (30) |
|
Overview of Basic Set Operations |
|
|
99 | (2) |
|
|
101 | (4) |
|
Ensuring Union Compatibility |
|
|
104 | (1) |
|
|
105 | (6) |
|
Selecting the Appropriate Columns |
|
|
106 | (2) |
|
|
108 | (1) |
|
Union and Full Outer Joins |
|
|
109 | (2) |
|
|
111 | (7) |
|
|
112 | (3) |
|
The Importance of Projecting Appropriate Columns |
|
|
115 | (1) |
|
Managing Without the INTERSECT Keyword |
|
|
116 | (2) |
|
|
118 | (4) |
|
|
118 | (3) |
|
Managing Without the EXCEPT Keyword |
|
|
121 | (1) |
|
|
122 | (4) |
|
Projecting Appropriate Columns |
|
|
124 | (1) |
|
|
125 | (1) |
|
|
126 | (3) |
|
|
127 | (1) |
|
|
127 | (1) |
|
|
127 | (1) |
|
|
128 | (1) |
|
Chapter 8 Aggregate Operations |
|
|
129 | (18) |
|
Simple Aggregate Functions |
|
|
129 | (6) |
|
|
129 | (3) |
|
|
132 | (2) |
|
|
134 | (1) |
|
Other Aggregate Functions |
|
|
135 | (1) |
|
|
135 | (9) |
|
Filtering the Result of an Aggregate Query |
|
|
140 | (2) |
|
Using Aggregates to Perform Division Operations |
|
|
142 | (2) |
|
Nested Queries and Aggregates |
|
|
144 | (2) |
|
|
146 | (1) |
|
Chapter 9 Window Functions |
|
|
147 | (14) |
|
|
147 | (2) |
|
|
149 | (1) |
|
|
150 | (6) |
|
|
150 | (2) |
|
|
152 | (1) |
|
Combining Ordering with Partitions |
|
|
153 | (3) |
|
|
156 | (3) |
|
|
159 | (2) |
|
|
159 | (1) |
|
|
159 | (1) |
|
|
159 | (1) |
|
OVER(PARTITION BY <...> ORDER BY <...>) |
|
|
159 | (1) |
|
OVERSOWS BETWEEN <...> AND <...>) |
|
|
159 | (2) |
|
Chapter 10 Efficiency Considerations |
|
|
161 | (14) |
|
|
161 | (2) |
|
|
163 | (5) |
|
|
163 | (1) |
|
|
164 | (1) |
|
|
165 | (1) |
|
Clustered Index on a Compound Key |
|
|
166 | (1) |
|
|
167 | (1) |
|
|
168 | (1) |
|
|
168 | (1) |
|
|
168 | (5) |
|
|
169 | (1) |
|
|
170 | (1) |
|
Different SQL Expressions for Joins |
|
|
171 | (2) |
|
|
173 | (2) |
|
|
173 | (1) |
|
|
173 | (1) |
|
|
173 | (1) |
|
Order By, Group By, And Distinct |
|
|
173 | (1) |
|
|
173 | (2) |
|
Chapter 11 How to Tackle a Query |
|
|
175 | (20) |
|
|
175 | (6) |
|
Determine the Relationships Between Tables |
|
|
175 | (3) |
|
Real World Versus Implementation |
|
|
178 | (2) |
|
What Tables Are Involved? |
|
|
180 | (1) |
|
|
180 | (1) |
|
|
181 | (3) |
|
|
181 | (2) |
|
|
183 | (1) |
|
Retain the Appropriate Columns |
|
|
183 | (1) |
|
Consider an Intermediate View |
|
|
184 | (1) |
|
Spotting Keywords in Questions |
|
|
184 | (5) |
|
|
185 | (2) |
|
|
187 | (1) |
|
|
188 | (1) |
|
|
189 | (2) |
|
|
189 | (1) |
|
Try to Answer the Question by Hand |
|
|
189 | (1) |
|
Write Down a Description of the Retrieved Result |
|
|
190 | (1) |
|
|
190 | (1) |
|
|
191 | (2) |
|
Check a Row That Should Be Returned |
|
|
192 | (1) |
|
Check a Row That Should Not Be Returned |
|
|
192 | (1) |
|
Check Boundary Conditions |
|
|
192 | (1) |
|
|
193 | (1) |
|
|
193 | (2) |
|
Chapter 12 Common Problems |
|
|
195 | (16) |
|
|
195 | (6) |
|
Data That Is Not Normalized |
|
|
195 | (3) |
|
Tables with No Primary Key |
|
|
198 | (1) |
|
Tables with Missing Foreign Keys |
|
|
199 | (1) |
|
Similar Data in Two Tables |
|
|
199 | (1) |
|
|
200 | (1) |
|
Problems with Data Values |
|
|
201 | (2) |
|
|
201 | (1) |
|
Incorrect or Inconsistent Spelling |
|
|
202 | (1) |
|
Extraneous Characters in Text Fields |
|
|
202 | (1) |
|
Inconsistent Case in Text Fields |
|
|
203 | (1) |
|
|
203 | (2) |
|
Check Parts of Nested Queries Independently |
|
|
204 | (1) |
|
Understand How the Tables Are Being Combined |
|
|
204 | (1) |
|
Remove Extra WHERE Clauses |
|
|
204 | (1) |
|
|
204 | (1) |
|
Check Underlying Queries in Aggregates |
|
|
205 | (1) |
|
|
205 | (4) |
|
|
205 | (1) |
|
|
205 | (2) |
|
More Rows Than There Should Be |
|
|
207 | (1) |
|
Incorrect Statistics or Aggregates |
|
|
208 | (1) |
|
|
209 | (1) |
|
Common Typos and Syntax Problems |
|
|
209 | (1) |
|
|
210 | (1) |
|
Appendix 1 Example Database |
|
|
211 | (2) |
|
Appendix 2 Relational Notation |
|
|
213 | (20) |
|
|
213 | (3) |
|
Relations, Tuples, and Attributes |
|
|
214 | (2) |
|
SQL, Algebra, and Calculus |
|
|
216 | (1) |
|
Relational Algebra: Specifying the Operations |
|
|
216 | (9) |
|
|
217 | (1) |
|
|
218 | (1) |
|
Combining Select and Project |
|
|
218 | (1) |
|
|
219 | (1) |
|
|
220 | (1) |
|
Union, Difference, and Intersection |
|
|
221 | (2) |
|
|
223 | (2) |
|
Relational Calculus: Specifying the Outcome |
|
|
225 | (4) |
|
Simple Calculus Expressions |
|
|
225 | (1) |
|
|
225 | (1) |
|
Existential Quantifier and SQL |
|
|
226 | (2) |
|
Universal Quantifier and SQL |
|
|
228 | (1) |
|
|
229 | (4) |
|
|
229 | (1) |
|
|
230 | (1) |
|
|
231 | (2) |
Index |
|
233 | |