CHAPTER 5:
PHYSICAL DATABASE DESIGN AND
PERFORMANCE
Essentials of Database Management
Jeffrey A. Hoffer, Heikki Topi, V. Ramesh
Copyright © 2014 Pearson Education, Inc.
1
WHAT IS DATA NORMALİZATİON?
It’s no secret.
We are officially living in the era of big data.
Nearly every business—especially large-scale enterprises—collects, stores,
and analyzes data for the benefit of growth.
In most daily business operations, managing data is a norm, using tools such
as:
•Databases
•Automation systems
•CRM platforms
Chapter 5 Copyright © 2014 Pearson Education, Inc.
2
WHAT İS DATA NORMALİZATİON?
If you've worked in any company for some time, you've probably
encountered the term Data Normalization.
Data normalization ensures:
• Consistency: Data is organized in a consistent format, reducing
redundancy.
• Accuracy: By removing duplicates, the accuracy of data is
improved.
• Efficiency: It streamlines data management, making it easier to
maintain and query.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
3
WHAT İS DATA NORMALİZATİON?
Data normalization is generally considered the
development of clean data. Diving deeper,
however, the meaning or goal of data normalization
is twofold:
1. Data normalization is the organization of data to
appear similar across all records and fields.
2. It increases the cohesion of entry types leading to
cleansing, lead generation, segmentation, and
higher quality data.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
4
WHAT İS DATA NORMALİZATİON?
this process includes eliminating unstructured data and redundancy (duplicates) in
order to ensure logical data storage.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
5
WHO NEEDS DATA NORMALİZATİON?
Database Administrators: They use normalization to design efficient and reliable
databases, minimizing redundancy and ensuring data integrity.
Data Analysts: Normalized data is easier to query and analyze, leading to more
accurate insights and reports.
Developers: Working with normalized data structures simplifies development and
maintenance of applications.
Businesses: Any company that stores large amounts of data benefits from improved
data consistency and reduced storage costs.
Researchers: Clean and organized data is crucial for accurate and replicable
research results.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
6
HOW DATA NORMALİZATİON WORKS
Normalization is simply creating a standard format for
all data throughout a company:
Miss EMILY will be written in Ms. Emily
8023097864 will be written 802-309-7864
24 canillas RD will be written 24 Canillas Road
GoogleBiz will be written Google Biz, Inc.
VP marketing will be written Vice President of Marketing
Chapter 5 Copyright © 2014 Pearson Education, Inc.
7
1. FİRST NORMAL FORM (1NF)
For the purposes of complexity, in this article, the first and three most common
forms are discussed at a top-level and all data is considered in table format.
1. First Normal Form (1NF)
The most basic form of data normalization is 1NFm which ensures there are no
repeating entries in a group. To be considered 1NF, each entry must have only
one single value for each cell and each record must be unique.
For example, you are recording the name, address, gender of a person, and if
they bought cookies.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
8
2. SECOND NORMAL FORM (2NF)
Again working to ensure no repeating entries, to be in the 2NF rule, the
data must first apply to all the 1NF requirements.
Following that, data must have only one primary key.
To separate data to only have one primary key, all subsets of data that
can be placed in multiple rows should be placed in separate tables.
Then, relationships can be created through new foreign key labels.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
9
3. THİRD NORMAL FORM (3NF)
For data to be in this rule, it must first comply with all the 2NF
requirements.
Following that, data in a table must only be dependent on the primary
key.
If the primary key is changed, all data that is impacted must be put into
a new table.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
10
BENEFİTS OF DATA NORMALİZATİON
Eliminates Data Redundancy
Improves Data Integrity
More space
Enhanced Query Performance Faster question answering
Facilitates Data Maintenance Better segmentation
Promotes Scalability
Better Data Relationships
Reduces Anomalies
Optimized Storage Use
Chapter 5 Copyright © 2014 Pearson Education, Inc.
11
DATA NORMALIZATION IS NOT AN
OPTION
Mandatory for Data Integrity
Scalability
Facilitates Maintenance
In essence, normalization isn't just a best practice—it's a necessity
for any organization that relies on data for its operations and
decision-making processes.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
12
OBJECTIVES
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, and know when/how to
denormalize
Chapter 5 Copyright © 2014 Pearson Education, Inc.
13
PHYSICAL DATABASE DESIGN
Purpose–translate 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
insure database integrity, security, and
recoverability
Chapter 5 Copyright © 2014 Pearson Education, Inc.
14
PHYSICAL DESIGN PROCESS
Inputs Decisions
Normalized relations
Attribute data types
Volume estimates
Physical record descriptions
Attribute definitions (doesn’t always match
logical design)
Response time
expectations File organizations
Leads to
Data security needs Indexes and database
architectures
Backup/recovery needs
Query optimization
Integrity expectations
DBMS technology used
Chapter 5 Copyright © 2014 Pearson Education, Inc.
15
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 Copyright © 2014 Pearson Education, Inc.
16
DESIGNING FIELDS
Field:smallest unit of application data
recognized by system software
Field design
Choosing data type
Coding, compression, encryption
Controlling data integrity
Chapter 5 Copyright © 2014 Pearson Education, Inc.
17
CHOOSING DATA TYPES
Chapter 5 Copyright © 2014 Pearson Education, Inc.
18
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
Chapter 5 Copyright © 2014 Pearson Education, Inc.
19
FIELD DATA INTEGRITY
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 Copyright © 2014 Pearson Education, Inc.
20
HANDLING MISSING DATA
Substitute 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)
Triggers can be used to perform these operations
Chapter 5 Copyright © 2014 Pearson Education, Inc.
21
DENORMALIZATION
Transforming normalized relations into non-normalized
physical record specifications
Benefits:
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-2)
Many-to-many relationship with non-key attributes (associative entity)
(Fig. 5-3)
Reference data (1:N relationship where 1-side has data not used in
any other relationship) (Fig. 5-4)
Chapter 5 Copyright © 2014 Pearson Education, Inc.
22
Figure 5-2 A possible denormalization situation: two entities with one-
to-one relationship
Chapter 5 Copyright © 2014 Pearson Education, Inc.
23
Figure 5-3 A possible denormalization situation: a many-to-many
relationship with nonkey attributes
Extra table
access
required
Null description possible
Chapter 5 Copyright © 2014 Pearson Education, Inc.
24
Figure 5-4
A possible
denormalization
situation:
reference data
Extra table
access
required
Data duplication
Chapter 5 Copyright © 2014 Pearson Education, Inc.
25
DENORMALIZE WITH CAUTION
Denormalization can
Increase chance of errors and inconsistencies
Reintroduce anomalies
Force reprogramming when business rules
change
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
Chapter 5 Copyright © 2014 Pearson Education, Inc.
26
DESIGNING PHYSICAL DATABASE FILES
Physical File:
A 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
Tablespace components
Segment – a table, index, or partition
Extent–contiguous section of disk space
Data block – smallest unit of storage
Chapter 5 Copyright © 2014 Pearson Education, Inc.
27
Figure 5-5 DBMS terminology in an Oracle 11g environment
Chapter 5 Copyright © 2014 Pearson Education, Inc.
28
FILE ORGANIZATIONS
Technique for physically arranging
records of a file on secondary
storage
Types of file organizations
Sequential
Indexed
Hashed
Chapter 5 Copyright © 2014 Pearson Education, Inc.
29
FILE ORGANIZATIONS
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
Chapter 5 Copyright © 2014 Pearson Education, Inc.
30
Figure 5-6a
Sequential file
organization
Records of the If sorted – every
insert or delete
file are stored in requires re-sort
sequence by the
primary key
field values
If not sorted
Average time to
find desired record
= n/2
Chapter 5 Copyright © 2014 Pearson Education, Inc.
31
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)
Chapter 5 Copyright © 2014 Pearson Education, Inc.
32
Figure 5-6b Indexed file organization
uses a tree search
Average time to find desired
record = depth of the tree
Chapter 5 Copyright © 2014 Pearson Education, Inc.
33
Figure 5-6c
Hashed file
organization
Hash algorithm
Usually uses division-
remainder to determine
record position. Records
with same position are
grouped in lists.
Chapter 5 Copyright © 2014 Pearson Education, Inc.
34
Figure 5-7 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 Copyright © 2014 Pearson Education, Inc.
35
Chapter 5 Copyright © 2014 Pearson Education, Inc.
36
USING 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)
Chapter 5 Copyright © 2014 Pearson Education, Inc.
37
RULES FOR USING INDEXES
1. Use on larger tables
2. Index the primary key of each table
3. Index search fields (fields frequently in
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
Chapter 5 Copyright © 2014 Pearson Education, Inc.
38
RULES FOR USING INDEXES (CONT.)
6. Avoid use of indexes for fields with long
values; perhaps compress values first
7. If key to index is used to determine location of
record, use surrogate (like sequence nbr) 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
Chapter 5 Copyright © 2014 Pearson Education, Inc.
39
QUERY OPTIMIZATION
Parallel query processing–possible when
working in multiprocessor systems
Overriding automatic query optimization–
allows for query writers to preempt the
automated optimization
Data warehouses are already configured for
optimized query performance
Chapter 5 Copyright © 2014 Pearson Education, Inc.
40