objectives physical database design physical design process

OBJECTIVES
CHAPTER 5:
PHYSICAL DATABASE DESIGN AND
PERFORMANCE
Define terms
!  Describe the physical database design process
!  Choose storage formats for attributes
!  Select appropriate file organizations
!  Describe three types of file organization
!  Describe indexes and their appropriate use
!  Translate a database model into efficient
structures
!  Know when and how to use denormalization
! 
Modern Database Management
11th Edition
Jef frey A. Hof fer, V. Ramesh,
Heikki Topi
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
1
PHYSICAL DATABASE DESIGN
Chapter 5
Inputs
the logical description
of data into the technical specifications
for storing and retrieving data
!  Goal–create a design for storing data that
will provide adequate performance and
ensure database integrity, security, and
recoverability
! Normalized
! Volume
Decisions
relations
! Attribute
estimates
! Attribute
record descriptions
(doesnt always match
logical design)
definitions
time
expectations
! Data
security needs
! Backup/recovery
! Integrity
3
needs
expectations
data types
! Physical
! Response
! DBMS
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
2
PHYSICAL DESIGN PROCESS
!  Purpose–translate
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
Leads to
! File
organizations
! Indexes
and database
architectures
! Query
optimization
technology used
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
4
Figure 5-1 Composite usage map
(Pine Valley Furniture Company)
PHYSICAL DESIGN FOR
REGULATORY COMPLIANCE
!  Sarbanes-
Oxley Act (SOX) – protect investors by
improving accuracy and reliability
!  Committee of Sponsoring Organizations (COSO)
of the Treadway Commission
!  IT Infrastructure Library (ITIL)
!  Control Objectives for Information and Related
Technology (COBIT)
Regulations and standards that impact physical design decisions
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
5
Chapter 5
Figure 5-1 Composite usage map
(Pine Valley Furniture Company) (cont.)
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
6
Figure 5-1 Composite usage map
(Pine Valley Furniture Company) (cont.)
Access Frequencies
(per hour)
Data volumes
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
7
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
8
8
Figure 5-1 Composite usage map
(Pine Valley Furniture Company) (cont.)
Figure 5-1 Composite usage map
(Pine Valley Furniture Company) (cont.)
Usage analysis:
Usage analysis:
7500 suppliers accessed per
hour "
4000 quotations accessed
from these 7500 supplier
accesses "
4000 purchased parts accessed
from these 4000 quotation
accesses
14,000 purchased parts
accessed per hour "
8000 quotations accessed
from these 140 purchased part
accesses "
7000 suppliers accessed from
these 8000 quotation accesses
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
9
DESIGNING FIELDS
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
10
CHOOSING DATA TYPES
! Field:
smallest unit of application
data recognized by system software
! Field design
" Choosing
data type
" Coding, compression, encryption
" Controlling data integrity
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
11
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
12
FIELD DATA INTEGRITY
Figure 5-2 Example of a code look-up table
(Pine Valley Furniture Company)
! 
! 
! 
! 
Code saves space, but costs
an additional lookup to
obtain actual value
Default value–assumed value if no explicit
value
Range control–allowable value limitations
(constraints or validation rules)
Null value control–allowing or prohibiting
empty fields
Referential integrity–range control (and null
value allowances) for foreign-key to
primary-key match-ups
Sarbanes-Oxley Act (SOX) legislates importance of financial data integrity
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
13
HANDLING MISSING DATA
14
! Transforming normalized relations into non-normalized
physical record specifications
! Benefits:
an estimate of the missing
value (e.g., using a formula)
!  Construct a report listing missing values
!  In programs, ignore missing data unless
the value is significant (sensitivity testing)
" Can improve performance (speed) by reducing number of table
lookups (i.e. reduce number of necessary join queries)
! Costs (due to data duplication)
" Wasted storage space
" Data integrity/consistency threats
! Common denormalization opportunities
" One-to-one relationship (Fig. 5-3)
" Many-to-many relationship with non-key attributes (associative entity)
(Fig. 5-4)
" Reference data (1:N relationship where 1-side has data not used in
any other relationship) (Fig. 5-5)
Triggers can be used to perform these operations.
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
DENORMALIZATION
!  Substitute
Chapter 5
Chapter 5
15
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
16
Figure 5-4 A possible denormalization situation: a many-to-many
relationship with nonkey attributes
Figure 5-3 A possible denormalization situation: two entities with one-
to-one relationship
Extra table
access
required
Null description possible
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
17
Figure 5-5
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
DENORMALIZE WITH CAUTION
A possible
denormalization
situation:
reference data
!  Denormalization
"  Increase
!  Perhaps
other methods could be used to
improve performance of joins
"  Organization
of tables in the database (file
organization and clustering)
"  Proper query design and optimization
Data duplication
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
can
chance of errors and inconsistencies
"  Reintroduce anomalies
"  Force reprogramming when business rules
change
Extra table
access
required
Chapter 5
18
19
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
20
PARTITIONING
! 
PARTITIONING PROS AND CONS
!  Advantages
Horizontal Par titioning: Distributing the rows of a
logical relation into several separate tables
Useful for situations where different users need access to
different rows
"  Three types: Key Range Partitioning, Hash Partitioning, or
Composite Partitioning
" 
! 
Ver tical Par titioning: Distributing the columns of a
logical relation into several separate physical tables
!  Disadvantages
Useful for situations where different users need access to
different columns
"  The primary key must be repeated in each file
" 
! 
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
21
ORACLES HORIZONTAL
PARTITIONING
! 
Range partitioning
"  A
Partitions defined via hash functions
Will guarantee balanced distribution of rows
"  Partition could contain widely varying valued fields
" 
" 
! 
– a table, index, or partition
"  Extent–contiguous section of disk space
"  Data block – smallest unit of storage
Composite partitioning
Combination of the other approaches
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
components
"  Segment
Based on predefined lists of values for the partitioning
key
Chapter 5
File:
!  Tablespace
List partitioning
" 
22
named portion of secondary memory allocated
for the purpose of storing physical records
"  Tablespace–named logical storage unit in which
data from multiple tables/views/objects can be
stored
Hash partitioning
" 
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
!  Physical
Partitions defined by range of field values
"  Could result in unbalanced distribution of rows
"  Like-valued fields share partitions
! 
Chapter 5
DESIGNING PHYSICAL DATABASE FILES
" 
! 
of Partitioning:
Inconsistent access speed: Slow retrievals across partitions
"  Complexity: Non-transparent partitioning
"  Extra space or update time: Duplicate data; access from
multiple partitions
" 
Combinations of Horizontal and Vertical
Chapter 5
of Partitioning:
Efficiency: Records used together are grouped together
"  Local optimization: Each partition can be optimized for
performance
"  Security: data not relevant to users are segregated
"  Recovery and uptime: smaller files take less time to back up
"  Load balancing: Partitions stored on different disks, reduces
contention
" 
23
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
24
Figure 5-6 DBMS terminology in an Oracle 11g environment
FILE ORGANIZATIONS
Technique for physically arranging records of a file
on secondary storage
!  Factors for selecting file organization:
! 
Fast data retrieval and throughput
Efficient storage space utilization
"  Protection from failure and data loss
"  Minimizing need for reorganization
"  Accommodating growth
"  Security from unauthorized use
" 
" 
! 
Types of file organizations
Sequential
Indexed
"  Hashed
" 
" 
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
25
Figure 5-7a
Sequential file
organization
Records of the
file are stored in
sequence by the
primary key
field values.
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
26
INDEXED FILE ORGANIZATIONS
!  Storage
of records sequentially or
nonsequentially with an index that allows
software to locate individual records
!  Index: a table or other data structure used to
determine in a file the location of records that
satisfy some condition
!  Primary keys are automatically indexed
!  Other fields or combinations of fields can also
be indexed; these are called secondary keys
(or nonunique keys)
If sorted –
every insert or
delete requires
resort
If not sorted
Average time to
find desired record
= n/2
Chapter 5
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
27
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
28
Figure 5-7b Indexed file organization
Figure 5-7c
Hashed file
organization
Hash algorithm
Usually uses divisionremainder to determine
record position. Records
with same position are
grouped in lists.
uses a tree search
Average time to find desired
record = depth of the tree
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
29
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
31
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
30
Figure 6-8 Join Indexes–speeds up join operations
b) Join index for matching foreign
key (FK) and primary key (PK)
a) Join index
for common
non-key
columns
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
32
CLUSTERING FILES
RULES FOR USING INDEXES
!  In
some relational DBMSs, related records from
different tables can be stored together in the
same disk area
!  Useful for improving performance of join
operations
!  Primary key records of the main table are
stored adjacent to associated foreign key
records of the dependent table
!  e.g. Oracle has a CREATE CLUSTER command
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
33
RULES FOR USING INDEXES (CONT.)
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
34
!  Parallel
query processing–possible when
working in multiprocessor systems
!  Overriding automatic query optimization–
allows for query writers to preempt the
automated optimization
!  Oracle example:
values; perhaps compress values first
7.  If key to index is used to determine location of
record, use surrogate (like sequence number)
to allow even spread in storage area
8.  DBMS may have limit on number of indexes
per table and number of bytes per indexed
field(s)
9.  Be careful of indexing attributes with null
values; many DBMSs will not recognize null
values in an index search
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
WHERE clause)
4.  Fields in SQL ORDER BY and GROUP BY
commands
5.  When there are >100 values but not when
there are <30 values
QUERY OPTIMIZATION
6.  Avoid use of indexes for fields with long
Chapter 5
1.  Use on larger tables
2.  Index the primary key of each table
3.  Index search fields (fields frequently in
/* */ clause is a hint to override Oracles default
query plan
35
Chapter 5
© 2013 Pearson Education, Inc. Publishing as Prentice Hall
36
Download PDF
Similar pages