SQL and Relational Theory, 3rd Edition

Book description

SQL is full of difficulties and traps for the unwary. You can avoid them if you understand relational theory, but only if you know how to put that theory into practice. In this book, Chris Date explains relational theory in depth, and demonstrates through numerous examples and exercises how you can apply it to your use of SQL.

This third edition has been revised, extended, and improved throughout. Topics whose treatment has been expanded include data types and domains, table comparisons, image relations, aggregate operators and summarization, view updating, and subqueries. A special feature of this edition is a new appendix on NoSQL and relational theory.

Publisher resources

View/Submit Errata

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. About the Author
  6. Contents
  7. Preface to the First Edition
  8. Preface to the Second Edition
  9. Preface to the Third Edition
  10. Chapter 1: Setting the Scene
    1. The relational model is much misunderstood
    2. Some remarks on terminology
    3. Principles not products
    4. A review of the original model
    5. Model vs. implementation
    6. Properties of relations
    7. Base vs. derived relations
    8. Relations vs. relvars
    9. Values vs. variables
    10. Concluding remarks
    11. Exercises
    12. Answers
  11. Chapter 2: Types and Domains
    1. Types and relations
    2. Equality comparisons
    3. Data value atomicity
    4. What’s a type?
    5. Scalar vs. nonscalar types
    6. Scalar types in SQL
    7. Type checking and coercion in SQL
    8. Collations in SQL
    9. Row and table types in SQL
    10. Concluding remarks
    11. Exercises
    12. Answers
  12. Chapter 3: Tuples and Relations, Rows and Tables
    1. What’s a tuple?
    2. Rows in SQL
    3. What’s a relation?
    4. Relations and their bodies
    5. Relations are n-dimensional
    6. Relational comparisons
    7. TABLE_DUM and TABLE_DEE
    8. Tables in SQL
    9. Column naming in SQL
    10. Concluding remarks
    11. Exercises
    12. Answers
  13. Chapter 4: No Duplicates, No Nulls
    1. What’s wrong with duplicates?
    2. Duplicates: further issues
    3. Avoiding duplicates in SQL
    4. What’s wrong with nulls?
    5. Avoiding nulls in SQL
    6. A remark on outer join
    7. Concluding remarks
    8. Exercises
    9. Answers
  14. Chapter 5: Base Relvars, Base Tables
    1. Updating is set level
    2. Relational assignment
    3. More on candidate keys
    4. More on foreign keys
    5. Relvars and predicates
    6. Relations vs. types
    7. Exercises
    8. Answers
  15. Chapter 6: SQL and Relational Algebra I: The Original Operators
    1. Some preliminaries
    2. More on closure
    3. Restriction
    4. Projection
    5. Join
    6. Union, intersection, and difference
    7. Which operators are primitive?
    8. Formulating expressions one step at a time
    9. What do relational expressions mean?
    10. Evaluating SQL table expressions
    11. Expression transformation
    12. The reliance on attribute names
    13. Exercises
    14. Answers
  16. Chapter 7: SQL and Relational Algebra II: Additional Operators
    1. Exclusive union
    2. Semijoin and semidifference
    3. Extend
    4. Image relations
    5. Divide
    6. Aggregate operators
    7. Image relations revisited
    8. Summarization
    9. Summarization revisited
    10. Group, ungroup, and relation valued attributes
    11. “What if” queries
    12. A note on recursion
    13. What about ORDER BY?
    14. Exercises
    15. Answers
  17. Chapter 8: SQL and Constraints
    1. Type constraints
    2. Type constraints in SQL
    3. Database constraints
    4. Database constraints in SQL
    5. Transactions
    6. Why database constraint checking must be immediate
    7. But doesn’t some checking have to be deferred?
    8. Constraints and predicates
    9. Miscellaneous issues
    10. Exercises
    11. Answers
  18. Chapter 9: SQL and Views
    1. Views are relvars
    2. Views and predicates
    3. Retrieval operations
    4. Views and constraints
    5. Update operations
    6. What are views for?
    7. Views and snapshots
    8. Exercises
    9. Answers
  19. Chapter 10: SQL and Logic
    1. Why do we need logic?
    2. Simple and compound propositions
    3. Simple and compound predicates
    4. Quantification
    5. Relational calculus
    6. More on quantification
    7. Some equivalences
    8. Concluding remarks
    9. Exercises
    10. Answers
  20. Chapter 11: Using Logic to Formulate SQL Expressions
    1. Some transformation laws
    2. Example 1: Logical implication
    3. Example 2: Universal quantification
    4. Example 3: Implication and universal quantification
    5. Example 4: Correlated subqueries
    6. Example 5: Naming subexpressions
    7. Example 6: More on naming subexpressions
    8. Example 7: Dealing with ambiguity
    9. Example 8: Using COUNT
    10. Example 9: Another variation
    11. Example 10: UNIQUE quantification
    12. Example 11: ALL or ANY comparisons
    13. Example 12: GROUP BY and HAVING
    14. Exercises
    15. Answers
  21. Chapter 12: Miscellaneous SQL Topics
    1. SELECT *
    2. Explicit tables
    3. Dot qualification
    4. Range variables
    5. Subqueries
    6. “Possibly nondeterministic” expressions
    7. Empty sets
    8. A simplified BNF grammar
    9. Exercises
    10. Answers
  22. Appendix A: The Relational Model
    1. The relational model vs. others
    2. The significance of theory
    3. The relational model defined
    4. Database variables
    5. Objectives of the relational model
    6. Some database principles
    7. What remains to be done?
  23. Appendix B: SQL Departures from the Relational Model
  24. Appendix C: A Relational Approach to Missing Information
    1. Vertical decomposition
    2. Horizontal decomposition
    3. What do the shaded entries mean?
    4. Constraints
    5. Queries
    6. More on predicates
    7. Exercises
    8. Answers
  25. Appendix D: A Tutorial D Grammar
  26. Appendix E: Summary of Recommendations
  27. Appendix F: NoSQL and Relational Theory
    1. Functional segmentation
    2. Sharding
    3. Eventual consistency
    4. The Fernandez interview
  28. Appendix G: Suggestions for Further Reading
  29. Index
  30. Footnotes
  31. Backcover

Product information

  • Title: SQL and Relational Theory, 3rd Edition
  • Author(s):
  • Release date: November 2015
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491941171