Skip to main content

Joe Celko's SQL for Smarties

Advanced SQL Programming

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… Read more

World Book Day celebration

Where learning shapes lives

Up to 25% off trusted resources that support research, study, and discovery.

Description

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.

Key features

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

Readership

Working SQL programmers, including those application developers, database analysts, and others who want to pick up some advanced programming tips and techniques, and also those who are developing new features for DBMSs who want to know about users' ideas and needs.

Table of contents

Dedication

Introduction to the Third Edition

1.1 What Changed in Ten Years

1.2 What Is New in This Edition

1.3 Corrections and Additions

Chapter 1: Database Design

1.1 Schema and Table Creation

1.2 Generating Unique Sequential Numbers for Keys

1.3 A Remark on Duplicate Rows

1.4 Other Schema Objects

Chapter 2: Normalization

2.1 Functional and Multivalued Dependencies

2.2 First Normal Form (1NF)

2.3 Second Normal Form (2NF)

2.4 Third Normal Form (3NF)

2.5 Elementary Key Normal Form (EKNF)

2.6 Boyce-Codd Normal Form (BCNF)

2.7 Fourth Normal Form (4NF)

2.8 Fifth Normal Form (5NF)

2.9 Domain-Key Normal Form (DKNF)

2.10 Practical Hints for Normalization

2.11 Key Types

Chapter 3: Numeric Data in SQL

3.1 Numeric Types

3.1.1 BIT, BYTE, and BOOLEAN Data Types

3.2 Numeric Type Conversion

3.3 Four-Function Arithmetic

3.4 Arithmetic and NULLs

3.5 Converting Values to and from NULL

3.6 Vendor Math Functions

Chapter 4: Temporal Data Types in SQL

4.1 Notes on Calendar Standards

4.2 SQL Temporal Data Types

4.3 Queries with Date Arithmetic

4.4 The Nature of Temporal Data Models

Chapter 5: Character Data Types in SQL

5.1 Problems with SQL Strings

5.2 Standard String Functions

5.3 Common Vendor Extensions

5.4 Cutter Tables

Chapter 6: NULLs

6.1 Empty and Missing Tables

6.2 Missing Values in Columns

6.3 Context and Missing Values

6.5 NULLs and Logic

6.6 Math and NULLs

6.7 Functions and NULLs

6.8 NULLs and Host Languages

6.9 Design Advice for NULLs

6.10 A Note on Multiple NULL Values

Chapter 7: Multiple Column Data Elements

7.1 Distance Functions

7.2 Storing an IP Address in SQL

7.3 Currency and Other Unit Conversions

7.4 Social Security Numbers

7.5 Rational Numbers

Chapter 8: Table Operations

8.1 Delete From Statement

8.2 Insert into Statement

8.3 The Update Statement

8.4 A Note on Flaws in a Common Vendor Extension

8.5 Merge Statement

Chapter 9: Comparison or Theta Operators

9.1 Converting Data Types

9.2 Row Comparisons in SQL

Chapter 10: Valued Predicates

10.1 IS NULL Predicate

10.2 IS [NOT]{TRUE

Review quotes

"This book is a classic, and this revision will merely solidify its position."—Rudy Limeback "SQL for Smarties is a well-known and highly regarded text in the industry and a new edition of the book will be sought by database practitioners regardless of the DBMS they use."—Craig Mullins, BMC Software

Product details

About the author

JC

Joe Celko

Joe Celko served 10 years on ANSI/ISO SQL Standards Committee and contributed to the SQL-89 and SQL-92 Standards.

Mr. Celko is author a series of books on SQL and RDBMS for Elsevier/MKP. He is an independent consultant based in Austin, Texas.

He has written over 1200 columns in the computer trade and academic press, mostly dealing with data and databases.

Affiliations and expertise
Independent Consultant, Austin, Texas

View book on ScienceDirect

Read Joe Celko's SQL for Smarties on ScienceDirect