You are on page 1of 1034
An Introductio Database Systems + Part T (four chapters) provides a broad introduction to the concepts of database systems in general and relational systems in particular. It also introduces the standard database language. SQL. + Part IT (six chapters) consists of a detailed and very careful description of the relational model. which is not only the theoretical foundation underlying rela- tional systems but is. in fact. the theoretical foundation for the entire database field. : + Part IIT (four chapters) discusses the general question of database design. Three chapters are devoted to design theory. and the fourth considers semantic model- ing and the entity/relationship model. + Part IV (qwo chapters? is concemed with transaction management (i.e.. recovery and concurrency controls). - = Part V (cight chapters) shows how relational concepts are relevant to a variety of further aspects of database technology—security. distributed databases, temporal data, decision support, and so on. + Part VI (three chapters) describes the impact of object technology on database systems. Chapter 25 describes object systems specifically: Chapter 26 considers the possibility of a rapprochement between object and relational technologies and discusses objec/elational systems: and Chapter 27 addresses the relevance (0 databases of XML. About the Author C.J. DATE is an author. lecturer. sesearcher. and independent consultant specializing in relational database systems, An active member of the database community for nearly 35 years. C. J. Date devotes the major part of his career to exploring, expanding. ‘and expounding the theory and practice of relational technology. He enjoys a reputation second to none for his ability 10 explain ‘complex technical material in a clear and understandable fashion. “{C. J. Date"s} book is the flag bearer of relational theory and mathematical treat- tment in general.,.as well as the runaway leader in discussing the SQL standards. Ik exercises much more respect for careful language and the importance of con- ‘cepts and principles in gaining mastery of the fiel —Car Ecker, San Diego State University [The] 8th Edition is an excellent and comprehensive presentation of the contem- porary database field: In particular, Date's chapters on types. relations. object databases, and object-relational databases together provide an exceptionally clear. self-contained exposition of the object-relational approach to databases.” Martin K, SOLOMON, Florida Atlantic University “Chris Date is the computer industry's most respected expert and thinker on data- base technology. and his book Am Introduction to Database Systems continues to be the definitive work for those wanting a compreliensive and current guide to —COLIN J. WatTE, President, Intelligent Business Strategies ~ “This is the best explanation of concurrency that { have seen in literature. and it covers the ground quite thoroughly.” —BRUCE,O. LARSEN. Stevens Institute of Technology both an indispensable read and an indispensable reference. No serious informa- tion systems or database practitioner should be without this book.” —DectaN Braby. MICS, Srstems Architect and Database Specialist. Fujitsu “The author's deep insights into the area. informal treatment of profound topics. open-ended discussions of critical issues, comprehensive and up-to-date contents. a$ well as rich annotations on bibliography have made the book most popular in the database area for more than two decades.” QUANG ZHU, The University of Michigan, Dearborn “{The book's] appeal is its comprehensiveness and the tact that itis very up-to- date with research developments, The latter factor is due mainly to (Date's} in- volvement with these developments, which gives him a unique opportunity t0 write about them.” | —Davip Livincstone. University of Northumbria at Newcastle Senior Acquisitions Editor: Maite Suarez-Rivas* Project Editor: Katherine Harutunian pee Marketing Manager: Nathan Schultz : Production Supervisor: Mariya Lioyd \ Project Management: Elisabeth Beller Composition: Nancy Loran Technical Art: Dartmouth Publishing, Inc. Copyeditor: Daril Bentley Proofreader: Jennifer McClain Design Manager: Soyee Cosentino Wells Cover Design: Night & Day Design Cover Image: Lindy Date Prepress and Manufacturing: Caroline Fell ‘Access the latest information about Addison-Wesley titles from our World Wide Web site: Inpsthownanaconfes " ‘Many ofthe designations used by manufacturers and sellers to distinguish their products are claimed as trademarks, Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed in intial caps or all caps. ‘The programs and applications presented inthis book have-been included for their instructional value. They have been tested with care but are not guaranteed for any purpose. The gublisher does not offer any warranties or representations, nor does it accept any liabilities with respect tothe programs or applications. {you purchased this book within the United States or Canada you should be aware that it has been ‘wrongfully imported without the approval ofthe Publisher or the Author. Copyright © 2004 by Pearson Education, Inc. - All sights reseeved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or other- wise, without the prior written permission ofthe publisher. Printed in the United States of America. ISBN 0-321-18956-6 23456789 10-HAM-06050403 - This book is dedicated to my wife Lindy and to the memory of my mother Rene— also to the memory of Ted Codd, who, sadly, passed away as this book was going to press ‘Those who cannot remember the past are condemned to repeat it Usually quoted in the form: ‘Those who don’t know history are doomed to repeat it George Santayana I would like to see computer science teaching set deliberately in a historical framework. .. Students need to understand hhow the present situation has come about, what was tried, what worked and what did not, and how improvements in hardware made progress possible. The absence of this element in their training causes people to approach every problem from first principles. They are apt to propose solutions that have been found wanting in the past. Instead of standing ‘on the shoulders of their precursors, they try to go it alone, Maurice V. Wilkes a a te C. J. Date is an independent author, lecturer, researcher, and consultant, specializing in relational database technology. He is based in Healdsburg, California, In 1967, following several years as a mathematical programmer and programming instructor for Leo Computers Lid. (London, England), Mr. Date moved to the IBM (UK) Development Laboratories, where he worked on the integration of database functionality into PL/L In 1974 he transferred to the IBM Systems Development Center in California, where he was responsible for the design of a database language known as the Unified Database Language, UDL, and worked On technical planning and externals design for the IBM products SQUDS and DB2. He left IBM in May, 1983. Me. Date has been active in the database field for well over 30 years. He was one of # the first people anywhere to recognize the significance of Codd’s pioneering work on the relational model. He has lectured widely on tectinical subjects—principally on database topics. and especially on relational datsbase—thnughaot Noch Ar Europe, Australia, Latin America, and the Far East. In addition to the present book, he is author of coauthor of a number of other database texts, including, from Morgan Kauf- mann. Temporal Data and the Relational Model (2003) and, from Addison-Wesley, Fou- dation for Future Database Systems: The Third Manifesto (2nd edition. 2000), a detailed proposal for the furure direction of the field: Database: A Primer (1983), which treats database systems from the nonspecialist's point of view; a series of Relational Database Writings books (1986, 1990, 1992,, 1995, 1998), which deal with various aspects of rela- tional technology in depth: and another series of books on specific systems and lan- guages—A Guide 10 DB2 (4th edition, 1993), A Guide to SYBASE and SQL Seiver (1992), A Guide 10 SQL/DS (1988), A Guide to INGRES (1987), and A Guide to the SQL Sia- dard (4th edition, 1997). His books have been translated into several languages, including Braille, Chinese, Dutch, French, Geman, Greek, Italian, Japanese, Korean, Polish, Portu- quese, Russian, and Spanish. = * Mr. Date has also produced over 300 technical articles and research papers and has made a variety of original contributions to database theory. For several years, be was a regular columnist for the magazine Database Programming & Design. He also contrib- utes regularly to the website Atip://dbdebunk.com. His professional seminars on database technology, offered both in North Ainerica and overseas, are widely considered to be sec- ‘ond to none for the quality of the subject matter and the clarity of the exposition. Ms, Date holds an Honours Degree in Mathematics from Cambridge University, England (BA. 1962, MA 1966) and the hovorary degree of Doctor of Technology from De Montfort University, England (1994). 9 and alen in Me seapey Chapter 1 uw 12 13 14 15 16 7 Chapter2 24 22 24 25 26 27 28 29 210 241 27 243 Preface to the Eighth Edition xxi PARTI ‘PRELIMINARIES 1 ‘An Overview of Database Management 3 Introduction ~ What Isa Database System? 6 What Isa Database? 11 - Why Database? 16 \ Data Independence 20 Relational Systems and Others 26 Summary 28 Exercises 29 References and Bibliography 31 Database System Architecture 33 wee Introduction 33 . The Three Levels of the Architecture uM The External Level: © 37 The Conceptual Level _ 39 The Internal Level 40 Mappings 41 The Database Administrator 42 The Database Management System 44 Data Communications 48 Client/Server Architecture 49 Utilities = Si Diatrihuted Processing 51 Summary 55 Exercises 56 References and Bibliography 56 x Chapter3 An Introduction to Relational Databases 59 34 Introduction 59 3.2 An Informal Look at the Relational Model 60 3.3 Kelations and Kelvars cd . 34 WhatRelations Mean 66 35 Optimization 69 3.6 TheCatalog 71 37 Base Relvarsand Views 72 3.8 Transactions 76 3.9 The Suppliers-and-Parts Database 77 3.10 Summary 79 Exercises 81 References and Bibliography 81 Chapter4 An Introduction toSQL 85 4.1 Introduction 85 42 Overview 86 43° The Catalog © “89 44 Views 90 45° Transactions 91 46 EmbeddedSQL 91 47 DynamicSQLand SQL/CLI 97 418 SQLIsNot Perfect 100 ¥ 49° Summary 101 Exercises 102 References and Bibliography 104 PARTI THE RELATIONAL MODEL 109 ChapterS TYPES 111 5.1 Introduction 111 52 Valuesvs. Variables 112 53 Types 0s. Representations 115 24 Type Definition 119 v5 Operators 122 - 56 TypeGenerators 127 5.7 SQL Facilities 128 58 Summary 136 Exercises 137 References and Bibliography 139 Chapter 6 61 62 63 6.4 65 66 67 ” Chapter 7 71 72 73 74 76 27 79 7.10 Chapter 8 81 83 84 85 86 a7 88 89 Relations 14 Introduction 141 .Tuples 141 Relation Types 146 Relation Values 148 Relation Variables 156 SQL Facilities 161 Summary 167 Exercises: 168 References and Bibliography 170 Relational Algebra. 173 Introduction 173 Closure Revisited 175 The Original Algebra: Syntax _ What Is the’Algebra For? 192 Further Points 194 Additional Operators 195 Grouping and Ungrouping 203 Summary 206 Exercises 207 References and Bibliography 209 Relational Calculus 213 Introduction 213, Tuple Calculus 215 Examples 223 Calculus vs. Algebra 225 230 ‘Exercises 246 References and Bibliography . 250 Chapter 11 ma n2 ns m4 us Integrity 253 Introduction 253, ACloser Look 255 Predicates and Propositions 258 Relvar Predicates and Database Predicates 259 Checking the Constraints 260 Internal vs, External Predicates 261 Correctness vs. Consistency 263 Integrity and Views 265 AConstraint Classification Scheme 266 Keys 268 . ‘Triggers (a Digression) 277 SQL Facilities 279 Summary 284 Exercises - 285 References and Bibliography 288 Views 295, Introduction 295 What Are Views For? 298 View Retrievals 302 View Updates 303 Snapshots (a Digression) 318 SQL Facilities " 320 Summary 323 Exercises 324 References and Bibliography 325 PART IIIT DATABASE DESIGN Functional Dependencies 333 Introduction 333. Basic Definitions 334 ‘Trivial and Nontrivial Dependencies 337 Closure ofa Set of Dependencies 338 Closure ofa Set of Attributes 339 329 116 117 121 122 123 124 125 126 127 13.1 132 133 13.4 BS 136 137 BS Chapter 14 141 14.2 143 144 1465 146 147 Irreducible Sets of Dependencies 341 Summary 343 Exercises: 344 References and Bibliography 345 Further Normalization I: INE 2NE3NEBCNF 349 Introduction 349 Nonloss Decomposit First, Second, and Third Normal Forms Dependency Preservation 364 Boyce/Codd Normal Form 367 A Note on Relation-Valued Attributes Summary 375 Exercises 376 : References and Bibliography. ~ 378 357 373 Further Normalization II: Higher Normal Forms Introduction 381 Multi-valued Depen Join Dependencies and Fifth Normal Form 386 ‘The Normalization Procedure Summarized ANote on Denormalization 393 Orthogonal Design (a Digression) 395 Other Normal Forms 398 Summary 400 Exercises 401 References and Bibliography Semantic Modeling ° 409 Introduction 409 ‘The Overall Approach ; 411 TheE/RModel 414 E/RDiagrams 418 402 Database Design with the E/R Model ABriefAnalysis 424 Summary 428 Exercises 429 References and Bibliography 430 420 391 ion and Functional Dependencies 381 \dencies and Fourth Normal Form 353 382 xiv Contents Chapter 15 15.1 15.2 153 15.4 1535 15.6 187 158 15.9 Chapter 16 16.1 162 163 164 16S 166 167 168 169 16.10 16.11 16.12 chapter 17 Wt W2 PARTIV TRANSACTION MANAGEMENT Recovery 445 Introduction 445, Transactions 446 ‘Transaction Recovery 450 System Recovery 453 Media Recovery 455 ‘Two-Phase Commit 456 Savepoints (a Digression) 457 SQLFacilities "458 Summary 459 Exercises 460 References and Bibliography 460 Concurrency 465 Introduction 465 Three Concurrency Problems 466 Locking 470 ‘The Three Concurrency Problems Revisited 472 Deadlock 474 arjalizability 476 Recovery Revisited 478 Isolation Levels 480 Intent Locking 483 Dropping ACID 485 SQL Facilities 490 Summary 491 Exercises 492 References and Bibliography 494 PART V FURTHER TOPICS 501 Security 503 Introduction 503 Discretionary Access Control 506 443 73 Wa 175 176 7 Chapter 18 18.1 182 183 18.4 185 186 18.7 188 Chapter 19 19.1 192 193 194 195 196 19.7 198 Chapter 28 20.1 202 203 204 205 20.6 ‘Mandatory Access Control Statistical Databases 513 DataEncyption 519 SQL Facilities 523 sit Summary 527 Exercises 528 References and Bibliography 529 Optimization 531 Introduction 531 AMotivating Example 533 ‘An Overview of Query Processing Expression Transformation... 539 Database Statistics 544 534 ADivide-and-Conquer Strategy 545 Implementing the Relational Operators Missing Information 575 Introduction 575 ‘An Overview of the 3VL Approach ‘Some Consequences of the Foregoing Scheme Nullsand Keys 586 Outer Join (a Digression) 589 Special Values 591 SQL Facilities 592 Summary 597 Exercises 598 References and Bibliography Type Inheritance 605: Introduction 605 Type Hierarchies 610 600 Polymorphism and Substitutability Variables and Assignments Specialization by Constraint Comparisons 623 617 621 37 613, 548 582 Contents wi Contents . 27 * 20.8 20.9 20.10 20.11 Chapter 21 24 212 23 214 2s 21.6 217 218 Chapter 22 2a 22 24 25 226 27 28 29 Chapter 23 231 23.2 233 23.4 23.5 23.6 Operators, Versions, and Signatures 626 IsaCirclean Ellipse? 630 . Specialization by Constraint Revisited 634 SQLFacilities "636 Summary 641 Exercises 642 References and Bibliography 644 Distributed Databases 647 Introduction 647, Some Preliminaries 648 The Twelve Objectives 652 Problems of Distributed Systems 660 Client/Server Systems "671 DBMS independence 674 SQL Facilities 679 Summary 680 Exercises 681 References and Bibliography 682 Decision Support 689 Introduction 689 Aspects of Decision Support 691 Database Design for Decision Support 693 Data Preparation 701 Data Warehouses and Data Marts 704 Online Analytical Processing 709 DataMining 717 SQLFacilities 719 Summary 720 Exercises 721 References and Bibliography 722 Temporal Databases 727 Introduction 727 * ‘What Is the Problem? 732 Intervals 737 Packing and Unpacking Relations 743 Generalizing the Relational Operators 754 Database Design 758 237 23.8 Chapter 24 24.1 24.2 24.3 24.4 245 246 24.7 24.8 Chapter 25 251 252 33 24 235 26 Chapter 26 26.1 262 26.3 64 265 26.6 26.7 Contents xvii Integrity Constraints 764 Summary 770 Exercises 71 References and Bibliography 772 Logie-Based Databases 775 Introduction 775 Overview 776 Propositional Calculus 778 Predicate Calculus 783 AProof-Theoretic View of Databases 789 Deductive Database Systems, :, 793 Recursive Query Processing’... 798 Summary 803 * Exercises 806 . References and Bibliography: ~ wus; PART VI OBJECTS, RELATIONS, AND XML "811 ” Object Databases 813 Introduction 813 Objects, Classes, Methods, and Messages 817 F ACloser Look 822 _ ACradle-to-Grave Example 830+ Miscellaneous Issues 840 - Summary 847 . : Exercises 850 References and Bibliography 851 Object/Relational Databases 859 Introduction 859 ‘The First Great Blunder 862 The Second Great Blunder 870 Implementation Issues 874 Benefits of True Rapprochement 876 SQLFacilities 878 Summary 885 Exercises ‘885 References and Bibliography 886 xviii Contents ‘Chapter 27 274 272 273 274 275 27.6 277 278 The World Wide Web and XML 895 Introduction 895 ‘The Web and the Internet 896 An Overview of XML 897 XML Data Definition 908 XML Data Manipulation 917 XML and Databases 925 SQL Facilities 928 Summary 932 Exercises 934 . References and Bibliography 935 APPENDIXES 939 Appendix A The TransRelational™ Model 941. Al A2 AS AA AS ASG Az Introduction - 941 Three Levels of Abstraction . 943 The Basicldea 946 Condensed Columns 952 Merged Columns 956 Implementing the Relational Operators 960 Summary 966 References and Bibliography 966 \ppendixB SQLExpressions 967 BA B2 B3 Introduction 967 Table Expressions 968 Boolean Expressions 973 \ppendix C Abbreviations, Acronyms, and Symbols 977

You might also like