+ All Categories
Home > Documents > Hoffer Edm Pp Ch05

Hoffer Edm Pp Ch05

Date post: 28-Jan-2016
Category:
Upload: -
View: 402 times
Download: 34 times
Share this document with a friend
Description:
Chapter 5
Popular Tags:
30
CHAPTER 5: CHAPTER 5: PHYSICAL DATABASE DESIGN AND PHYSICAL DATABASE DESIGN AND PERFORMANCE PERFORMANCE Copyright © 2014 Pearson Education, Inc. 1 Essentials of Database Management Jeffrey A. Hoffer, Heikki Topi, V. Ramesh
Transcript
Page 1: Hoffer Edm Pp Ch05

CHAPTER 5:CHAPTER 5:PHYSICAL DATABASE DESIGN AND PHYSICAL DATABASE DESIGN AND PERFORMANCEPERFORMANCE

Copyright © 2014 Pearson Education, Inc.1

Essentials of Database Management

Jeffrey A. Hoffer, Heikki Topi, V. Ramesh

Page 2: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

OBJECTIVESOBJECTIVES Define termsDefine terms Describe the physical database design Describe the physical database design

processprocess Choose storage formats for attributesChoose storage formats for attributes Select appropriate file organizationsSelect appropriate file organizations Describe three types of file organizationDescribe three types of file organization Describe indexes and their appropriate useDescribe indexes and their appropriate use Translate a database model into efficient Translate a database model into efficient

structures, and know when/how to structures, and know when/how to denormalizedenormalize

2

Page 3: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

PHYSICAL DATABASE PHYSICAL DATABASE DESIGNDESIGN

Purpose–translate the logical Purpose–translate the logical description of data into the description of data into the technical technical specificationsspecifications for storing and for storing and retrieving dataretrieving data

Goal–create a design for storing data Goal–create a design for storing data that will provide that will provide adequate adequate performanceperformance and insure and insure database database integrityintegrity, , securitysecurity, and , and recoverabilityrecoverability

3

Page 4: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

PHYSICAL DESIGN PROCESSPHYSICAL DESIGN PROCESS

4

Normalized relations

Volume estimates

Attribute definitions

Response time expectations

Data security needs

Backup/recovery needs

Integrity expectations

DBMS technology used

Inputs

Attribute data types

Physical record descriptions (doesn’t always match logical design)

File organizations

Indexes and database architectures

Query optimization

Leads to

Decisions

Page 5: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

PHYSICAL DESIGN FOR PHYSICAL DESIGN FOR REGULATORY REGULATORY COMPLIANCECOMPLIANCE

Sarbanes- Oxley Act (SOX) – protect Sarbanes- Oxley Act (SOX) – protect investors by improving accuracy and investors by improving accuracy and reliabilityreliability

Committee of Sponsoring Organizations Committee of Sponsoring Organizations (COSO) of the Treadway Commission(COSO) of the Treadway Commission

IT Infrastructure Library (ITIL)IT Infrastructure Library (ITIL) Control Objectives for Information and Control Objectives for Information and

Related Technology (COBIT)Related Technology (COBIT)

5

Regulations and standards that impact physical design decisions

Page 6: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

DESIGNING FIELDSDESIGNING FIELDS

Field: smallest unit of Field: smallest unit of application data recognized by application data recognized by system softwaresystem software

Field design Field design Choosing data typeChoosing data type Coding, compression, encryptionCoding, compression, encryption Controlling data integrityControlling data integrity

6

Page 7: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

CHOOSING DATA TYPESCHOOSING DATA TYPES

7

Page 8: Hoffer Edm Pp Ch05

8

Figure 5-1 Example of a code look-up table(Pine Valley Furniture Company)

Code saves space, but costs an additional lookup to obtain actual value

8Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 9: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

FIELD DATA INTEGRITYFIELD DATA INTEGRITY

Default value–assumed value if no Default value–assumed value if no explicit valueexplicit value

Range control–allowable value limitations Range control–allowable value limitations (constraints or validation rules)(constraints or validation rules)

Null value control–allowing or prohibiting Null value control–allowing or prohibiting empty fieldsempty fields

Referential integrity–range control (and Referential integrity–range control (and null value allowances) for foreign-key to null value allowances) for foreign-key to primary-key match-upsprimary-key match-ups

9

Sarbanes-Oxley Act (SOX) legislates importance of financial data integrity

Page 10: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

HANDLING MISSING DATAHANDLING MISSING DATA

Substitute an estimate of the missing Substitute an estimate of the missing value (e.g., using a formula)value (e.g., using a formula)

Construct a report listing missing valuesConstruct a report listing missing values In programs, ignore missing data unless In programs, ignore missing data unless

the value is significant (sensitivity testing)the value is significant (sensitivity testing)

10

Triggers can be used to perform these operations

Page 11: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

DENORMALIZATIONDENORMALIZATION Transforming Transforming normalizednormalized relations into relations into non-non-

normalizednormalized physical record specifications physical record specifications Benefits:Benefits:

Can improve performance (speed) by reducing number of Can improve performance (speed) by reducing number of table lookups (i.e. table lookups (i.e. reduce number of necessary join reduce number of necessary join queriesqueries))

Costs (due to data duplication)Costs (due to data duplication) Wasted storage spaceWasted storage space Data integrity/consistency threatsData integrity/consistency threats

Common denormalization opportunitiesCommon denormalization opportunities One-to-one relationship (Fig. 5-2)One-to-one relationship (Fig. 5-2) Many-to-many relationship with non-key attributes Many-to-many relationship with non-key attributes

(associative entity) (Fig. 5-3)(associative entity) (Fig. 5-3) Reference data (1:N relationship where 1-side has data not Reference data (1:N relationship where 1-side has data not

used in any other relationship) (Fig. 5-4)used in any other relationship) (Fig. 5-4)

11

Page 12: Hoffer Edm Pp Ch05

12

Figure 5-2 A possible denormalization situation: two entities with one-to-one relationship

12Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 13: Hoffer Edm Pp Ch05

13

Figure 5-3 A possible denormalization situation: a many-to-many relationship with nonkey attributes

Extra table access required

Null description possible

13Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 14: Hoffer Edm Pp Ch05

14

Figure 5-4A possible denormalization situation:reference data

Extra table access required

Data duplication

14Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 15: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

DENORMALIZE WITH DENORMALIZE WITH CAUTIONCAUTION

Denormalization canDenormalization can Increase chance of errors and inconsistenciesIncrease chance of errors and inconsistencies Reintroduce anomaliesReintroduce anomalies Force reprogramming when business rules Force reprogramming when business rules

changechange Perhaps other methods could be used to Perhaps other methods could be used to

improve performance of joinsimprove performance of joins Organization of tables in the database (file Organization of tables in the database (file

organization and clustering)organization and clustering) Proper query design and optimizationProper query design and optimization

15

Page 16: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

DESIGNING PHYSICAL DATABASE DESIGNING PHYSICAL DATABASE FILESFILES Physical File: Physical File:

A named portion of secondary memory allocated A named portion of secondary memory allocated for the purpose of storing physical recordsfor the purpose of storing physical records

Tablespace–named logical storage unit in which Tablespace–named logical storage unit in which data from multiple tables/views/objects can be data from multiple tables/views/objects can be storedstored

Tablespace componentsTablespace components Segment – a table, index, or partitionSegment – a table, index, or partition Extent–contiguous section of disk spaceExtent–contiguous section of disk space Data block – smallest unit of storageData block – smallest unit of storage

16

Page 17: Hoffer Edm Pp Ch05

17

Figure 5-5 DBMS terminology in an Oracle 11g environment

17Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 18: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

FILE ORGANIZATIONSFILE ORGANIZATIONS Technique for physically Technique for physically

arranging records of a file on arranging records of a file on secondary storagesecondary storage

Types of file organizationsTypes of file organizations SequentialSequential IndexedIndexed HashedHashed

18

Page 19: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

FILE ORGANIZATIONSFILE ORGANIZATIONS Factors for selecting file Factors for selecting file

organization:organization: Fast data retrieval and throughputFast data retrieval and throughput Efficient storage space utilizationEfficient storage space utilization Protection from failure and data lossProtection from failure and data loss Minimizing need for reorganizationMinimizing need for reorganization Accommodating growthAccommodating growth Security from unauthorized useSecurity from unauthorized use

19

Page 20: Hoffer Edm Pp Ch05

20

Figure 5-6a Sequential file organization

If not sortedAverage time to find desired record = n/2

Records of the file are stored in sequence by the primary key field values

If sorted – every insert or delete requires re-sort

20Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 21: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

INDEXED FILE INDEXED FILE ORGANIZATIONSORGANIZATIONS

Storage of records sequentially or Storage of records sequentially or nonsequentially with an index that allows nonsequentially with an index that allows software to locate individual recordssoftware to locate individual records

IndexIndex: a table or other data structure used to : a table or other data structure used to determine in a file the location of records that determine in a file the location of records that satisfy some conditionsatisfy some condition

Primary keys are automatically indexedPrimary keys are automatically indexed Other fields or combinations of fields can also Other fields or combinations of fields can also

be indexed; these are called secondary keys be indexed; these are called secondary keys (or nonunique keys)(or nonunique keys)

21

Page 22: Hoffer Edm Pp Ch05

22

Figure 5-6b Indexed file organization

uses a tree searchAverage time to find desired record = depth of the tree

22Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 23: Hoffer Edm Pp Ch05

23

Figure 5-6cHashed file organization

Hash algorithmUsually uses division-remainder to determine record position. Records with same position are grouped in lists.

23Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 24: Hoffer Edm Pp Ch05

24

Figure 5-7 Join Indexes–speeds up join operations

a) Join index for common non-key columns

b) Join index for matching foreign key (FK) and primary key (PK)

24Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 25: Hoffer Edm Pp Ch05

2525Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

Page 26: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

USING AND SELECTING KEYSUSING AND SELECTING KEYS

Creating a unique key index Example: CustomerID (primary key) of

Customer

Example: Composite primary key for OrderLine

Creating a secondary key index Example: Description field for Product (not

unique)

26

Page 27: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

RULES FOR USING INDEXESRULES FOR USING INDEXES

1.1. Use on larger tablesUse on larger tables2.2. Index the primary key of each tableIndex the primary key of each table3.3. Index search fields (fields frequently Index search fields (fields frequently

in WHERE clause)in WHERE clause)4.4. Fields in SQL ORDER BY and GROUP Fields in SQL ORDER BY and GROUP

BY commandsBY commands5.5. When there are >100 values but not When there are >100 values but not

when there are <30 valueswhen there are <30 values

27

Page 28: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

RULES FOR USING INDEXES RULES FOR USING INDEXES (CONT.)(CONT.)

6.6. Avoid use of indexes for fields with long Avoid use of indexes for fields with long values; perhaps compress values firstvalues; perhaps compress values first

7.7. If key to index is used to determine If key to index is used to determine location of record, use surrogate (like location of record, use surrogate (like sequence nbr) to allow even spread in sequence nbr) to allow even spread in storage areastorage area

8.8. DBMS may have limit on number of DBMS may have limit on number of indexes per table and number of bytes indexes per table and number of bytes per indexed field(s)per indexed field(s)

9.9. Be careful of indexing attributes with null Be careful of indexing attributes with null values; many DBMSs will not recognize values; many DBMSs will not recognize null values in an index searchnull values in an index search

28

Page 29: Hoffer Edm Pp Ch05

Chapter 5 Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.

QUERY OPTIMIZATIONQUERY OPTIMIZATION Parallel query processing–possible when Parallel query processing–possible when

working in multiprocessor systemsworking in multiprocessor systems

Overriding automatic query Overriding automatic query optimization–allows for query writers to optimization–allows for query writers to preempt the automated optimizationpreempt the automated optimization

Data warehouses are already configured Data warehouses are already configured for optimized query performancefor optimized query performance

29

Page 30: Hoffer Edm Pp Ch05

3030

All rights reserved. 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 otherwise, without the prior written permission of the publisher. Printed in the United States of America.

Copyright © 2014 Pearson Education, Inc.Copyright © 2014 Pearson Education, Inc.


Recommended