Book description
Understanding SQL's underlying theory is the best way to guarantee that your SQL code is correct and your database schema is robust and maintainable. On the other hand, if you're not well versed in the theory, you can fall into several traps. In SQL and Relational Theory, author C.J. Date demonstrates how you can apply relational theory directly to your use of SQL. With numerous examples and clear explanations of the reasoning behind them, you'll learn how to deal with common SQL dilemmas, such as:
- Should database access granted be through views instead of base tables?
- Nulls in your database are causing you to get wrong answers. Why? What can you do about it?
- Could you write an SQL query to find employees who have never been in the same department for more than six months at a time?
- SQL supports "quantified comparisons," but they're better avoided. Why? How do you avoid them?
- Constraints are crucially important, but most SQL products don't support them properly. What can you do to resolve this situation?
Database theory and practice have evolved since Edgar Codd originally defined the relational model back in 1969. Independent of any SQL products, SQL and Relational Theory draws on decades of research to present the most up-to-date treatment of the material available anywhere. Anyone with a modest to advanced background in SQL will benefit from the many insights in this book.
Publisher resources
Table of contents
- Dedication
- Preface
- 1. Setting the Scene
- 2. Types and Domains
- 3. Tuples and Relations, Rows and Tables
- 4. No Duplicates, No Nulls
- 5. Base Relvars, Base Tables
-
6. SQL and Relational Algebra I: The Original Operators
- Some Preliminaries
- More on Closure
- Restriction
- Projection
- Join
- Union, Intersection, and Difference
- Which Operators Are Primitive?
- Formulating Expressions a Step at a Time
- What Do Relational Expressions Mean?
- Evaluating SQL Table Expressions
- Expression Transformation
- The Reliance on Attribute Names
- Exercises
- 7. SQL and Relational Algebra II: Additional Operators
- 8. SQL and Constraints
- 9. SQL and Views
- 10. SQL and Logic
-
11. Using Logic to Formulate SQL Expressions
- Some Transformation Laws
- Example 1: Logical Implication
- Example 2: Universal Quantification
- Example 3: Implication and Universal Quantification
- Example 4: Correlated Subqueries
- Example 5: Naming Subexpressions
- Example 6: More on Naming Subexpressions
- Example 7: Dealing with Ambiguity
- Example 8: Using COUNT
- Example 9: Join Queries
- Example 10: UNIQUE Quantification
- Example 11: ALL or ANY Comparisons
- Example 12: GROUP BY and HAVING
- Exercises
- 12. Miscellaneous SQL Topics
- A. The Relational Model
- B. Database Design Theory
- C. Answers to Exercises
- D. Suggestions for Further Reading
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: SQL and Relational Theory
- Author(s):
- Release date: January 2009
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596523060
You might also like
book
SQL and Relational Theory, 3rd Edition
SQL is full of difficulties and traps for the unwary. You can avoid them if you …
book
SQL and Relational Theory, 2nd Edition
SQL is full of difficulties and traps for the unwary. You can avoid them if you …
video
C.J. Date's SQL and Relational Theory Master Class
Chris Date is the world's best known relational advocate. In this online seminar, he shows howto …
book
The Language of SQL, Second Edition
The Language of SQL, Second Edition Many SQL texts attempt to serve as an encyclopedic reference …