Database Systems The Complete Book
Database Systems The Complete Book
Hector Garcia-Molina
Jeffrey D. UHman
Jennifer Widom
PEARSON
Prentice
Hall
xiii
xiv TABLE OF CONTENTS
7 C o n s t r a i n t s a n d Triggers 311
7.1 Keys and Foreign Keys 311
7.1.1 Declaring Foreign-Key Constraints 312
7.1.2 Maintaining Referential Integrity 313
7.1.3 Deferred Checking of Constraints 315
7.1.4 Exercises for Section 7.1 318
7.2 Constraints on Attributes and Tuples 319
XX TABLE OF CONTENTS
15 Q u e r y Execution 701
15.1 Introduction to Physical-Query-Plan Operators 703
15.1.1 Scanning Tables 703
15.1.2 Sorting While Scanning Tables 704
15.1.3 The Computation Model for Physical Operators 704
15.1.4 Parameters for Measuring Costs 705
15.1.5 I/O Cost for Scan Operators 706
15.1.6 Iterators for Implementation of Physical Operators . . . . 707
15.2 One-Pass Algorithms 709
TABLE OF CONTENTS
16 T h e Q u e r y Compiler 759
16.1 Parsing and Preprocessing 760
16.1.1 Syntax Analysis and Parse Trees 760
16.1.2 A Grammar for a Simple Subset of SQL 761
16.1.3 The Preprocessor 764
16.1.4 Preprocessing Queries Involving Views 765
16.1.5 Exercises for Section 16.1 767
16.2 Algebraic Laws for Improving Query Plans 768
16.2.1 Commutative and Associative Laws 768
16.2.2 Laws Involving Selection 770
16.2.3 Pushing Selections 772
16.2.4 Laws Involving Projection 774
16.2.5 Laws About Joins and Products 776
16.2.6 Laws Involving Duplicate Elimination 777
16.2.7 Laws Involving Grouping and Aggregation 777
16.2.8 Exercises for Section 16.2 780
16.3 From Parse Trees to Logical Query Plans 781
16.3.1 Conversion to Relational Algebra 782
16.3.2 Removing Subqueries From Conditions 783
16.3.3 Improving the Logical Query Plan 788
16.3.4 Grouping Associative/Commutative Operators 790
16.3.5 Exercises for Section 16.3 791
16.4 Estimating the Cost of Operations 792
16.4.1 Estimating Sizes of Intermediate Relations 793
16.4.2 Estimating the Size of a Projection 794
16.4.3 Estimating the Size of a Selection 794
16.4.4 Estimating the Size of a Join 797
16.4.5 Natural Joins With Multiple Join Attributes 799
16.4.6 Joins of Many Relations 800
16.4.7 Estimating Sizes for Other Operations 801
16.4.8 Exercises for Section 16.4 802
16.5 Introduction to Cost-Based Plan Selection 803
16.5.1 Obtaining Estimates for Size Parameters 804
16.5.2 Computation of Statistics 807
16.5.3 Heuristics for Reducing the Cost of Logical Query Plans . 808
16.5.4 Approaches to Enumerating Physical Plans 810
16.5.5 Exercises for Section 16.5 813
16.6 Choosing an Order for Joins 814
xxx TABLE OF CONTENTS
Index 1183