Professional Documents
Culture Documents
bcis5420_lecture note_ch5_data normalization (1)
bcis5420_lecture note_ch5_data normalization (1)
Data Normalization
4/24/2023 1
2.1
Ch.5. Data Normalization
4/24/2023 2
2.2
Ch.5. Data Normalization
4/24/2023 3
2.3
Ch.5. Data Normalization
4/24/2023 4
2.4
Ch.5. Data Normalization
• Edit
• Symbols
Master text styles
and Meanings in ER Diagrams
• Second level
• Third level Entity Name
• Fourth level
Primary Key
• Fifth level
Simple, single-valued attribute
Multi-valued attribute
Composite attribute
4/24/2023 5
2.5
Ch.5. Data Normalization
Foreign key
Regular attribute
4/24/2023 6
2.6
Ch.5. Data Normalization
• Edit Master
• Simple text
attributes mapstyles
directly onto the relation
• Second level
CUSTOMER Entity Type
• Third level
• Fourth level
Allowing space in attribute names
• Fifth level
CUSTOMER Relation
NOT Allowing space in attribute names
4/24/2023 7
2.7
Ch.5. Data Normalization
•• Edit Master
Composite textto styles
attributes the relations, using only their component attributes
• Second level
• Third level
CUSTOMER Entity Type with Composite Attribute
• Fourth level
• Fifth level
4/24/2023 8
2.8
Ch.5. Data Normalization
4/24/2023 9
2.9
Ch.5. Data Normalization
Employee
Employee Employee Employee MS Office Skill
ID
ID First Name Last Name
333-33-3333 Word
333-33-3333 Excel
333-33-3333 Simpson Alice
333-33-3333 PowerPoint
111-11-1111 Sanders Ned 111-11-1111 Word
111-11-1111 Excel
123-45-6789 Moore Tom
123-45-6789 Excel
4/24/2023 10
2.10
Ch.5. Data Normalization
Weak entity
DEPENDENT
Relations Resulting
from Weak Entity
4/24/2023 13
2.13
Ch.5. Data Normalization
• •Edit Master
Primary text styles
key on mandatory side becomes a foreign key on optional side
• Second level
• Third level
• Fourth level
• Fifth level One-to-one Relationship between
NURSE and CARE CENTER
• •Edit Master
Primary text
key on the one styles
side becomes a foreign key on the many side (c.f.,
similar one-to-one relationships)
• Second level
• Third level
• Fourth level
• Fifth level One-to-Many Relationship between
CUSTOMER and ORDER
4/24/2023 15
2.15
Ch.5. Data Normalization
•• create
Edit aMaster text
new relation withstyles
the primary keys of the two entities as its composite
primary key
• Second level
• Third level
• Fourth level
• Fifth level
A new relation
(i.e., associative entity)
4/24/2023 16
2.16
Ch.5. Data Normalization
•• Edit
Primary key of supertype relation becomes primary key of subtype relation
Master text styles
• Second level
• Third level
• Fourth level
• Fifth level
4/24/2023 17
2.17
Ch.5. Data Normalization
4/24/2023 18
2.18
Ch.5. Data Normalization
4/24/2023 19
2.19
Ch.5. Data Normalization
4/24/2023 20
2.20
Ch.5. Data Normalization
Click
How to edit
to Make Master
First title
Normal Form style
(1NF)
• (1) Having a primary key, which uniquely defines each row, and (2) single
• Edit Master text styles
value at the intersection of each row and column of the table (i.e., no missing
values and multivalued attributes)
• Second level
• Hence, the example below is NOT 1NF (see the next slide for the first normal
form•ofThird
this) level
• Fourth level
• Fifth level
4/24/2023 21
2.21
Ch.5. Data Normalization
4/24/2023 22
2.22
Ch.5. Data Normalization
Data redundancies
4/24/2023 23
2.23
Ch.5. Data Normalization
Inconsistency!
4/24/2023 24
2.24
Ch.5. Data Normalization
•• Edit
UpdateMaster
anomalies:text styles
data inconsistencies caused by partial update of data
• Second level
Alice recently married, changing her last name from
• Third level Simpson to Hopkins. However, the update is only applied
• Fourth level to one of the two instances, causing an update anomaly
4/24/2023 25
2.25
Ch.5. Data Normalization
•• Edit
Insert Master
anomalies: text styles caused by inserting incomplete rows
data inconsistencies
• Second level
Student ID Last Name First Name Course No. Section Day Time
• Third level
333-33-3333 Simpson
• Fourth level Alice ACCT- 3603 1 M 9:00 AM
Tom was recently added as a new student but has registered no course,
causing an insert anomaly
4/24/2023 26
2.26
Ch.5. Data Normalization
•• Edit Master
Deletion text
anomalies: datastyles
inconsistencies caused by partial deletion of data
•Student
Second ID level
Last Name First Name Course No. Section Day Time
• Third level
333-33-3333 Simpson Alice ACCT- 3603 1 M 9:00 AM
• Fourth level
333-33-3333 Simpson
• Fifth levelAlice FIN-3213 3 Th 11:00 AM
4/24/2023 29
2.29
Ch.5. Data Normalization
4/24/2023 30
2.30
Ch.5. Data Normalization
INVOICE
PRODUCT
CUSTOMER ORDER
4/24/2023 32
2.32
Ch.5. Data Normalization
▪ Transitive dependencies: when a relation has a single primary key and some
attributes depend on another non-key attribute, which can determine the attributes
CUSTOMER ORDER
4/24/2023 33
2.33
Ch.5. Data Normalization
•• Edit
Why Master
Transitivetext styles Matter?
Dependencies
• Second level
CUSTOMER ORDER (2NF)
• Third level
Order Order Customer Customer Customer
ID Date • Fourth
ID level
Name Address
OD1 20220929 •C1 Fifth level
Nick address_1
CUSTOMER ORDER in 2NF still has
OD2 20220929 C2 Tom address_2 redundancies in the relation, caused by
OD3 20220929 C3 Harry address_3 transitive dependencies
OD4 20220929 C4 Andrea address_4
OD5 20220930 C1 Nick address_1
OD6 20220930 C2 Tom address_2
OD7 20220930 C3 Harry address_3
OD8 20220930 C4 Andrea address_4
4/24/2023 34
2.34
Ch.5. Data Normalization
• •Edit Master
In addition text
to 2NF, styles dependencies
no transitive
• Second
• Solution: leveldeterminant (CustomerID in the example) becomes the
non-key
primary key in the new table and stays as foreign key in the old table
• Third level
• Fourth level
• Fifth level
4/24/2023 35
2.35
Ch.5. Data Normalization
• Edit Master
CUSTOMER ORDERtext styles
(2NF) ORDER (3NF)
Order
ID
• Order
Second
Date ID
level
Customer Customer
Name
Customer
Address
Order
ID
Order
Date
Customer
ID
OD1 • Third
20220929 C1 level Nick address_1
OD1 20220929 C1
OD2 20220929 C2
OD2 20220929 • C2Fourth Tom
level address_2 OD3 20220929 C3
C3 • Fifth
OD4 20220929 C4
OD3 20220929 Harrylevel
address_3 OD5 20220930 C1
OD4 20220929 C4 Andrea address_4 OD6 20220930 C2
OD7 20220930 C3
OD5 20220930 C1 Nick address_1
OD8 20220930 C4
OD6 20220930 C2 Tom address_2
OD7 20220930 C3 Harry address_3
CUSTOMER (3NF)
OD8 20220930 C4 Andrea address_4 Customer Customer Customer
ID Name Address
C1 Nick address_1
C2 Tom address_2
Data redundancies are removed as dividing C3 Harry address_3
CUSTOMER ORDER into two relations C4 Andrea address_4
4/24/2023 36
2.36
Ch.5. Data Normalization
ORDER LINE
Each relation
represents one single Playing as an
“entity”, such as associative relation
product, order line,
order, and customer ORDER
CUSTOMER
4/24/2023 37
2.37
Ch.5. Data Normalization
4/24/2023 38
2.38
Ch.5. Data Normalization
4/24/2023 39
2.39
Ch.5. Data Normalization
• •Edit Master
Conducted text styles
when normalized
processing time and cost
relations are not user friendly, requiring excessive data
• Second
• Transforms level relations into non-normalized relations based on needs
normalized
• Third level
• Fourth level
▪ Normalized Relations
• Fifth level
4/24/2023 40
2.40
Ch.5. Data Normalization
4/24/2023 41
2.41
Ch.5. Data Normalization
4/24/2023 42
2.42
Ch.5. Data Normalization
4/24/2023 43
2.43