Tải bản đầy đủ (.pdf) (24 trang)

Module 5: Normalizing the Logical Data Design

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (639.53 KB, 24 trang )


Module 5: Normalizing the Logical
Data Design


THIS PAGE LEFT INTENTIONALLY BLANK




Module 1: Course
Overview
Module 4: Deriving a
Logical Data Design
Module 5: Normalizing the
Logical Data Design
Module 6: Deriving a
Physical Data Design
Module 7:
Implementing Data
Integrity
Module 2: Solution
Design Processes
Module 3: Using a
Conceptual Design for Data
Requirements
Module 8: Designing
Data Services
Module 9: Data Storage
Considerations
Designing Data


Services and
Data Models
Implementing
Entity
Relationships
Activity 5.1: Identifying
Keys in the Logical Model
Normalization
Basic
Activity 5.2: Deriving the
Third Normal Form for a
Logical Data Model
Module 5: Normalizing the
Logical Data Design

Module 5: Normalizing the Logical Data Design 95



!
!!
! Overview
"
Implementing Entity Relationships
"
Normalization Basics
"
Review
In this module...
In this module...



After completing this module, you will be able to:
"
Use primary and foreign keys to implement relationships between entities.
"
Explain the benefits of normalizing entities.
"
Normalize a table to third normal form.

Slide Objective
To provide an overview of
this module’s topics and
objectives.
Lead-in
This module discusses the
implementation of
relationships between
entities with keys and
database normalization
strategies.
96 Module 5: Normalizing the Logical Data Design



!
!!
! Implementing Entity Relationships
"
Using Keys

"
Primary Keys
"
Foreign Keys
"
Examples of Primary and Foreign Keys
"
Activity 5.1: Identifying Keys in the
Logical Model
In this section...
In this section...


In this section, you will learn how entities are uniquely identified within the
logical data model with keys. You will also learn how keys are used to
implement relationships between entities.
Slide Objective
To introduce the topics in
this section.
Lead-in
In this section, you will learn
about primary and foreign
keys and how to use them
to implement relationships.
Module 5: Normalizing the Logical Data Design 97



Using Keys
"

Benefits
$
Uniquely define an entity within a group of like entities
$
Help to move data design from logical to physical
$
Tie entities together to form relationships


Keys are identifying values assigned to each instance of an entity within a data
model. As you learned in Module 4, “Deriving a Logical Data Design,” entities
within a data model represent a grouping of information about people, places,
objects, or ideas. When you begin to move a logical design to a physical design,
you use keys to uniquely identify each instance of an entity within the data
model.
Keys also provide the mechanism for tying entities together. In your physical
database design, you represent relationships between entities by adding the keys
from parent entity tables to child entity tables so that the entities are bound
together by the common key value.
Slide Objective
To introduce the concept of
keys within the physical data
model.
Lead-in
Keys are the mechanism for
implementing relationships.
98 Module 5: Normalizing the Logical Data Design




Primary Keys
"
Identifying attributes (existing or new) for entities
"
Unique values are necessary
"
Types of primary keys
$
Intelligent — related to entities as attributes and keys
$
Surrogate — related to entities only as unique identifiers
$
Composite — comprised of more than one value


A primary key is any field that represents the uniqueness of all an entity’s
instances. The primary key value must be unique across all instances of an
entity; otherwise, the key value cannot identify any one instance of the entity.
The uniqueness of the values in a primary key allows each instance of an entity
to exist independently.
An entity’s primary key can be an existing attribute within the entity. Any
identifying attribute that is guaranteed to be unique across all instances of an
entity is a candidate for a primary key. If the uniqueness of the existing
attributes cannot be guaranteed, you can create an identifying key, usually a
numeric value, and assign it primary key responsibilities.
The following types of primary keys exist:
"
Intelligent keys
These keys are created from existing attributes and are related to entities as
both attributes and keys.

"
Surrogate keys
These keys are identifier values with no specific relation to entities other
than to uniquely identify them.
"
Composite keys
These keys include more than one value per entity. When one attribute
within an entity is not enough to uniquely identify each instance of the
entity, you can select more than one attribute to be a composite key. For
example, each project within a project-tracking database might have a
project number, and each project number might contain multiple jobs, each
with its own identifying job number. You might use recurring job numbers
within each project to denote a specific phase of the project. In this case, the
primary key of the project table would be a composite key consisting of
both the project number and the job number, because both numbers are
necessary to uniquely identify any one job.

Slide Objective
To introduce primary keys
and how they are defined
within the data model.
Lead-in
Primary keys define
uniqueness in the relational
data model.
Delivery Tip
Give an example of an
intelligent key and a
surrogate key.
Delivery Tip

It might help to draw a
picture of a project table
with a composite key.
Module 5: Normalizing the Logical Data Design 99



Foreign Keys
"
Values that establish relationships between parent and
child entities
"
Typically primary keys of parent entities
"
Keys that contain same values as parent entities’
instances
"
Possibly members of child entities’ primary keys


Foreign keys are values that exist in child entities and that establish
relationships with the corresponding parent entities. The parent entity can find
all its related child entities by searching the child entities for those instances
with the appropriate foreign key.
A foreign key for a child entity is usually the primary key of the parent entity,
because as the primary key uniquely defines the parent, the child must in turn
be associated with a unique instance of the parent.
The foreign key for a child entity cannot serve as the child’s entire primary key
because many instances of the child entity may be related to the same parent
instance, and as a result, have the same foreign key value. In many cases,

however, the foreign key can serve as a member of a composite key for the
child.
Slide Objective
To introduce foreign key
concepts.
Lead-in
Foreign keys are used as
the links between entities
that make relationships
possible.
Delivery Tip
If necessary, remind
students of the basic
definition of a relationship.
Also remind them about
parent and child entities, as
well as the different types of
relationships.
100 Module 5: Normalizing the Logical Data Design



Examples of Primary and Foreign Keys


The slide shows a logical data model with primary and foreign keys, as well as
entity relationships.
The primary keys identified for each entity are surrogate keys. As shown, each
employee, client, timesheet, and invoice instance of an entity has its own
unique identifier. The EmployeeID primary key in the Employee entity is used

as a foreign key in both the Client and Timesheet entities. Although the
Timesheet entity has a primary key, the EmployeeID foreign key is responsible
for linking the Timesheet and Employee entities together.
Notice the existence between the Timesheet and EmployeeID entities. A
timesheet cannot exist unless an employee fills it out. However, the dotted line
between the Client and Employee entities indicates that although an employee
and a client are related, neither depends on the other for its existence.
Slide Objective
To show how primary and
foreign keys might be used
in a logical data model.
Lead-in
The following slide shows
how primary and foreign
keys might be used in a
logical data model.
Module 5: Normalizing the Logical Data Design 101



Activity 5.1: Identifying Keys in the Logical Model


In this activity, you will identify primary, foreign, and (if necessary) composite
keys in the logical data model for Ferguson and Bardell, Inc.
After completing this activity, you will be able to:
"
Identify primary, foreign, and composite keys in a logical data model.
"
Select a primary and foreign key type that is appropriate for a given entity.


Slide Objective
To introduce this activity.
Lead-in
In this activity, you will
identify keys in the
Ferguson and Bardell, Inc.
logical data model.
Delivery Tip
Make the students aware
that they are focusing on
keys in this activity. They
are identifying keys to
reinforce their knowledge so
that they will be able to build
a normalized data model.

×