did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780123693792

Joe Celko's SQL for Smarties : Advanced SQL Programming

by
  • ISBN13:

    9780123693792

  • ISBN10:

    0123693799

  • Edition: 3rd
  • Format: Paperback
  • Copyright: 2005-07-29
  • Publisher: Elsevier Science

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
  • Complimentary 7-Day eTextbook Access - Read more
    When you rent or buy this book, you will receive complimentary 7-day online access to the eTextbook version from your PC, Mac, tablet, or smartphone. Feature not included on Marketplace Items.
List Price: $66.95 Save up to $16.74
  • Buy Used
    $50.21
    Add to Cart Free Shipping Icon Free Shipping

    USUALLY SHIPS IN 2-4 BUSINESS DAYS

    7-Day eTextbook Access 7-Day eTextbook Access

Supplemental Materials

What is included with this book?

Summary

SQL for Smarties was hailed as the first book devoted explicitly to the advanced techniques needed to transform an experienced SQL programmer into an expert. Now, 10 years later and in the third edition, this classic still reigns supreme as the book written by an SQL master that teaches future SQL masters. These are not just tips and techniques; Joe also offers the best solutions to old and new challenges and conveys the way you need to think in order to get the most out of SQL programming efforts for both correctness and performance. In the third edition, Joe features new examples and updates to SQL-99, expanded sections of Query techniques, and a new section on schema design, with the same war-story teaching style that made the first and second editions of this book classics. * Expert advice from a noted SQL authority and award-winning columnist, who has given ten years of service to the ANSI SQL standards committee and many more years of dependable help to readers of online forums. * Teaches scores of advanced techniques that can be used with any product, in any SQL environment, whether it is an SQL-92 or SQL-99 environment. * Offers tips for working around system deficiencies. * Continues to use war stories--updated!--that give insights into real-world SQL programming challenges.

Author Biography

Joe Celko is a noted consultant, lecturer, teacher, and one of the most-read SQL authors in the world

Table of Contents

Introduction to the Third Editionp. xxv
What Changed in Ten Yearsp. xxv
What Is New in This Editionp. xxvii
Corrections and Additionsp. xxviii
Database Designp. 1
Schema and Table Creationp. 2
CREATE SCHEMA Statementp. 3
Manipulating Tablesp. 5
Column Constraintsp. 10
UNIQUE Constraints versus UNIQUE Indexesp. 17
Nested UNIQUE Constraintsp. 18
Overlapping Keysp. 22
CREATE ASSERTION Constraintsp. 25
Using VIEWs for Schema Level Constraintsp. 25
Using PRIMARY KEYs and ASSERTIONs for Constraintsp. 29
Avoiding Attribute Splittingp. 31
Modeling Class Hierarchies in DDLp. 34
Generating Unique Sequential Numbers for Keysp. 36
IDENTITY Columnsp. 37
ROWID and Physical Disk Addressesp. 39
Sequential Numbering in Pure SQLp. 39
GUIDsp. 41
Sequence Generator Functionsp. 42
Unique Value Generatorsp. 42
Preallocated Valuesp. 44
Random Order Valuesp. 45
A Remark on Duplicate Rowsp. 48
Other Schema Objectsp. 50
Schema Tablesp. 50
Temporary Tablesp. 51
CREATE DOMAIN Statementp. 51
CREATE TRIGGER Statementp. 52
CREATE PROCEDURE Statementp. 53
DECLARE CURSOR Statementp. 53
Normalizationp. 61
Functional and Multivalued Dependenciesp. 64
First Normal Form (1NF)p. 64
Note on Repeated Groupsp. 66
Second Normal Form (2NF)p. 70
Third Normal Form (3NF)p. 71
Elementary Key Normal Form (EKNF)p. 72
Boyce-Codd Normal Form (BCNF)p. 73
Fourth Normal Form (4NF)p. 75
Fifth Normal Form (5NF)p. 76
Domain-Key Normal Form (DKNF)p. 78
Practical Hints for Normalizationp. 87
Key Typesp. 88
Natural Keysp. 89
Artificial Keysp. 89
Exposed Physical Locatorsp. 89
Practical Hints for Denormalizationp. 91
Row Sortingp. 93
Numeric Data in SQLp. 101
Numeric Typesp. 101
BIT, BYTE, and BOOLEAN Data Typesp. 104
Numeric Type Conversionp. 105
Rounding and Truncatingp. 105
CAST() Functionp. 107
Four-Function Arithmeticp. 108
Arithmetic and NULLsp. 109
Converting Values to and from NULLp. 110
NULLIF() Functionp. 110
COALESCE() Functionp. 111
Vendor Math Functionsp. 113
Number Theory Operatorsp. 113
Exponential Functionsp. 116
Scaling Functionsp. 116
Converting Numbers to Wordsp. 117
Temporal Data Types in SQLp. 119
Notes on Calendar Standardsp. 119
SQL Temporal Data Typesp. 123
Tips for Handling Dates, Timestamps, and Timesp. 124
Date Format Standardsp. 124
Handling Timestampsp. 125
Handling Timesp. 127
Queries with Date Arithmeticp. 128
The Nature of Temporal Data Modelsp. 129
Temporal Duplicatesp. 129
Temporal Databasesp. 135
Temporal Projection and Selectionp. 137
Temporal Joinsp. 139
Modifying Valid-Time State Tablesp. 145
Current Modificationsp. 146
Sequenced Modificationsp. 150
Nonsequenced Modificationsp. 155
Transaction-Time State Tablesp. 156
Maintaining the Audit Logp. 158
Querying the Audit Logp. 160
Modifying the Audit Logp. 164
Bitemporal Tablesp. 164
Temporal Support in Standard SQLp. 167
Character Data Types in SQLp. 169
Problems with SQL Stringsp. 170
Problems of String Equalityp. 170
Problems of String Orderingp. 171
Problems of String Groupingp. 172
Standard String Functionsp. 172
Common Vendor Extensionsp. 174
Phonetic Matchingp. 175
Cutter Tablesp. 182
NULLs: Missing Data in SQLp. 185
Empty and Missing Tablesp. 187
Missing Values in Columnsp. 187
Context and Missing Valuesp. 189
Comparing NULLsp. 190
NULLs and Logicp. 190
NULLS in Subquery Predicatesp. 191
Standard SQL Solutionsp. 193
Math and NULLsp. 193
Functions and NULLsp. 193
NULLs and Host Languagesp. 194
Design Advice for NULLsp. 195
Avoiding NULLs from the Host Programsp. 197
A Note on Multiple NULL Valuesp. 198
Multiple Column Data Elementsp. 201
Distance Functionsp. 201
Storing an IP Address in SQLp. 202
A Single VARCHAR(15) Columnp. 203
One INTEGER Columnp. 203
Four SMALLINT Columnsp. 205
Currency and Other Unit Conversionsp. 205
Social Security Numbersp. 206
Rational Numbersp. 209
Table Operationsp. 211
DELETE FROM Statementp. 211
The DELETE FROM Clausep. 212
The WHERE Clausep. 212
Deleting Based on Data in a Second Tablep. 216
Deleting within the Same Tablep. 216
Deleting in Multiple Tables without Referential Integrityp. 220
INSERT INTO Statementp. 221
INSERT INTO Clausep. 221
The Nature of Insertsp. 222
Bulk Load and Unload Utilitiesp. 223
The UPDATE Statementp. 223
The UPDATE Clausep. 223
The WHERE Clausep. 224
The SET Clausep. 225
Updating with a Second Tablep. 226
Using the CASE Expression in UPDATEsp. 228
A Note on Flaws in a Common Vendor Extensionp. 231
MERGE Statementp. 232
Comparison or Theta Operatorsp. 235
Converting Data Typesp. 236
Row Comparisons in SQLp. 238
Valued Predicatesp. 241
IS NULL Predicatep. 241
Sources of NULLsp. 242
IS [NOT] {TRUE [vertical bar] FALSE [vertical bar] UNKNOWN} Predicatep. 242
IS [NOT] NORMALIZED Predicatep. 244
CASE Expressionsp. 247
The CASE Expressionp. 247
The COALESCE() and NULLIF() Functionsp. 251
CASE Expressions with GROUP BYp. 252
CASE, CHECK() Clauses and Logical Implicationp. 253
Subquery Expressions and Constantsp. 257
Rozenshtein Characteristic Functionsp. 258
LIKE Predicatep. 261
Tricks with Patternsp. 262
Results with NULL Values and Empty Stringsp. 264
LIKE Is Not Equalityp. 264
Avoiding the LIKE Predicate with a Joinp. 264
CASE Expressions and LIKE Predicatesp. 266
SIMILAR TO Predicatesp. 267
Tricks with Stringsp. 269
String Character Contentp. 269
Searching versus Declaring a Stringp. 270
Creating an Index on a Stringp. 270
BETWEEN and OVERLAPS Predicatesp. 273
The BETWEEN Predicatep. 273
Results with NULL Valuesp. 274
Results with Empty Setsp. 274
Programming Tipsp. 274
OVERLAPS Predicatep. 275
Time Periods and OVERLAPS Predicatep. 275
The [NOT] IN() Predicatep. 287
Optimizing the IN() Predicatep. 288
Replacing ORs with the IN() Predicatep. 292
NULLs and the IN() Predicatep. 293
IN() Predicate and Referential Constraintsp. 295
IN() Predicate and Scalar Queriesp. 297
EXISTS() Predicatep. 299
EXISTS and NULLsp. 300
EXISTS and INNER JOINsp. 302
NOT EXISTS and OUTER JOINsp. 303
EXISTS() and Quantifiersp. 304
EXISTS() and Referential Constraintsp. 305
EXISTS and Three-Valued Logicp. 306
Quantified Subquery Predicatesp. 309
Scalar Subquery Comparisonsp. 310
Quantifiers and Missing Datap. 311
The ALL Predicate and Extrema Functionsp. 313
The UNIQUE Predicatep. 314
The SELECT Statementp. 317
SELECT and JOINsp. 317
One-Level SELECT Statementp. 317
Correlated Subqueries in a SELECT Statementp. 324
SELECT Statement Syntaxp. 326
The ORDER BY Clausep. 328
OUTER JOINsp. 336
Syntax for OUTER JOINsp. 337
NULLs and OUTER JOINsp. 342
NATURAL versus Searched OUTER JOINsp. 344
Self OUTER JOINsp. 345
Two or More OUTER JOINsp. 346
OUTER JOINs and Aggregate Functionsp. 348
FULL OUTER JOINp. 349
WHERE Clause OUTER JOIN Operatorsp. 350
Old versus New JOIN Syntaxp. 351
Scope of Derived Table Namesp. 353
JOINs by Function Callsp. 354
The UNION JOINp. 356
Packing Joinsp. 358
Dr. Codd's T-Joinp. 359
The Croatian Solutionp. 363
The Swedish Solutionp. 364
The Colombian Solutionp. 364
VIEWs, Derived Tables, Materialized Tables, and Temporary Tablesp. 369
VIEWs in Queriesp. 370
Updatable and Read-Only VIEWsp. 371
Types of VIEWsp. 373
Single-Table Projection and Restrictionp. 373
Calculated Columnsp. 373
Translated Columnsp. 373
Grouped VIEWsp. 374
UNIONed VIEWsp. 375
JOINs in VIEWsp. 377
Nested VIEWsp. 377
How VIEWs Are Handled in the Database Systemp. 379
View Column Listp. 379
VIEW Materializationp. 379
In-Line Text Expansionp. 380
Pointer Structuresp. 382
Indexing and Viewsp. 383
WITH CHECK OPTION Clausep. 383
WITH CHECK OPTION as CHECK() Clausep. 388
Dropping VIEWsp. 389
TEMPORARY TABLE Declarationsp. 390
Hints on Using VIEWs and TEMPORARY TABLEsp. 391
Using VIEWsp. 392
Using TEMPORARY TABLEsp. 392
Flattening a Table with a VIEWp. 393
Using Derived Tablesp. 395
Derived Tables in the FROM clausep. 395
Derived Tables with a VALUES Constructorp. 397
Derived Tables in the WITH Clausep. 397
Partitioning Data in Queriesp. 401
Coverings and Partitionsp. 401
Partitioning by Rangesp. 402
Partition by Functionsp. 403
Partition by Sequencesp. 404
Relational Divisionp. 406
Division with a Remainderp. 408
Exact Divisionp. 409
Note on Performancep. 410
Todd's Divisionp. 410
Division with JOINsp. 413
Division with Set Operatorsp. 413
Romley's Divisionp. 414
Boolean Expressions in an RDBMSp. 418
FIFO and LIFO Subsetsp. 420
Grouping Operationsp. 425
GROUP BY Clausep. 425
NULLs and Groupsp. 427
GROUP BY and HAVINGp. 427
Group Characteristics and the HAVING Clausep. 429
Multiple Aggregation Levelsp. 431
Grouped VIEWs for Multiple Aggregation Levelsp. 432
Subquery Expressions for Multiple Aggregation Levelsp. 433
CASE Expressions for Multiple Aggregation Levelsp. 434
Grouping on Computed Columnsp. 435
Grouping into Pairsp. 436
Sorting and GROUP BYp. 437
Aggregate Functionsp. 439
COUNT() Functionsp. 440
SUM() Functionsp. 443
AVG() Functionsp. 444
Averages with Empty Groupsp. 446
Averages across Columnsp. 448
Extrema Functionsp. 449
Simple Extrema Functionsp. 449
Generalized Extrema Functionsp. 451
Multiple Criteria Extrema Functionsp. 460
GREATEST() and LEAST() Functionsp. 462
The LIST() Aggregate Functionp. 465
The LIST() Function with a Procedurep. 466
The LIST() Function by Crosstabsp. 467
The PRD() Aggregate Functionp. 468
PRD() Function by Expressionsp. 469
The PRD() Aggregate Function by Logarithmsp. 470
Bitwise Aggregate Functionsp. 473
Bitwise OR Aggregate Functionp. 474
Bitwise AND Aggregate Functionp. 475
Auxiliary Tablesp. 477
The Sequence Tablep. 477
Enumerating a Listp. 479
Mapping a Sequence into a Cyclep. 481
Replacing an Iterative Loopp. 483
Lookup Auxiliary Tablesp. 485
Simple Translation Auxiliary Tablesp. 487
Multiple Translation Auxiliary Tablesp. 487
Multiple Parameter Auxiliary Tablesp. 488
Range Auxiliary Tablesp. 489
Hierarchical Auxiliary Tablesp. 490
One True Lookup Tablep. 491
Auxiliary Function Tablesp. 493
Inverse Functions with Auxiliary Tablesp. 495
Interpolation with Auxiliary Function Tablesp. 504
Global Constants Tablesp. 506
Statistics in SQLp. 509
The Modep. 510
The AVG() Functionp. 512
The Medianp. 512
Date's First Medianp. 513
Celko's First Medianp. 514
Date's Second Medianp. 516
Murchison's Medianp. 516
Celko's Second Medianp. 517
Vaughan's Median with VIEWsp. 519
Median with Characteristic Functionp. 520
Celko's Third Medianp. 522
Ken Henderson's Medianp. 526
Variance and Standard Deviationp. 527
Average Deviationp. 528
Cumulative Statisticsp. 528
Running Totalsp. 529
Running Differencesp. 530
Cumulative Percentagesp. 531
Rankings and Related Statisticsp. 533
Quintiles and Related Statisticsp. 537
Cross Tabulationsp. 538
Crosstabs by Cross Joinp. 542
Crosstabs by Outer Joinsp. 543
Crosstabs by Subqueryp. 544
Crosstabs by CASE Expressionp. 545
Harmonic Mean and Geometric Meanp. 545
Multivariable Descriptive Statistics in SQLp. 546
Covariancep. 546
Pearson's rp. 547
NULLs in Multivariable Descriptive Statisticsp. 548
Regions, Runs, Gaps, Sequences, and Seriesp. 549
Finding Subregions of Size (n)p. 550
Numbering Regionsp. 551
Finding Regions of Maximum Sizep. 552
Bound Queriesp. 557
Run and Sequence Queriesp. 557
Filling in Sequence Numbersp. 560
Summation of a Seriesp. 562
Swapping and Sliding Values in a Listp. 565
Condensing a List of Numbersp. 567
Folding a List of Numbersp. 567
Coveringsp. 568
Arrays in SQLp. 575
Arrays via Named Columnsp. 576
Arrays via Subscript Columnsp. 580
Matrix Operations in SQLp. 581
Matrix Equalityp. 582
Matrix Additionp. 582
Matrix Multiplicationp. 583
Other Matrix Operationsp. 585
Flattening a Table into an Arrayp. 585
Comparing Arrays in Table Formatp. 587
Set Operationsp. 591
UNION and UNION ALLp. 592
Order of Executionp. 594
Mixed UNION and UNION ALL Operatorsp. 595
UNION of Columns from the Same Tablep. 595
INTERSECT and EXCEPTp. 596
INTERSECT and EXCEPT without NULLs and Duplicatesp. 599
INTERSECT and EXCEPT with NULLs and Duplicatesp. 600
A Note on ALL and SELECT DISTINCTp. 601
Equality and Proper Subsetsp. 602
Subsetsp. 605
Every nth Item in a Tablep. 605
Picking Random Rows from a Tablep. 607
The CONTAINS Operatorsp. 612
Proper Subset Operatorsp. 612
Table Equalityp. 613
Picking a Representative Subsetp. 618
Trees and Hierarchies in SQLp. 623
Adjacency List Modelp. 624
Complex Constraintsp. 625
Procedural Traversal for Queriesp. 627
Altering the Tablep. 628
The Path Enumeration Modelp. 628
Finding Subtrees and Nodesp. 629
Finding Levels and Subordinatesp. 630
Deleting Nodes and Subtreesp. 630
Integrity Constraintsp. 631
Nested Set Model of Hierarchiesp. 631
The Counting Propertyp. 633
The Containment Propertyp. 634
Subordinatesp. 635
Hierarchical Aggregationsp. 636
Deleting Nodes and Subtreesp. 636
Converting Adjacency List to Nested Set Modelp. 637
Other Models for Trees and Hierarchiesp. 639
Temporal Queriesp. 641
Temporal Mathp. 642
Personal Calendarsp. 643
Time Seriesp. 645
Gaps in a Time Seriesp. 645
Continuous Time Periodsp. 648
Missing Times in Contiguous Eventsp. 652
Locating Datesp. 656
Temporal Starting and Ending Pointsp. 658
Average Wait Timesp. 660
Julian Datesp. 661
Date and Time Extraction Functionsp. 665
Other Temporal Functionsp. 666
Weeksp. 667
Sorting by Weekday Namesp. 669
Modeling Time in Tablesp. 670
Using Duration Pairsp. 672
Calendar Auxiliary Tablep. 673
Problems with the Year 2000p. 675
The Zerosp. 675
Leap Yearp. 676
The Millenniump. 677
Weird Dates in Legacy Datap. 679
The Aftermathp. 680
Graphs in SQLp. 681
Basic Graph Characteristicsp. 682
All Nodes in the Graphp. 682
Path Endpointsp. 683
Reachable Nodesp. 683
Edgesp. 684
Indegree and Outdegreep. 684
Source, Sink, Isolated, and Internal Nodesp. 685
Paths in a Graphp. 686
Length of Pathsp. 687
Shortest Pathp. 687
Paths by Iterationp. 688
Listing the Pathsp. 691
Acyclic Graphs as Nested Setsp. 695
Paths with CTEp. 697
Nonacyclic Graphsp. 703
Adjacency Matrix Modelp. 705
Points inside Polygonsp. 706
OLAP in SQLp. 709
Star Schemap. 710
OLAP Functionalityp. 711
RANK and DENSE_RANKp. 711
Row Numberingp. 711
GROUPING Operatorsp. 712
The Window Clausep. 714
OLAP Examples of SQLp. 716
Enterprise-Wide Dimensional Layerp. 717
A Bit of Historyp. 718
Transactions and Concurrency Controlp. 719
Sessionsp. 719
Transactions and ACIDp. 720
Atomicityp. 720
Consistencyp. 721
Isolationp. 721
Durabilityp. 722
Concurrency Controlp. 722
The Five Phenomenap. 722
The Isolation Levelsp. 724
CURSOR STABILITY Isolation Levelp. 726
Pessimistic Concurrency Controlp. 726
SNAPSHOT Isolation: Optimistic Concurrencyp. 727
Logical Concurrency Controlp. 729
Deadlock and Livelocksp. 730
Optimizing SQLp. 731
Access Methodsp. 732
Sequential Accessp. 732
Indexed Accessp. 732
Hashed Indexesp. 733
Bit Vector Indexesp. 733
Expressions and Unnested Queriesp. 733
Use Simple Expressionsp. 734
String Expressionsp. 738
Give Extra Join Information in Queriesp. 738
Index Tables Carefullyp. 740
Watch the IN Predicatep. 742
Avoid UNIONsp. 744
Prefer Joins over Nested Queriesp. 745
Avoid Expressions on Indexed Columnsp. 746
Avoid Sortingp. 746
Avoid CROSS JOINsp. 750
Learn to Use Indexes Carefullyp. 751
Order Indexes Carefullyp. 752
Know Your Optimizerp. 754
Recompile Static SQL after Schema Changesp. 756
Temporary Tables Are Sometimes Handyp. 757
Update Statisticsp. 760
Referencesp. 761
General Referencesp. 761
Logicp. 761
Mathematical Techniquesp. 761
Random Numbersp. 762
Scales and Measurementsp. 763
Missing Valuesp. 763
Regular Expressionsp. 764
Graph Theoryp. 765
Introductory SQL Booksp. 765
Optimizing Queriesp. 766
Temporal Data and the Year 2000 Problemp. 766
SQL Programming Techniquesp. 768
Classicsp. 768
Forump. 769
Updatable Viewsp. 769
Theory, Normalization, and Advanced Database Topicsp. 770
Books on SQL-92 and SQL-99p. 771
Standards and Related Groupsp. 771
Web Sites Related to SQLp. 772
Statisticsp. 772
Temporal Databasesp. 773
New Citationsp. 774
Indexp. 777
About the Authorp. 810
Table of Contents provided by Ingram. All Rights Reserved.

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program