Introduction |
|
1 | (1) |
|
|
1 | (1) |
|
Who Should Read This Book? |
|
|
2 | (1) |
|
How This Book Is Organized |
|
|
2 | (2) |
|
|
2 | (1) |
|
Part II: Using SQL to Build Databases |
|
|
2 | (1) |
|
Part III: Storing and Retrieving Data |
|
|
3 | (1) |
|
Part IV: Controlling Operations |
|
|
3 | (1) |
|
Part V: Taking SQL to the Real World |
|
|
3 | (1) |
|
|
3 | (1) |
|
Part VII: The Part of Tens |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
4 | (1) |
|
|
5 | (68) |
|
Relational Database Fundamentals |
|
|
7 | (14) |
|
|
7 | (1) |
|
|
8 | (1) |
|
Database Size and Complexity |
|
|
9 | (1) |
|
What Is a Database Management System? |
|
|
9 | (1) |
|
|
10 | (2) |
|
|
12 | (8) |
|
|
12 | (1) |
|
|
13 | (1) |
|
Components of a relational database |
|
|
13 | (1) |
|
Holidays bring families together |
|
|
13 | (2) |
|
|
15 | (3) |
|
Schemas, domains, and constraints |
|
|
18 | (1) |
|
The object model challenges the relational model |
|
|
19 | (1) |
|
The object-relational model |
|
|
19 | (1) |
|
Database Design Considerations |
|
|
20 | (1) |
|
|
21 | (26) |
|
|
21 | (2) |
|
|
23 | (1) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
26 | (16) |
|
|
26 | (2) |
|
|
28 | (2) |
|
|
30 | (2) |
|
|
32 | (1) |
|
|
32 | (2) |
|
|
34 | (1) |
|
|
34 | (1) |
|
|
35 | (1) |
|
|
36 | (1) |
|
|
37 | (1) |
|
|
37 | (3) |
|
|
40 | (2) |
|
|
42 | (1) |
|
|
42 | (1) |
|
Using SQL in a Client/Server System |
|
|
43 | (2) |
|
|
43 | (1) |
|
|
44 | (1) |
|
Using SQL on the Internet/Intranet |
|
|
45 | (2) |
|
|
47 | (26) |
|
|
48 | (11) |
|
When ``Just do it!'' is not good advice |
|
|
48 | (1) |
|
|
49 | (2) |
|
|
51 | (5) |
|
Collecting tables into schemas |
|
|
56 | (1) |
|
|
57 | (1) |
|
Getting familiar with DDL commands |
|
|
58 | (1) |
|
Data Manipulation Language |
|
|
59 | (7) |
|
|
60 | (3) |
|
|
63 | (1) |
|
|
64 | (1) |
|
|
64 | (2) |
|
|
66 | (1) |
|
|
66 | (7) |
|
|
66 | (1) |
|
|
67 | (3) |
|
Referential integrity constraints can jeopardize your data |
|
|
70 | (2) |
|
Delegating responsibility for security |
|
|
72 | (1) |
|
Part II: Using SQL to Build Databases |
|
|
73 | (48) |
|
Building and Maintaining a Simple Database Structure |
|
|
75 | (16) |
|
Building a Simple Database Using a RAD Tool |
|
|
76 | (10) |
|
|
76 | (1) |
|
Creating a table with Design View |
|
|
77 | (3) |
|
Altering the table structure |
|
|
80 | (2) |
|
Identifying a primary key |
|
|
82 | (1) |
|
|
83 | (2) |
|
|
85 | (1) |
|
Building PowerDesign with SQL's DDL |
|
|
86 | (4) |
|
Using SQL with Microsoft Access |
|
|
87 | (1) |
|
|
87 | (1) |
|
|
88 | (1) |
|
Altering the table structure |
|
|
89 | (1) |
|
|
89 | (1) |
|
|
90 | (1) |
|
Portability Considerations |
|
|
90 | (1) |
|
Building a Multitable Relational Database |
|
|
91 | (30) |
|
|
91 | (9) |
|
|
92 | (1) |
|
Step 2: Identifying tables and columns |
|
|
92 | (1) |
|
|
93 | (4) |
|
Domains, character sets, collations, and translations |
|
|
97 | (1) |
|
Getting into your database fast with keys |
|
|
98 | (2) |
|
|
100 | (4) |
|
|
101 | (1) |
|
Why you should want an index |
|
|
102 | (1) |
|
|
103 | (1) |
|
|
104 | (10) |
|
|
104 | (1) |
|
|
105 | (1) |
|
|
106 | (3) |
|
Just when you thought it was safe |
|
|
109 | (1) |
|
|
109 | (2) |
|
|
111 | (3) |
|
|
114 | (7) |
|
|
116 | (1) |
|
|
117 | (1) |
|
|
118 | (1) |
|
Domain-key normal form (DK/NF) |
|
|
119 | (1) |
|
|
120 | (1) |
|
Part III: Storing and Retrieving Data |
|
|
121 | (132) |
|
Manipulating Database Data |
|
|
123 | (18) |
|
|
124 | (1) |
|
|
125 | (4) |
|
|
126 | (1) |
|
With a selection condition |
|
|
127 | (1) |
|
With a modified attribute |
|
|
128 | (1) |
|
|
129 | (1) |
|
|
130 | (5) |
|
Adding data one row at a time |
|
|
130 | (2) |
|
Adding data only to selected columns |
|
|
132 | (1) |
|
Adding a block of rows to a table |
|
|
132 | (3) |
|
|
135 | (3) |
|
|
138 | (1) |
|
|
139 | (2) |
|
|
141 | (22) |
|
|
141 | (6) |
|
|
142 | (1) |
|
|
142 | (2) |
|
|
144 | (2) |
|
|
146 | (1) |
|
|
146 | (1) |
|
|
147 | (4) |
|
|
148 | (1) |
|
Numeric value expressions |
|
|
149 | (1) |
|
Datetime value expressions |
|
|
149 | (1) |
|
Interval value expressions |
|
|
150 | (1) |
|
Conditional value expressions |
|
|
150 | (1) |
|
|
151 | (12) |
|
Summarizing by using set functions |
|
|
151 | (3) |
|
|
154 | (9) |
|
Using Advanced SQL Value Expressions |
|
|
163 | (12) |
|
CASE Conditional Expressions |
|
|
163 | (7) |
|
Using CASE with search conditions |
|
|
164 | (2) |
|
|
166 | (2) |
|
A special CASE --- NULLIF |
|
|
168 | (2) |
|
Another special CASE --- COALESCE |
|
|
170 | (1) |
|
CAST Data-Type Conversions |
|
|
170 | (3) |
|
|
172 | (1) |
|
Using CAST between SQL and the host language |
|
|
172 | (1) |
|
|
173 | (2) |
|
Zeroing In on the Data You Want |
|
|
175 | (26) |
|
|
175 | (2) |
|
|
177 | (1) |
|
|
177 | (17) |
|
|
179 | (1) |
|
|
180 | (1) |
|
|
181 | (1) |
|
|
182 | (2) |
|
|
184 | (1) |
|
|
184 | (1) |
|
|
185 | (3) |
|
|
188 | (1) |
|
|
189 | (1) |
|
|
189 | (1) |
|
|
190 | (1) |
|
|
190 | (2) |
|
Referential integrity rules and the Match predicate |
|
|
192 | (2) |
|
|
194 | (2) |
|
|
194 | (1) |
|
|
195 | (1) |
|
|
195 | (1) |
|
|
196 | (1) |
|
|
197 | (1) |
|
|
198 | (3) |
|
Using Relational Operators |
|
|
201 | (24) |
|
|
201 | (3) |
|
|
203 | (1) |
|
The Corresponding operation |
|
|
203 | (1) |
|
|
204 | (1) |
|
|
205 | (1) |
|
|
206 | (17) |
|
|
206 | (2) |
|
|
208 | (2) |
|
|
210 | (1) |
|
|
210 | (1) |
|
|
211 | (1) |
|
|
211 | (1) |
|
|
212 | (1) |
|
|
213 | (3) |
|
|
216 | (7) |
|
|
223 | (2) |
|
Delving Deep with Nested Queries |
|
|
225 | (18) |
|
|
226 | (17) |
|
Nested queries that return sets of rows |
|
|
227 | (3) |
|
Nested queries that return a single value |
|
|
230 | (3) |
|
The All, Some, and Any quantifiers |
|
|
233 | (2) |
|
Nested queries that are an existence test |
|
|
235 | (1) |
|
Other correlated subqueries |
|
|
236 | (4) |
|
Update, Delete, and Insert statements |
|
|
240 | (3) |
|
|
243 | (10) |
|
|
243 | (3) |
|
Houston, we have a problem |
|
|
244 | (1) |
|
|
244 | (2) |
|
What Is a Recursive Query? |
|
|
246 | (1) |
|
Where Might You Use a Recursive Query? |
|
|
247 | (5) |
|
|
248 | (1) |
|
Saving time with a recursive query |
|
|
249 | (3) |
|
Where Else Might You Use a Recursive Query? |
|
|
252 | (1) |
|
Part IV: Controlling Operations |
|
|
253 | (48) |
|
Providing Database Security |
|
|
255 | (14) |
|
The SQL Data Control Language |
|
|
256 | (1) |
|
|
256 | (2) |
|
The database administrator |
|
|
256 | (1) |
|
|
257 | (1) |
|
|
257 | (1) |
|
Granting Privileges to Users |
|
|
258 | (7) |
|
|
260 | (1) |
|
|
260 | (1) |
|
|
260 | (1) |
|
|
261 | (1) |
|
Deleting obsolete rows from a table |
|
|
262 | (1) |
|
Referencing related tables |
|
|
262 | (1) |
|
Using domains, character sets, collations, and translations |
|
|
263 | (1) |
|
Causing SQL statements to be executed |
|
|
264 | (1) |
|
Granting the Power to Grant Privileges |
|
|
265 | (1) |
|
|
266 | (2) |
|
Using GRANT and REVOKE Together to Save Time and Effort |
|
|
268 | (1) |
|
|
269 | (18) |
|
Threats to Data Integrity |
|
|
269 | (4) |
|
|
270 | (1) |
|
|
270 | (1) |
|
|
271 | (2) |
|
Reducing Vulnerability to Data Corruption |
|
|
273 | (9) |
|
|
274 | (1) |
|
|
275 | (1) |
|
|
276 | (2) |
|
The implicit transaction-starting statement |
|
|
278 | (1) |
|
|
278 | (1) |
|
|
279 | (1) |
|
|
279 | (1) |
|
|
280 | (1) |
|
|
281 | (1) |
|
Savepoints and subtransactions |
|
|
281 | (1) |
|
Constraints Within Transactions |
|
|
282 | (5) |
|
Using SQL within Applications |
|
|
287 | (14) |
|
|
288 | (3) |
|
Keeping an eye out for the asterisk |
|
|
288 | (1) |
|
SQL strengths and weaknesses |
|
|
289 | (1) |
|
Procedural language strengths and weaknesses |
|
|
289 | (1) |
|
Problems in combining SQL with a procedural language |
|
|
290 | (1) |
|
Hooking SQL into Procedural Languages |
|
|
291 | (10) |
|
|
291 | (3) |
|
|
294 | (2) |
|
Object-oriented RAD tools |
|
|
296 | (1) |
|
Using SQL with Microsoft Access |
|
|
297 | (4) |
|
Part V: Taking SQL to the Real World |
|
|
301 | (32) |
|
Accessing Data with ODBC and JDBC |
|
|
303 | (10) |
|
|
304 | (1) |
|
|
304 | (1) |
|
|
304 | (1) |
|
ODBC in a Client/Server Environment |
|
|
305 | (1) |
|
|
306 | (13) |
|
|
307 | (1) |
|
|
308 | (11) |
|
|
319 | |
|
|
310 | (3) |
|
Operating on XML Data with SQL |
|
|
313 | (20) |
|
|
313 | (1) |
|
|
314 | (2) |
|
|
314 | (1) |
|
When not to use the XML type |
|
|
315 | (1) |
|
Mapping SQL to XML and XML to SQL |
|
|
316 | (4) |
|
|
316 | (1) |
|
|
316 | (1) |
|
|
317 | (1) |
|
|
318 | (1) |
|
|
318 | (1) |
|
Generating the XML Schema |
|
|
319 | (1) |
|
SQL Functions that Operate on XML Data |
|
|
320 | (4) |
|
|
320 | (1) |
|
|
321 | (1) |
|
|
321 | (1) |
|
|
322 | (1) |
|
|
322 | (1) |
|
|
323 | (1) |
|
|
323 | (1) |
|
|
323 | (1) |
|
|
324 | (1) |
|
|
324 | (2) |
|
|
325 | (1) |
|
|
325 | (1) |
|
|
325 | (1) |
|
|
326 | (1) |
|
Transforming XML Data into SQL Tables |
|
|
326 | (2) |
|
Mapping Non-Predefined Data Types to XML |
|
|
328 | (4) |
|
|
328 | (1) |
|
|
329 | (1) |
|
|
329 | (1) |
|
|
330 | (1) |
|
|
331 | (1) |
|
The Marriage of SQL and XML |
|
|
332 | (1) |
|
|
333 | (40) |
|
Stepping through a Dataset with Cursors |
|
|
335 | (10) |
|
|
336 | (4) |
|
|
337 | (1) |
|
|
337 | (1) |
|
|
338 | (1) |
|
|
339 | (1) |
|
|
340 | (1) |
|
|
340 | (2) |
|
Fetching Data from a Single Row |
|
|
342 | (2) |
|
|
342 | (1) |
|
Orientation of a scrollable cursor |
|
|
343 | (1) |
|
Positioned Delete and Update statements |
|
|
343 | (1) |
|
|
344 | (1) |
|
Adding Procedural Capabilities with Persistent Stored Modules |
|
|
345 | (16) |
|
|
345 | (7) |
|
|
346 | (1) |
|
|
347 | (1) |
|
|
348 | (1) |
|
|
348 | (1) |
|
|
349 | (2) |
|
Conditions that aren't handled |
|
|
351 | (1) |
|
|
352 | (1) |
|
Flow of Control Statements |
|
|
352 | (5) |
|
If. . .Then. . .Else. . .End If |
|
|
352 | (1) |
|
|
353 | (1) |
|
|
354 | (1) |
|
|
355 | (1) |
|
While. . .Do. . .End While |
|
|
355 | (1) |
|
Repeat. . .Until. . .End Repeat |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
357 | (1) |
|
|
358 | (1) |
|
|
359 | (1) |
|
|
359 | (2) |
|
|
361 | (12) |
|
|
361 | (2) |
|
|
363 | (1) |
|
|
364 | (7) |
|
The diagnostics header area |
|
|
364 | (2) |
|
The diagnostics detail area |
|
|
366 | (2) |
|
Constraint violation example |
|
|
368 | (1) |
|
Adding constraints to an existing table |
|
|
369 | (1) |
|
Interpreting the information returned by SQLSTATE |
|
|
370 | (1) |
|
|
371 | (2) |
|
Part VII: The Part of Tens |
|
|
373 | (10) |
|
|
375 | (4) |
|
Assuming That Your Clients Know What They Need |
|
|
375 | (1) |
|
|
376 | (1) |
|
Considering Only Technical Factors |
|
|
376 | (1) |
|
Not Asking for Client Feedback |
|
|
376 | (1) |
|
Always Using Your Favorite Development Environment |
|
|
377 | (1) |
|
Using Your Favorite System Architecture Exclusively |
|
|
377 | (1) |
|
Designing Database Tables in Isolation |
|
|
377 | (1) |
|
Neglecting Design Reviews |
|
|
378 | (1) |
|
|
378 | (1) |
|
Not Documenting Your Process |
|
|
378 | (1) |
|
|
379 | (4) |
|
Verify the Database Structure |
|
|
379 | (1) |
|
Try Queries on a Test Database |
|
|
380 | (1) |
|
Double-Check Queries That Include Joins |
|
|
380 | (1) |
|
Triple-Check Queries with Subselects |
|
|
380 | (1) |
|
Summarize Data with Group by |
|
|
380 | (1) |
|
Watch Group by Clause Restrictions |
|
|
381 | (1) |
|
Use Parentheses with AND, OR, and NOT |
|
|
381 | (1) |
|
Control Retrieval Privileges |
|
|
381 | (1) |
|
Back Up Your Databases Regularly |
|
|
382 | (1) |
|
Handle Error Conditions Gracefully |
|
|
382 | (1) |
|
|
383 | (14) |
|
Appendix A: SQL:2003 Reserved Words |
|
|
385 | (4) |
|
|
389 | (8) |
Index |
|
397 | |