Unit 3_Normalization
Unit 3_Normalization
2 Snoopy 232-234-1234
Functional Dependencies: {AuId}
{AuPhone}
3 Grumpy 665-235-6532
4 Jones 123-333-3333
{AuId}
5 Smith 654-223-3455
{AuName}
6 Joyce 666-666-6666 {AuName, AuPhone}
7 Roman 444-444-4444 {AuID}
FD – Example
Functional Dependencies
AuthNo AuthName, AuthEmail, AuthAddress
AuthEmail AuthNo
PaperNo Primary-AuthNo, Title, Abstract,
Status
RevNo RevName, RevEmail, RevAddress
RevEmail RevNo
RevNo, PaperNo AuthComm, Prog-Comm,
Date, Rating1, Rating2, Rating3, Rating4,
Rating5
Determinant and Dependent
8
Functional Dependency
EmpNum EmpEmail
91.2914
Transitive dependency
9
Transitive dependency
91.2914
Transitive dependency
10
EmpNum DeptNum
EmpNum EmpEmail DeptNum DeptNname
DeptNum DeptName
91.2914
Partial dependency
11
1. Uniqueness: No two rows can have the same value of the candidate key.
2. Minimality: The set is minimal, meaning that if any attribute is removed from
the candidate key, it no longer remains capable of uniquely identifying every
tuple in the table.
3. Not Null: All attributes in the candidate key must be non-null to ensure that
every tuple can always be uniquely identified.
A candidate key is considered a candidate for selection as the primary key of the
table. The primary key is a specially designated candidate key chosen to uniquely
identify tuples in a relational table, primarily used for indexing and referencing in
relational operations. Other candidate keys not chosen as the primary key are
referred to as alternate keys.
Levels of Normalization
Levels of normalization based on the amount
of redundancy in the database.
Various levels of normalization are:
First Normal Form (1NF)
Second Normal Form (2NF)
Third Normal Form (3NF)
Boyce-Codd Normal Form (BCNF)
Fourth Normal Form (4NF)
Fifth Normal Form (5NF)
Domain Key Normal Form (DKNF)
Most
Mostdatabases
databasesshould
shouldbe
be3NF
3NFor
orBCNF
BCNFininorder
ordertotoavoid
avoidthe
thedatabase
databaseanomalies.
anomalies.
Levels of Normalization
1NF
2NF
3NF
BCNF
4NF
5NF
Each
Eachhigher
higherlevel
levelisisaasubset
subsetofofthe
thelower
lowerlevel
level
First Normal Form (1NF)
A table is considered to be in 1NF if all the fields
contain
only scalar values (as opposed to list of values).
Example
ISBN Title (Not 1NF)
AuName AuPhone PubName PubPhone Price
Author
Authorand
andAuPhone
AuPhonecolumns
columnsare
arenot
notscalar
scalar
1NF - Decomposition
1. Place all items that appear in the repeating group
in a new table
2. Designate a primary key for each new table
produced.
3. Duplicate in the new table the primary key of the
table from which the repeating ISBN
group
AuName
was
AuPhone
extracted or vice versa. 0-321-32132-1 Sleepy 321-321-1111
Example
ISBN
(1NF)
Title PubName PubPhone Price 0-321-32132-1 Snoopy 232-234-1234
0-55-123456-9 Main Street Small House 714-000-0000 $22.95 0-55-123456-9 Jones 123-333-3333
This form dictates that all non-key or non prime attributes of a table
must be functionally dependent on a candidate key or prime attribute
can also be dependent on Non prime attribute
i.e. there can be no interdependencies among non-key attributes.
Example
Functional Dependencies:
1. EmpID, ProjectID -> SupervisorID (an employee and
FD
(student, Teacher) -> subject
(student, subject) -> Teacher
Teacher -> subject
Candidate keys are (student, teacher) and (student,
subject).
• Course_Info(CourseID, Instructor)
• Instructor_Info(Instructor, Textbook)
This decomposition removes redundancy and each
table is in BCNF.
Example: Employee Project
Supervision
Table: ProjectAssignments
• Attributes: EmpID (Employee ID), ProjectID (Project
Functional Dependencies:
1. EmpID, ProjectID -> SupervisorID (an employee and
X = R₁ ∩ R₂,
then the decomposition is lossless if:
Example of lossless
Cand_ID is CK
Decomposition of table
Join of decomposed table
BCNF - Decomposition
EXAMPLE:
R(ABCD); {ABCD, DA}
CK={AB, BD} PA={A B D} NPA={C}
SOLUTION:
Check for 3NF,
It is a 3NF
Check for BCNF, Fd1 is okay but FD2 is not following BCNF
R(ABCD) is decomposed into R1={D, A} and R2={B C D}
Check for lossless decomposition
Check for lossless decomposition
Common attribute of the decomposed table should be CK of
any of the table
Attribute (R1∩ R2) = CK of any of R1 or R2 or R
Here it is D, and D is CK in R1 as D A, Therefore it is
lossless
Check for dependency preserving
Multivalued Dependency
A multivalued dependency (MVD) exists when, for a given value of
attribute X, there are multiple, independent values of attributes Y and Z,
and these values are independent of each other.
XY
XZ
Here
StudentLanguage and StudentSport
And language and sport are independent , therefore not
in 4nf
Decomposition
These tables doesn't violate 4 normal form by
itself.
That's because:
• tables have only two attributes: Student, Sports and
Student Language
• There are no third attributes that could show
independence
• So, this table is in 4NF
Fifth Normal Form (5NF)