modern database management - gbv

17
Modern Database Management Fifth Edition FRED R. McFADDEN University of Colorado-Colorado Springs JEFFREY A- HOFFER University of Dayton MARY B. PRESCOTT University of South Florida rtüß&Üfe J 1/Dt^ An imprint of Addison Wesley Longman, Inc. Reading, Massachusetts • Menlo Park, California • New York • Harlow, England Don Mills, Ontario • Sydney • Mexico City • Madrid • Amsterdam

Upload: others

Post on 16-May-2022

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modern Database Management - GBV

Modern Database Management Fifth Edition

FRED R. McFADDEN University of Colorado-Colorado Springs

JEFFREY A- HOFFER University of Dayton

MARY B. PRESCOTT University of South Florida

rtüß&Üfe

J 1 / D t ^

An imprint of Addison Wesley Longman, Inc.

Reading, Massachusetts • Menlo Park, California • New York • Harlow, England Don Mills, Ontario • Sydney • Mexico City • Madrid • Amsterdam

Page 2: Modern Database Management - GBV

Contents

Preface xix

Part I The Context of Database Management 1

PART I OVERVIEW 2

Chapter 1 The Database Environment 3 Learning Objectives 3

In t roduct ion 3

Basic Concepts and Definitions 4

Data 4 Data versus Information 5 Metadata 5

Traditional File Processing Systems 7

File Processing Systems at Pine Valley Furniture Company 7 Disadvantages of File Processing Systems 8

Program-Data Dependence 8 Duplication of Data 9 Limited Data Sharing 9 Lengthy Development Times 9 Excessive Program Maintenance 10

The Database Approach 10

The Database Approach at Pine Valley Furniture Company 10 Enterprise Data Model 10 Relational Databases 11 Implementing the Relational Databases 13 A Database Application 14

The Range of Database Applicat ions 15 Personal Computer Databases 15 Workgroup Databases 16 Department Databases 18 Enterprise Databases 19 Summary of Database Applications 20

Advan tages of the Database Approach 20 Program-Data Independence 21 Minimal Data Redundancy 21

iii

Page 3: Modern Database Management - GBV

Improved Data Consistency 22 Improved Data Sharing 22 Increased Productivity of Application Development 22 Enforcement of Standards 22 Improved Data Quality 23 Improved Data Accessibility and Responsiveness 23 Reduced Program Maintenance 23 Cautions About Database Benefits 23

Costs and Risks of the Database Approach 24

New, Specialized Personnel 24 Installation and Management Cost and Complexity 24 Conversion Costs 25 Need for Explicit Backup and Recovery 25 Organizational Conflict 25

Componen t s of the Database Envi ronment 25

Evolution of Database Systems 27 1960s 28 1970s 28 1980s 28 1990s 29 2000 and Beyond 29

S u m m a r y 29

Chapter Review 30 Key Terms 30 Review Questions 31 Problems and Exercises 31 Field Exercises 33 References 34 Further Reading 34

Project Case: Moun ta in View C o m m u n i t y Hospi ta l 35

Database Development Process 37 Learning Objectives 37

Introduct ion 37

Database Deve lopment Within Information Systems Deve lopment 38

Information Systems Architecture 39 Information Engineering 40 Information Systems Planning 40

Identifying Strategie Planning Factors 41 Identifying Corporate Planning Objects 41 Developing an Enterprise Model 41

Database Deve lopment Process 44 Systems Development Life Cycle 45

Enterprise Modeling 46 Conceptual Data Modeling 47 Logical Database Design 47 Physical Database Design and Creation 48 Database Implementation 48 Database Maintenance 48

Page 4: Modern Database Management - GBV

Contents v

Alternative IS Development Approaches 48 The Role of CASE and a Repository 50

Manag ing the People Involved in Database Deve lopment 51

Three-Schema Architecture for Database Deve lopment 53

Three-Tiered Database Location Architecture 56

Developing a Database Appl icat ion for Pine Valley Furni ture 58

Matching User Needs to the Information Systems Architecture 59

Analyzing Database Requirements 61 Designing the Database 64 Using a Database 67 Administering a Database 69

S u m m a r y 70

Chapte r Review 71

Key Terms 71 Review Questions 71 Problems and Exercises 72 Field Exercises 75 References 75 Further Reading 76

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 77

Part II Database Analysis 83

PART II OVERVIEW 84

Chapter 3 The Entity-Relationship Model 85 Learning Objectives 85

In t roduct ion 85

The E-R Mode l 87 Sample E-R Diagram 87 E-R Model Notation 89

Enti ty-Relationship Mode l Constructs 89

Entities 89

Entity Type Versus Entity Instance 91

Entity Type Versus System Input , Ou tpu t , or User 91

Strong Versus Weak Entity Types 92 Attributes 93

Simple Versus Composite Attributes 94 Single-Valued Versus Multivalued Attributes 95 Stored Versus Derived Attributes 95

Relat ionships 97

Basic Concepts and Definitions in Relationships 98 Attributes on Relationships 99 Associative Entities 99

Degree of a Relationship 101 Unary Relationship 101

Page 5: Modern Database Management - GBV

vi Contents

Binary Relationship 104 Ternary Relationship 104

Cardinality Constraints 105 Minimum Cardinality 106 Maximum Cardinality 106 Some Examples 106 A Ternary Relationship 107

Modeling Time-Dependent Data 107 Multiple Relationships 110

E-R Mode l ing Example: Pine Valley Furn i ture C o m p a n y 111

Database Processing at Pine Valley Furni ture 114 Showing Product Information 114 Showing Customer Information 115 Showing Customer Order Status 115 Showing Product Sales 117

S u m m a r y 117

Chapter Review 118 Key Terms 118 Review Questions 119 Problems and Exercises 119 Field Exercises 124 References 124 Further Reading 125

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 126

Chapter 4 The Enhanced E-R Model and Business Ruies 129 Learning Objectives 129

Introduct ion 129

Represent ing Super types and Subtypes 130

Basic Concepts and Notation 130 An Example 131 Attribute Inheritance 133 When to Use Supertype/Subtype Relationships 133

Representing Specialization and Generalization 133 Generalization 133 Specialization 136 Combining Specialization and Generalization 137

Specifying Constraints in S u p e r t y p e / S u b t y p e Relat ionships 137

Specifying Completeness Constraints 137 Total Specialization Rule 138 Partial Specialization Rule 138

Specifying Disjointness Constraints 138 Disjoint Rule 139 Overlap Rule 139

Defining Subtype Discriminators 141 Disjoint Subtypes 141 Overlapping Subtypes 142

Defining Supertype/Subtype Hierarchies 143 An Example 143 Summary of Supertype/Subtype Hierarchies 145

Page 6: Modern Database Management - GBV

Contents vii

Business Rules: A n Overv iew 145 The Business Rules Paradigm 146 Scope of Business Rules 146 Classification of Business Rules 147

Business Rules: Defining Structural Constraints 148

Definitions 148 Facts 148 Derived Facts 149 Definitions for Data Model 150 Importance of Precise Definitions 150

Domain Constraints 153

Business Rules: Defining Opera t ional Constraints 154

Declarative Approach to Business Rules 154 Constraint Specification Language 155

Constrained Objects and Constraining Objects 155 Sample Business Rules 156

S u m m a r y 159

Chapte r Review 160 Key Terms 160 Review Questions 160 Problems and Exercises 161 Field Exercises 163 References 164 Further Reading 164

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 165

Chapter 5 Object-Oriented Modelins 167 Learning Objectives 167

In t roduct ion 167

The Unified Model ing Language 170

Object-Oriented Model ing 171 Representing Objects and Classes 171 Types of Operations 173 Representing Associations 174 Representing Association Classes 177 Representing Derived Attributes, Derived Associations, and

Derived Roles 180 Representing Generalization 181 Interpreting Inheritance and Overriding 186 Representing Multiple Inheritance 187 Representing Aggregation 187

Business Rules 191

Object Model ing Example: Pine Valley Furni ture C o m p a n y 191

S u m m a r y 194

Chapte r Review 195 Key Terms 195 Review Questions 196 Problems and Exercises 197

Page 7: Modern Database Management - GBV

Field Exercises 201 References 201

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 202

Part III Database Design 205

PART III OVERVIEW 206

Chapter 6 Logical Database Design and the Relational Model 207 Learning Objectives 207

Introduct ion 207

The Relational Data Mode l 208 Basic Definitions 208

Relational Data Structure 209 Relational Keys 209 Properties of Relations 210 Removing Multivalued Attributes from Tables 210

Example Database 211

Integrity Constraints 213 Domain Constraints 213 Entity Integrity 213 Referential Integrity 214 Operational Constraints 215 Creating Relational Tables 215 Well-Structured Relations 217

Transforming EER Diagrams into Relations 218

Step 1: Map Regulär Entities 219 Composite Attributes 219 Multivalued Attributes 220

Step 2: Map Weak Entities 221 Step 3: Map Binary Relationships 222

Map Binary One-to-Many Relationships 222 Map Binary Many-to-Many Relationships 223 Map Binary One-to-One Relationships 224

Step 4: Map Associative Entities 224 Identifier Not Assigned 224 Identifier Assigned 225

Step 5: Map Unary Relationships 227 Unary One-to-Many Relationships 227 Unary Many-to-Many Relationships 228

Step 6: Map Ternary (and w-ary) Relationships 229 Step 7: Map Supertype/Subtype Relationships 231

Int roduct ion to Normal iza t ion 232 Steps in Normalization 233 Functional Dependencies and Keys 235

Determinants 235 Candidate Keys 235

The Basic N o r m a l Forms 237 First Normal Form 237 Second Normal Form 237

Page 8: Modern Database Management - GBV

Contents ix

Third Normal Form 238 Normalizing Summary Data 241

Merging Relations 241 An Example 241 View Integration Problems 241

Synonyms 242 Homonyms 242 Transitive Dependencies 242 Supertype/Subtype Relationships 243

S u m m a r y 243

Chapte r Review 244 Key Terms 244 Review Questions 244 Problems and Exercises 245 Field Exercises 249 References 250 Further Reading 250

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 251

Chapter 7 Physical Database Design 253 Learning Objectives 253

Introduct ion 253

Physical Database Design Process 254

Data Volume and Usage Analysis 255

Designing Fields 257

Choosing Data Types 257 Coding and Compression Techniques 257

Controlling Data Integrity 259 Handling Missing Data 260

Designing Physical Records and Denormal iza t ion 260 Handling Fixed-Length Fields 261 Handling Variable-Length Fields 261 Denormalization 261

Designing Physical Files 267 Pointer 267 Access Methods 267 File Organizations 268

Sequential File Organizations 268 Indexed File Organizations 268 Hashed File Organizations 272

Summary of File Organizations 272 Clustering Files 272 Designing Controls for Files 274

Using and Selecting Indexes 274 Creating a Primary Key Index 274 Creating a Secondary Key Index 275 When to Use Indexes 275

RAID: Improv ing File Access Performance by Parallel Processing 276

Page 9: Modern Database Management - GBV

Choosing Among RAID Levels 278 RAID-0 278 RAID-1 278 RAID-2 281 RAID-3 281 RAID-4 281 RAID-5 281

RAID Performance 281 Designing Databases 282

Choosing Database Architectures 282

Optimizing for Query Performance 285

Summary 286

Chapter Review 288 Key Terms 288 Review Questions 288 Problems and Exercises 289 Field Exercises 291 References 292 Further Reading 292

Project Case: Mountain View Community Hospital 293

Part IV Implementation 295

PART IV OVERVIEW 296

Chapter 8 Client/Server and Middleware 297 Learning Objectives 297

Introduction 297

Client/Server Architectures 298 File Server Architectures 299 Limitations of File Servers 300 Database Server Architectures 301

Three-Tier Architectures 302

Partitioning an Application 304

Role of the Mainframe 305

Using Parallel Computer Architectures 306 Multiprocessor Hardware Architectures 307 Business Related Uses of SMP and MPP Architectures 308

Using Middleware 309

Establishing Client/Server Security 311

Client/Server Issues 312

Summary 314

Chapter Review 315 Key Terms 315 Review Questions 316 Problems and Exercises 316

Page 10: Modern Database Management - GBV

Field Exercises 317 References 318

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 319

Chapter 9 SQL 323 Learning Objectives 323

In t roduct ion 323

His tory of the SQL Standard 324

The Role of SQL in a Database Architecture 325

The SQL Envi ronment 327

Defining a Database in SQL 331

Generating SQL Database Definitions 332 Creating Tables 332 Creating Data Integrity Controls 334 Changing Table Definitions 336 Removing Tables 336 Establishing Synonyms 336

Insert ing, Upda t ing , and Deleting Data 337 Batch Input 337 Deleting Database Contents 338 Changing Database Contents 338

Internal Schema Definition in RDBMSs 338

Creating Indexes 339

Processing Single Tables 340

Clauses of the SELECT Statement 340 Using Expressions 342 Using Functions 343 Using Wildcards 345 Comparison Operators 345 Using Boolean Operators 346 Ranges 347 Distinct 348 IN and NOT IN Lists 350 Sorting Results: The ORDER BY Clause 350 Categorizing Results: The GROUP BY Clause 351 Qualifying Results by Categories: The HAVING Clause 352

Processing Mult ip le Tables 354 Equi-join 354 Natural Join 355 Outer Join 356 Subqueries 358 Correlated Subqueries 361

View Definitions 363

Ensur ing Transaction Integri ty 366

Data Dict ionary Facilities 368

Triggers a n d Procedures 369

SQL3 371

Page 11: Modern Database Management - GBV

xii Contents

S u m m a r y 372

Chapter Review 373 Key Terms 373 Review Questions 373 Problems and Exercises 374 Field Exercises 377 References 378 Web Site References 378 Further Reading 379

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 380

Chapter 10 Database Access from Client Applications 381 Learning Objectives 381

Introduct ion 381

Survey of Desktop Database Technology 382

Using Query-by-Example 383 The History and Importance of QBE 384 QBE: The Basics 384 Database Definition 386 Relationships 387 Building Queries Using QBE 388 Single-Table Queries 388 Selecting Qualified Records 390 Multiple-Table Queries 390 Self-Join 392 Basing a Query on Another Query 393 Access97 Query Types 394

Building a Client Appl icat ion 396 Application Menüs 396 Form Development 397 Report Development 399

Using OLE, COM, and ActiveX Controls for Database Access 401

Embedd ing SQL in Programs 403

Using Visual Basic for Appl icat ions (VBA) in Client Applicat ions 406

Building Internet Database Servers 407

S u m m a r y 409

Chapter Review 410 Key Terms 410 Review Questions 410 Problems and Exercises 411 Field Exercises 413 References 414

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 415

Chapter 11 Distributed Databases 417 Learning Objectives 417

Page 12: Modern Database Management - GBV

Contents xiii

In t roduct ion 417

Objectives and Trade-offs 421

Opt ions for Distr ibut ing a Database 422

Data Replication 423 Snapshot Replication 424 Near Real-Time Replication 425 Pull Replication 425 Database Integrity with Replication 425 When to Use Replication 426

Horizontal Partitioning 426 Vertical Partitioning 427 Combinations of Operations 429 Selecting the Right Data Distribution Strategy 430

Dis t r ibuted DBMS 431

Location Transparency 433 Replication Transparency 434 Failure Transparency 435 Commit Protocol 435 Concurrency Transparency 436

Timestamping 437 Query Optimization 437 Evolution of Distributed DBMS 440

Remote Unit of Work 440 Distributed Unit of Work 441 Distributed Request 441

Distr ibuted DBMS Products 442 IBM Corporation and DB2 442 Sybase Inc. 443 Oracle Corporation 444 Computer Associates International and Ingres 444 Microsoft Corporation and SQL Server 445

S u m m a r y 445

Chapte r Review 447 Key Terms 447 Review Questions 447 Problems and Exercises 448 Field Exercises 450 References 451

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 452

Chapter 12 Object-Oriented Database Development 453 Learning Objectives 453

Int roduct ion 453

Object Definition Language 454 Defining a Class 454 Defining an Attribute 455 Defining User Structures 456 Defining Operations 456 Defining a Range for an Attribute 457 Defining Relationships 457 Defining an Attribute with an Object Identifier as Its Value 459

Page 13: Modern Database Management - GBV

Defining Many-to-Many Relationships, Keys, and Multivalued Attributes 460

Defining Generalization 462 Defining an Abstract Class 464 Defining Other User Structures 464

OODB Design for Pine Valley Furni ture C o m p a n y 466

Creat ing Object Instances 467

Object Query Language 468 Basic Retrieval Command 469 Including Operations in Select Clause 469 Finding Distinct Values 470 Querying Multiple Classes 470 Writing Subqueries 471 Calculating Summary Values 471 Calculating Group Summary Values 472

Qualifying Groups 472 Using a Set in a Query 473

Current ODBMS Products and Their Appl icat ions 474

S u m m a r y 474

Chapter Review 475 Key Terms 475 Review Questions 476 Problems and Exercises 476 Field Exercises 477 References 478

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 479

Part V Data Administration 481

PART V OVERVIEW 482

Chapter 13 Data and Database Administration 483 Learning Objectives 483

Introduct ion 483

The Changing Roles of Data and Database Adminis t rators 484

Data Administration 484 Database Administration 485 Changing Approaches to Data Administration 488

Model ing Enterprise Data 490

P lanning for Databases 491

Manag ing Data Security 492 Threats to Data Security 492 Views 494 Authorization Rules 495 User-Defined Procedures 497 Encryption 497 Authentication Scheines 497

Page 14: Modern Database Management - GBV

Contents XV

Backing U p Databases 498

Basic Recovery Facilities 499 Backup Facilities 499 Journalizing Facilities 499 Checkpoint Facility 500 Recovery Manager 500

Recovery and Restart Procedures 500 Switch 501 Restore/Rerun 501 Transaction Integrity 501 Backward Recovery 502 Forward Recovery 503

Types of Database Failure 503 Aborted Transactions 503 Incorrect Data 504 System Failure 504 Database Destruction 505

Control l ing Concurren t Access 505 The Problem of Lost Updates 505 Serializability 506 Locking Mechanisms 507

Locking Level 507 Types of Locks 508 Deadlock 508 Managing Deadlock 510

Versioning 510

Manag ing Data Qual i ty 511

Security Policy and Disaster Recovery 512 Personnel Controls 513 Physical Access Controls 513 Maintenance Controls 514 Data Protection and Privacy 514

Data Dictionaries and Repositories 514

Repositories 515

Overv iew of Tuning the Database for Performance 516

Installation of the DBMS 517 Memory Usage 517 Input/Output (I/O) Contention 518 CPU Usage 518 Application Tuning 518

S u m m a r y 519

Chapte r Review 520 Key Terms 520 Review Questions 520 Problems and Exercises 522 Field Exercises 525 References 525

Project Case : Moun ta in View C o m m u n i t y Hospi ta l 527

Chapter 14 Data Warehouse 529 Learning Objectives 529

Page 15: Modern Database Management - GBV

Introduct ion 529

Basic Concepts of Data Warehous ing 531 A Brief History 531 The Need for Data Warehousing 532

Need for a Company-Wide View 532 Need to Separate Operational and Information

Systems 533

Data Warehouse Architectures 534 Generic Two-Level Architecture 534 An Expanded Data Warehouse Architecture 534 Three-Layer Data Architecture 537

Role of the Enterprise Data Model 537 Role of Metadata 537

Some Data Characteristics 538 Status versus Event Data 538 Transient versus Periodic Data 539 An Example of Transient and Periodic Data 540

Transient Data 541 Periodic Data 542

The Reconciled Data Layer 542

Characteristics of Reconciled Data 543 The Data Reconciliation Process 543

Capture 544 Scrub 544 Load and Index 545

Data Transformation 546

Data Transformation Functions 547 Record-Level Functions 547 Field-Level Functions 548 More Complex Transformations 550

Tools to Support Data Reconciliation 550 Data Quality Tools 550 Data Conversion Tools 550 Data-Cleansing Tools 550

The Derived Data Layer 551

Characteristics of Derived Data 551 The Star Schema 552

Fact Tables and Dimension Tables 552 Example Star Schema 552 Grain of a Fact Table 554 Size of the Fact Table 554

Variations of the Star Schema 556 Multiple Fact Tables 556 Snowflake Schema 556 Proprietary Databases 557

Independent versus Dependent Data Marts 558

The User Interface 559

Role of Metadata 559 On-Line Analytical Processing (OLAP) Tools 560

Slicing a Cube 561 Drill-Down 561

Page 16: Modern Database Management - GBV

Contents xvii

Data-Mining Tools 562 Data-Mining Techniques 562 Data-Mining Applications 562

Data Visualization 563

Summary 563

Chapter Review 565 Key Terms 565 Review Questions 565 Problems and Exercises 566 Field Exercises 568 References 568 Further Reading 569

Project Case: Mountain View Community Hospital 570

Appendix A Object-Relational Databases 573 Basic Concepts and Definitions 573

Features of an ORDBMS 574 Complex Data Types 574

Enhanced SQL 575 A Simple Example 575 Content Addressing 576

Advantages of the Object-Relational Approach 576

ORDBMS Vendors and Products 577

References 577

Appendix B Advanced Normal Forms 579 Boyce-Codd Normal Form 579

Anomalies in STUDENT_ADVISOR 579 Definition of Boyce-Codd Normal Form (BCNF) 580 Converting a Relation to BCNF 580

Fourth Normal Form 582

Multivalued Dependencies 583

Higher Normal Forms 584

References 584

Appendix C Data Structures 585 Pointers 585

Data Structure Building Blocks 587

Linear Data Structures 589 Stacks 590 Queues 590 Sorted Lists 591 Multilists 593

Hazards of Chain Structures 594

Trees 594 Balanced Trees 595

References 598

Page 17: Modern Database Management - GBV

xviii Contents

Glossary of Terms 599

Glossary of Acronyms 611

Index 613