Professional Documents
Culture Documents
DD 6 2 SG
DD 6 2 SG
Database Design
6-2
Normalization and First Normal Form
2
Objectives
• This lesson covers the following objectives:
−Define the purpose of normalization in database models
−Define the rule of First Normal Form in the normalization
process
−Determine if an entity conforms to the rule of First Normal
Form
−Convert an entity to First Normal Form if needed
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 3
This course discusses the first three rules of normalization. You should be aware that there are more.
Normalization can go from First Normal Form (1NF) all the way to Fifth Normal Form (5NF) and beyond
(6NF and 7NF are mostly academic exercises). For most business models, 3NF is enough.
Normalization is a very formal term that can be intimidating to some students. Explain that although
normalization is derived from complex mathematical rules, the data modeler’s goal is to eliminate
redundancy.
3
Purpose
• Think about storing your friends’ phone numbers in
three different places:
−your address book, your cell phone, and a sheet of paper that
you have taped to your refrigerator
• It’s a lot of work if a friend changes his/her phone
number
• You have to change it in your address book, cell phone,
and the sheet of paper taped to your
refrigerator
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 4
Normalization can be a difficult concept to learn. At the very basic level, it just seems like common
sense – make sure you don’t store the same data twice in the model, and that you store data in the
correct place. However, the rules of normalization are formal statements that can involve complex
language.
4
Purpose
• What happens if data is stored in more than one place
in a database?
• What if someone changes the information in one place
and not the other—how do you know which
information is correct?
• Redundancy like this causes unnecessary problems in a
database
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 5
Normalization: A series of steps followed to obtain a database design that allows for efficient access and
storage of data in a relational database. These steps reduce data redundancy and the chances of data
becoming inconsistent.
Redundancy: Something that is unnecessarily repetitive; the state of being unnecessarily repetitive.
A useful memory aid: some legal systems require that a witness in court swears to tell “the truth, the
whole truth and nothing but the truth”. One way of stating the normalization rules is that “Every non-
UID attribute must be dependent on the UID, the whole UID, and nothing but the UID”.
5
Purpose
• Normalization is a process that is used to eliminate
these kinds of problems
• One of your goals as a database designer is to "store
information in one place and in the best possible
place“
• If you follow the rules of normalization, you will
achieve this goal
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 6
Normalization: A series of steps followed to obtain a database design that allows for efficient access and
storage of data in a relational database. These steps reduce data redundancy and the chances of data
becoming inconsistent.
Redundancy: Something that is unnecessarily repetitive; the state of being unnecessarily repetitive.
A useful memory aid: some legal systems require that a witness in court swears to tell “the truth, the
whole truth and nothing but the truth”. One way of stating the normalization rules is that “Every non-
UID attribute must be dependent on the UID, the whole UID, and nothing but the UID”.
6
First Normal Form (1NF)
• First Normal Form requires that no multi-valued
attributes exist SCHOOL BUILDING 1NF
The classroom
• To check for 1NF, SCHOOL BUILDING
# Code attribute will have
validate that each * Name multiple values.
* Address This entity is not in
attribute has a single o Classroom First Normal Form.
value for each instance the
of the entity SCHOOL BUILDING location
of
CLASSROOM
# Code # Number
• One code, one name, * Name located * Floor
* Address in * Size
and one address exist
for the school building, CLASSROOM is now its own entity.
but not one classroom All attributes have only one value per
instance.
Both entities are in First Normal Form.
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 7
“For school building code 15, what is the address?” There is only one value of the address. But “For
school building 15, what is the classroom number?” Many values – so this entity is not in First Normal
Form
7
First Normal Form (1NF)
• Since many classrooms exist in a school building,
classroom is SCHOOL BUILDING 1NF
multi-valued and SCHOOL BUILDING The classroom
# Code attribute will have
violates 1NF * Name multiple values.
• If an attribute is * Address
o Classroom
This entity is not in
First Normal Form.
multi-valued, create the
an additional entity SCHOOL BUILDING location
of
CLASSROOM
# Code # Number
and relate it to the * Name located * Floor
original entity with * Address in * Size
a 1:M relationship
CLASSROOM is now its own entity.
All attributes have only one value per
instance.
Both entities are in First Normal Form.
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 8
1NF eliminates repeating groups (multiple values) within an attribute by transferring the attribute to a
new entity and then connecting the entities with a 1:M relationship.
8
1NF Violations
• Examine the entities: 1) STUDENT
# Number
−Are there any multi-valued attributes? * First name
* Last name
* Subject
2) SHOPPING MALL
# Id
* Name
* Address
* Store name
* Store floor
3)
TEAM LEAGUE
belong to
# Id # Number
* Name made up of * Name
* Player
1NF Violations
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 9
1. There are many subjects that can be associated with a STUDENT. The subject attribute is misplaced
because it is multi-valued.
2. A SHOPPING MALL has more than one store. Store name and store floor are attributes with multiple
values and should not be in the SHOPPING MALL entity.
3. A TEAM has several players, so the player attribute has multiple values.
9
1NF Solutions
2) STORE located in SHOPPING MALL
• When all the attributes # Name # Id
* Floor house
in an entity are * Name
* Address
single-valued, that entity * Store name
* Store floor
is said to be in
First Normal Form 3) TEAM
# Id belong to
* Name LEAGUE
* Player made up of # Number
have * Name
1)
10
Terminology
• Key terms used in this lesson included:
−First Normal Form (1NF)
−Normalization
−Redundancy
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 11
11
Summary
• In this lesson, you should have learned how to:
−Define the purpose of normalization in database models
−Define the rule of First Normal Form in the normalization
process
−Determine if an entity conforms to the rule of First Normal
Form
−Convert an entity to First Normal Form if needed
DDS6L2
Normalization and First Normal Form Copyright © 2020, Oracle and/or its affiliates. All rights reserved. 12
12
13