Sie sind auf Seite 1von 17

Data Modeling

and
Normalization

http://www.train-right.com

9/30/2009 Kenneth W. Caldwell & Brian S. Porter


Goals of Data Modeling
• Document Essential Business Data
– Provide for Create Retrieve Update Delete (CRUD) activities
– Change
– Growth
• Communicate Data Requirements
– Business Analysts
– Technical Staff
• Test Data Requirements
– Complete, Consistent, Correct (3-C’s)

9/30/2009 www.train-right.com
Data Dictionary
• Data Attributes are packaged together into an ENTITY
– Represents a Business Object and/or Activity

• Each Entity must be assigned a Primary Key (PK)


– Distinguishes each Entity Occurrence

In the Data Dictionary, an ORDER Entity is made up of the following Data


Attributes

ORDER = Order# + Date +


Cust# + Name + Address + City + State + Zip +
1 {Product# + Desc + Price + Quantity} n

9/30/2009 www.train-right.com
Entity Relationship Diagram (ERD)
• The Meaning of the Relationship
– A Verb
• The Cardinality of the Relationship
– One to One (1:1)
– One to Many (1:M)
– Many to Many (M:M)
• The Optionality of the Relationship
– Must
– May

9/30/2009 www.train-right.com
Entity Relationship Diagram (ERD)

The Relationship Sentence:

EACH {entity 1} {optionality} {verb} {cardinality} {entity 2}

EACH Car May Be Driven By One or More Person

EACH Passport Must Identify One Person

9/30/2009 www.train-right.com
Data Normalization
Normalization Is the process of analyzing a data
model for functional dependencies against the
primary keys to achieve the desirable properties of:
Minimizing data redundancy and maintaining data
integrity
Minimizing creation, deletion, and updating anomalies
Minimizing data storage requirements
Ensuring data dependencies make business sense
Each attribute must depend on its primary key, the
entire primary key and nothing but the primary key – so
help me Codd!

9/30/2009 www.train-right.com
Data Normalization
First proposed by Dr. Edgar Codd (1970)
Relational Database structure defined mathematically
Introduced 3 normal forms; first, second and third normal
form (1971)
A stronger definition of 3NF - called Boyce-Codd normal
form (BCNF) was defined (1974)
4NF, 5NF and 6NF were added (1977 – 1981)
The accepted Industry Standard goal is to achieve 3NF.

9/30/2009 www.train-right.com
First Normal Form (1NF)
• No repeating attributes in an Entity

ORDER – How many?


Order# (PK)
Date Create activity
Cust#
Name – How to manage?
Address, City, State, Zip
Product# Desc Price Quantity
Delete activity
_______ ____ ____ _______
_______ ____ ____ _______
...

9/30/2009 www.train-right.com
Correct 1NF Violation
1. Move the violating attributes to a new Entity
2. Copy the Primary Key to the new Entity (Foreign Key)
3. Assign a Primary Key to the new Entity (composite PK)
4. Name the new Entity and add Relationship

ORDER ORDERED_PRODUCT
Order# (PK) ORDER
Order# (PK) (FK)
Date Product# (PK)
Cust# APPEAR
Desc
Name ON Price
Address, City, State, Zip Quantity

9/30/2009 www.train-right.com
Second Normal Form (2NF)
• Each attribute must be dependent on the entire
Primary Key
– Optional Relationship
Create activity
Delete activity
– Redundant data
...
Update activity
ORDERED_PRODUCT
Order# (PK) Consistency
Product# (PK)
Desc
Price
Quantity
9/30/2009 www.train-right.com
Correct 2NF Violation
1. Move the violating attributes to a new Entity
2. Copy the partial Primary Key attribute to the new Entity
3. Assign a Primary Key to the new Entity (FK)
4. Name the new Entity and add Relationship

ORDERED_PRODUCT ORDER
PRODUCT
Order# (PK) (FK) Product# (PK)
Product# (PK) (FK) APPEAR
Desc
Quantity ON Price

9/30/2009 www.train-right.com
2NF
• No More Many to Many Relationships

ORDER
Order# (PK)
ORDER
ORDERED_PRODUCT
Date Order# (PK) (FK)
Cust# Product# (PK) (FK)
APPEAR
Name ON Quantity
Address, City, State, Zip
APPEAR
ON

ORDER

PRODUCT
Product# (PK)
Desc
Price

9/30/2009 www.train-right.com
Third Normal Form (3NF)
• Each attribute must be dependent on only the
Primary Key
– Transitive data
Create activity
Delete activity
...
ORDER
– Redundant data
Order# (PK) Update activity
Date
Cust#
Name
Address, City, State, Zip

9/30/2009 www.train-right.com
Correct 3NF Violation
1. Move the violating attributes to a new Entity
2. Copy the dependent non-Key attribute to the new Entity
3. Assign a Primary Key to the new Entity (FK)
4. Name the new Entity and add Relationship

BE
ORDER ORDERED CUSTOMER
BY
Order# (PK) Cust# (PK)
Date Name
MAY
Cust# (FK) PLACE Address, City, State, Zip

9/30/2009 www.train-right.com
3NF

ORDER ORDER
ORDERED_PRODUCT
Order# (PK) Order# (PK) (FK)
Date APPEAR
Product# (PK) (FK)
Cust# (FK) ON Quantity

MAY APPEAR
PLACE ON

BE
ORDERED ORDER
BY

CUSTOMER PRODUCT
Cust# (PK) Product# (PK)
Name Desc
Address, City, State, Zip Price

9/30/2009 www.train-right.com
Follow-Up Activities
• Review all Entities, Attributes and Relationships for the 3-C’s
• Be sure all relationships are supported by a Foreign Key
• Check for additional redundancies (Play CRUD!)
• Identify Alternate (Secondary) Keys
– Retrieve activities
– Sorting sequence
• Provide Scalability Requirements
– # People
– # Data
– # Time

9/30/2009 www.train-right.com
Thank-You!
TR001 Introduction to Business Systems Analysis
TR003 Object-Oriented Analysis and Design
TR008 Basic Problem Solving
TR012 Modeling Essential Business Data
TR013 Designing Distributed Databases
TR023 Creating Technical Documentation
TR027 Structured Business Systems Design
TR031 Customizing the SDLC for Your Organization
TR033 Overview of Data Modeling
TR034 Overview of Database Concepts
TR037 Business Systems Testing Fundamentals
TR041 Interpersonal Skills for Business Analysts
TR043 Discovering Essential Business Requirements
TR044 Overview of Business Systems Analysis and Design
TR049 Use Cases and Object-Oriented Concepts
TR058 Overview of Agile Systems Development

9/30/2009 www.train-right.com

Das könnte Ihnen auch gefallen