0% found this document useful (0 votes)
8 views224 pages

Bcse302l Dbms Module-3 Smsatapathy

Uploaded by

kamalnishant1223
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views224 pages

Bcse302l Dbms Module-3 Smsatapathy

Uploaded by

kamalnishant1223
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 224

Module - 3

Relational Database Design


LTPC
BCSE302L - 3 0 0 3
BCSE302P - 0 0 2 1

Dr. Shashank Mouli Satapathy


Professor, SCOPE

School of Computer Science and Engineering


Vellore Institute of Technology
Vellore, Tamil Nadu - 632014, India

September 3, 2024
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 1
Outline

1 Schema Refinement

2 Functional Dependencies

3 Database Normalization

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 2
Schema Refinement

Database design may be performed using two approaches.


➔ Bottom-up design methodology (also called design by synthesis)
• from the individual attributes → relation schema
• problem → have to collect a large number of binary relationships
among attributes as the starting point
➔ Top-down design methodology (also called design by analysis)
• starts with a number of groupings of attributes into relations that
exist together naturally. For example, on an invoice, a form, or a report
Goals of the design activity are information preservation and minimum
redundancy.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 3
Informal Design Guidelines for Relation Schemas

Four informal guidelines → measures to determine the quality of relation


schema design.
1 Semantics of the attributes:

When attributes are grouped to form a relation schema, it is assumed


that attributes belonging to one relation have certain meaning and a
proper interpretation is associated with them.
Hence it is important to ensure that the semantics of the attributes is
clear in the schema.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 4
Informal Design Guidelines for Relation Schemas

Guideline 1:
➔ Design a relation schema so that it is easy to explain its meaning.
➔ Do not combine attributes from multiple entity types and relationship
types into a single relation.
Violation of the design guideline - example

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 5
Informal Design Guidelines for Relation Schemas

2 Redundant Information in Tuples and Update Anomalies:


Goal of schema design → minimize the storage space
Grouping attributes into relation schemas has a significant effect on
storage space.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 6
Informal Design Guidelines for Relation Schemas
Anomalies that occur when joining relations
Insertion Anomalies
➔ Insert a new employee tuple into EMP DEPT → either include
attribute values for the department or else NULL (if he is not assigned
with any department)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 7
Informal Design Guidelines for Relation Schemas

Deletion Anomalies
➔ we delete from EMP DEPT

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 8
Informal Design Guidelines for Relation Schemas

Modification Anomalies
➔ If one copy of such repeated data is updated then there is inconsistency
unless all repeated copies are similarly updated.
➔ In EMP DEPT, if we change the value of one of the attributes of a
particular department, say, the department 5 → we must update the
tuples of all employees who work in that department.
➔ otherwise, the database will become inconsistent If not, the same
department will be shown to have two different values for manager
which would be wrong.
Guideline 2:
➔ Design a schema that does not suffer from the insertion, deletion and
update anomalies.
➔ If there are any anomalies present, then note them so that applications
can be made to take them into account.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 9
Informal Design Guidelines for Relation Schemas
3 Reducing Null Values in Tuples:
Problems:
➔ wastage of space at the storage level
➔ Difficult to understand the meaning of attributes and with specifying
JOIN operations
➔ Difficulty in applying aggregate function such as count, avg etc.
Guideline 3:
➔ Relations should be designed such that their tuples will have as few
NULL values as possible
➔ Attributes that are NULL frequently could be placed in separate
relations
Example: If 10% of employees have phone number then a separate
relation could be maintained to store the phone no of the employees
who have phone.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 10
Informal Design Guidelines for Relation Schemas

Reasons for nulls:


➔ Attribute not applicable or invalid
➔ Attribute value unknown (may exist)
➔ Value known to exist, but unavailable

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 11
Informal Design Guidelines for Relation Schemas

4 Generation of Spurious Tuples:


Bad designs for a relational database may result in erroneous results for
certain JOIN operations
The “lossless join” property is used to guarantee meaningful results for
join operations.
Guideline 4:
➔ The relations should be designed to satisfy the lossless join condition.
➔ Design the relational schema so that the individual relation can be
joined with the equality condition on the attribute that are primary key
or foreign key in a ways that guarantees that no spurious tuples are
generated.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 12
Informal Design Guidelines for Relation Schemas

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 13
Informal Design Guidelines for Relation Schemas

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 14
Functional Dependency (FD)
Formal tool for analysis of relational schemas.
It is used to specify the formal measures of the “goodness” of
relational design.
Definition: Functional dependency is a constraint between two sets of
attributes from the database.
A Functional Dependency (FD), denoted by x → y, between two sets
of attributes x & y, that are subsets of any universal relation schema
R specifies a constraint on the possible tuples of R.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 15
Functional Dependency (FD)

A set of attributes X functionally determines a set of attributes Y, if


the value of X uniquely determines a unique value for Y.
It typically exists between the primary key and non-key attribute
within a table.
Given a relation instance we can not guarantee whether the certain
FD may hold or not.
We can ensure certain FD does not hold if certain tuples violates that
FD.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 16
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

A→B

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 17
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

A→B
➔ Tuple 1 and 2 violates constraint

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 17
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

A→B
➔ Tuple 1 and 2 violates constraint
D→C

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 17
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

A→B
➔ Tuple 1 and 2 violates constraint
D→C
➔ Tuple 3 and 4 violates constraint

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 17
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

A→B
➔ Tuple 1 and 2 violates constraint
D→C
➔ Tuple 3 and 4 violates constraint
C→D

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 17
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

A→B
➔ Tuple 1 and 2 violates constraint
D→C
➔ Tuple 3 and 4 violates constraint
C→D
➔ Tuple 2 and 3 violates constraint

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 17
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

B→C

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 18
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

B→C
➔ may hold

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 18
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

B→C
➔ may hold
C→B

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 18
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

B→C
➔ may hold
C→B
➔ may hold

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 18
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

B→C
➔ may hold
C→B
➔ may hold
(A,B)→D

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 18
Functional Dependency (FD)

Consider the following relation R(A, B, C, D)

B→C
➔ may hold
C→B
➔ may hold
(A,B)→D
➔ may hold

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 18
Diagrammatic Representation of Functional Dependency

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 19
Diagrammatic Representation of Functional Dependency

Consider the following relation R:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 20
Diagrammatic Representation of Functional Dependency

The following FDs hold in the above diagram


Ssn,Pnumber→Hours
Ssn→Ename
Pnumber→Pname,Plocation

From the below diagram, identify the functional dependency.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 21
Diagrammatic Representation of Functional Dependency
The following FDs hold in the above diagram
Ssn,Pnumber→Hours
Ssn→Ename
Pnumber→Pname,Plocation

From the below diagram, identify the functional dependency.

F = Ssn→Ename,Bdate,Address,Dnumber
Dnumber→Dname,Dmgr ssn
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 22
Trivial and Non-trivial Dependency

There are two types of functional dependencies.


1 Trivial Functional Dependency

➔ The dependency of an attribute on a set of attributes is known as trivial


functional dependency if the set of attributes includes that attribute.
➔ A FD X → Y is called as trivial FD if Y ⊆ X.
➔ For Example, A → A, AB → A. It is satisfied by all relations.
➔ Consider a table with two columns Student id and Student Name.
{Student Id, Student Name} → Student Id is a trivial functional
dependency as Student Id is a subset of {Student Id, Student Name}.
➔ Also, Student Id → Student Id & Student Name → Student Name are
trivial dependencies too.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 23
Trivial and Non-trivial Dependency

2 Non-trivial Functional Dependency


➔ A FD X → Y is called as non-trivial FD if Y ⊈ X.
➔ For Example, A → B, AB → AC.
➔ Consider a table with three columns, an employee table with three
attributes: emp id, emp name, emp address.
➔ The following functional dependencies are non-trivial:
emp id → emp name (emp name is not a subset of emp id)
emp id → emp address (emp address is not a subset of emp id)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 24
Inference Rules for FDs
(or)
Armstrong’s Axioms

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 25
Armstrong’s Axioms

Given a set of functional dependency F we can infer additional


functional dependencies.
Systematic way to infer dependencies is through use of set of
inference rules.
Armstrong’s Axioms property was developed by William W.
Armstrong in 1974 to reason about functional dependencies.
The property suggests rules that hold true if the following are
satisfied:
➔ Axioms of Reflexivity
➔ Axioms of Augmentation
➔ Axioms of Transitivity

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 26
Armstrong’s Axioms

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 27
Armstrong’s Axioms

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 28
Armstrong’s Axioms

Axioms of Reflexivity (IR1 ): In the reflexive rule, if Y is a subset of X,


then X determines Y (i.e X holds a value of Y).
For example, {roll no, name} → name (this is a valid FD).
Axioms of Augmentation (IR2 ): If X → Y is a valid dependency, then
XZ → YZ is also valid by the augmentation rule.
For example, If {roll no, name} → dept building is valid, hence
{roll no, name, dept name} → {dept building, dept name} is also
valid.
Axioms of Transitivity (IR3 ): If X → Y and Y → Z are both valid
dependencies, then X → Z is also valid by the Transitivity rule.
For example,
roll no → dept name
dept name → dept building,
then, roll no → dept building is also valid.
IR1 , IR2 , IR3 form a sound and complete set of inference rules.
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 29
Armstrong’s Axioms

The last three inference rules(Additional inference rule) can be


deduced from IR1 , IR2 , IR3 (completeness property)
Additional inference rules
Union: If two tables are separate, and the PK is the same, then you
can consider putting them together. (i.e., you can take its union).
Given X → Y, X → Z
then X → XY (Augmentation Rule)
then XY → YZ (Augmentation Rule)
⇒ X → YZ (Transitive Rule)
For example, if:
Emp ID → EmpName
Emp ID → SpouseName
You may want to join these two tables into one as follows:
Emp ID → EmpName, SpouseName

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 30
Armstrong’s Axioms

Decomposition: It is reverse of the Union rule.


If you have a table that appears to contain two entities that are
determined by the same PK, consider breaking them up into two
tables.
Given X → YZ
YZ → Y (Reflexive Rule)
⇒ X → Y (Transitive Rule)
Similarly you can prove X → Z from X → YZ
Psuedotransitivity: Given X → Y, WY → Z
then WX → WY (Augmentation Rule)
⇒ WX → Z (Transitive Rule)
For example, if
Rollno → name
name, marks → percentage
then, Rollno, marks → percentage

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 31
Armstrong’s Axioms

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 32
Multivalued dependency
Multivalued dependency occurs when there are more than one
independent multivalued attribute in a table.
In this case these two columns are said to be multivalued dependent
on bike model. These dependencies can be represented like this:

bike model ↠ manuf year


bike model ↠ color
We can read this as “bike model multidetermined manuf year” and
“bike model multidetermined color”.
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 33
Practice Example

Given a relation R ( A, B, C, G, H, I ) with the functional dependencies,


F = {A → B, A → C, CG → H, CG → I, B → H}.
Find any new FD using inference rule.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 34
Practice Example

Given a relation R ( A, B, C, G, H, I ) with the functional dependencies,


F = {A → B, A → C, CG → H, CG → I, B → H}.
Find any new FD using inference rule.

Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 34
Practice Example

Given a relation R ( A, B, C, G, H, I ) with the functional dependencies,


F = {A → B, A → C, CG → H, CG → I, B → H}.
Find any new FD using inference rule.

Solution:
A → H [Transitive Rule ( A → B, B → H)]

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 34
Practice Example

Given a relation R ( A, B, C, G, H, I ) with the functional dependencies,


F = {A → B, A → C, CG → H, CG → I, B → H}.
Find any new FD using inference rule.

Solution:
A → H [Transitive Rule ( A → B, B → H)]
CG → HI [Union Rule (CG → H, CG → I)]

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 34
Practice Example

Given a relation R ( A, B, C, G, H, I ) with the functional dependencies,


F = {A → B, A → C, CG → H, CG → I, B → H}.
Find any new FD using inference rule.

Solution:
A → H [Transitive Rule ( A → B, B → H)]
CG → HI [Union Rule (CG → H, CG → I)]
AG → I [Pseudo-transitive Rule (A → C, CG → I)]

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 34
Inference Rules for FDs (Closure)
Closure of a set of FDs F is the set F + of all FDs that can be inferred
from F including F.
Closure of a set of attributes X with respect to F is the set X + of all
attributes that are functionally determined by X.
X + can be calculated by repeatedly applying IR1 , IR2 , IR3 using the
FDs in F.
Attribute Closure:
Given a set of attributes x, the closure of x under F (denoted by x + )
is defined as the set of attributes that are functionally determined by
x under F.
Algorithm

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 35
Closure - Example 1

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {A → BC, BC → DE, D → F, CF → G}. Find FD +

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 36
Closure - Example 1

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {A → BC, BC → DE, D → F, CF → G}. Find FD +
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 36
Closure - Example 1

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {A → BC, BC → DE, D → F, CF → G}. Find FD +
Solution:
Closure of attribute A

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 36
Closure - Example 1

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {A → BC, BC → DE, D → F, CF → G}. Find FD +
Solution:
Closure of attribute A
A+ = {A}
= {A, B, C} ( Using A → BC )
= {A, B, C, D, E} ( Using BC → DE )
= {A, B, C, D, E, F} ( Using D → F )
= {A, B, C, D, E, F, G} ( Using CF → G )
Thus A+ = {A, B, C, D, E, F, G}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 36
Closure - Example 1

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {A → BC, BC → DE, D → F, CF → G}. Find FD +
Solution:
Closure of attribute A
A+ = {A}
= {A, B, C} ( Using A → BC )
= {A, B, C, D, E} ( Using BC → DE )
= {A, B, C, D, E, F} ( Using D → F )
= {A, B, C, D, E, F, G} ( Using CF → G )
Thus A+ = {A, B, C, D, E, F, G}
Closure of attribute D
D + = {D}
= {D, F} ( Using D → F )
Thus D + = {D, F}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 36
Closure - Example 1

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {A → BC, BC → DE, D → F, CF → G}. Find FD +
Solution:
Closure of attribute BC

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 37
Closure - Example 1

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {A → BC, BC → DE, D → F, CF → G}. Find FD +
Solution:
Closure of attribute BC
BC + = {B, C}
= {B, C, D, E} ( Using BC → DE )
= {B, C, D, E, F} ( Using D → F )
= {B, C, D, E, F, G} ( Using CF → G )
Thus BC + = {B, C, D, E, F, G}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 37
Closure - Example 1

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {A → BC, BC → DE, D → F, CF → G}. Find FD +
Solution:
Closure of attribute BC
BC + = {B, C}
= {B, C, D, E} ( Using BC → DE )
= {B, C, D, E, F} ( Using D → F )
= {B, C, D, E, F, G} ( Using CF → G )
Thus BC + = {B, C, D, E, F, G}
Closure of attribute CF
CF + = {C, F}
= {C, F, G} ( Using CF → G )
Thus CF + = {C, F, G }

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 37
Closure - Example 2

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {AB → CD, AF → D, DE → F, C → G, F → E, G
→ A}. Find CF + , BG + , AF + and AB +

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 38
Closure - Example 2

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {AB → CD, AF → D, DE → F, C → G, F → E, G
→ A}. Find CF + , BG + , AF + and AB +
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 38
Closure - Example 2

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {AB → CD, AF → D, DE → F, C → G, F → E, G
→ A}. Find CF + , BG + , AF + and AB +
Solution:
Closure of attribute CF

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 38
Closure - Example 2

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {AB → CD, AF → D, DE → F, C → G, F → E, G
→ A}. Find CF + , BG + , AF + and AB +
Solution:
Closure of attribute CF
CF + = {C, F}
= {C, F, G} ( Using C → G )
= {C, E, F, G} ( Using F → E )
= {A, C, E, F, G} ( Using G → A )
= {A, C, D, E, F, G} ( Using AF → D )
Thus CF + = {A, C, D, E, F, G}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 38
Closure - Example 2
Consider a relation R ( A, B, C, D, E, F, G ) with the functional
dependencies - FD = {AB → CD, AF → D, DE → F, C → G, F → E, G
→ A}. Find CF + , BG + , AF + and AB +
Solution:
Closure of attribute CF
CF + = {C, F}
= {C, F, G} ( Using C → G )
= {C, E, F, G} ( Using F → E )
= {A, C, E, F, G} ( Using G → A )
= {A, C, D, E, F, G} ( Using AF → D )
Thus CF + = {A, C, D, E, F, G}
Closure of attribute BG
BG + = {B, G}
= {A, B, G} ( Using G → A )
= {A, B, C, D, G} ( Using AB → CD )
Thus BG + = {A, B, C, D, G}
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 38
Closure - Example 2

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {AB → CD, AF → D, DE → F, C → G, F → E, G
→ A}. Find CF + , BG + , AF + and AB +
Solution:
Closure of attribute AF

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 39
Closure - Example 2

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {AB → CD, AF → D, DE → F, C → G, F → E, G
→ A}. Find CF + , BG + , AF + and AB +
Solution:
Closure of attribute AF
AF + = {A, F}
= {A, D, F} ( Using AF → D )
= {A, D, E, F} ( Using F → E )
Thus AF + = {A, D, E, F}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 39
Closure - Example 2

Consider a relation R ( A, B, C, D, E, F, G ) with the functional


dependencies - FD = {AB → CD, AF → D, DE → F, C → G, F → E, G
→ A}. Find CF + , BG + , AF + and AB +
Solution:
Closure of attribute AF
AF + = {A, F}
= {A, D, F} ( Using AF → D )
= {A, D, E, F} ( Using F → E )
Thus AF + = {A, D, E, F}
Closure of attribute AB
AB + = {A, B}
= {A, B, C, D} ( Using AB → CD )
= {A, B, C, D, G} ( Using C → G )
Thus AB + = {A, B, C, D, G}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 39
Closure - Example 3

Consider a relation R ( A, B, C, D, E ) with the functional dependencies -


FD = {A → BC, C → B, D → E, E → D}. Calculate the closure of the
attributes.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 40
Closure - Example 3

Consider a relation R ( A, B, C, D, E ) with the functional dependencies -


FD = {A → BC, C → B, D → E, E → D}. Calculate the closure of the
attributes.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 40
Closure - Example 3

Consider a relation R ( A, B, C, D, E ) with the functional dependencies -


FD = {A → BC, C → B, D → E, E → D}. Calculate the closure of the
attributes.
Solution:
A+ = {A, B, C}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 40
Closure - Example 3

Consider a relation R ( A, B, C, D, E ) with the functional dependencies -


FD = {A → BC, C → B, D → E, E → D}. Calculate the closure of the
attributes.
Solution:
A+ = {A, B, C}
B + = {B}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 40
Closure - Example 3

Consider a relation R ( A, B, C, D, E ) with the functional dependencies -


FD = {A → BC, C → B, D → E, E → D}. Calculate the closure of the
attributes.
Solution:
A+ = {A, B, C}
B + = {B}
C + = {B, C}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 40
Closure - Example 3

Consider a relation R ( A, B, C, D, E ) with the functional dependencies -


FD = {A → BC, C → B, D → E, E → D}. Calculate the closure of the
attributes.
Solution:
A+ = {A, B, C}
B + = {B}
C + = {B, C}
D + = {D, E}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 40
Closure - Example 3

Consider a relation R ( A, B, C, D, E ) with the functional dependencies -


FD = {A → BC, C → B, D → E, E → D}. Calculate the closure of the
attributes.
Solution:
A+ = {A, B, C}
B + = {B}
C + = {B, C}
D + = {D, E}
E + = {D, E}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 40
Closure - Example 4

Consider a relation EMP PROJ ( SSN, ENAME, PNUMBER, PNAME,


PLOC, HOURS ) with the functional dependencies - F = {SSN →
ENAME, PNUMBER → {PNAME, PLOC}, {SSN, PNUMBER} →
HOURS}. Determine the closure.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 41
Closure - Example 4

Consider a relation EMP PROJ ( SSN, ENAME, PNUMBER, PNAME,


PLOC, HOURS ) with the functional dependencies - F = {SSN →
ENAME, PNUMBER → {PNAME, PLOC}, {SSN, PNUMBER} →
HOURS}. Determine the closure.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 41
Closure - Example 4

Consider a relation EMP PROJ ( SSN, ENAME, PNUMBER, PNAME,


PLOC, HOURS ) with the functional dependencies - F = {SSN →
ENAME, PNUMBER → {PNAME, PLOC}, {SSN, PNUMBER} →
HOURS}. Determine the closure.
Solution:
{SSN}+ = {SSN, ENAME}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 41
Closure - Example 4

Consider a relation EMP PROJ ( SSN, ENAME, PNUMBER, PNAME,


PLOC, HOURS ) with the functional dependencies - F = {SSN →
ENAME, PNUMBER → {PNAME, PLOC}, {SSN, PNUMBER} →
HOURS}. Determine the closure.
Solution:
{SSN}+ = {SSN, ENAME}
{PNUMBER}+ = {PNUMBER, PNAME, PLOC}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 41
Closure - Example 4

Consider a relation EMP PROJ ( SSN, ENAME, PNUMBER, PNAME,


PLOC, HOURS ) with the functional dependencies - F = {SSN →
ENAME, PNUMBER → {PNAME, PLOC}, {SSN, PNUMBER} →
HOURS}. Determine the closure.
Solution:
{SSN}+ = {SSN, ENAME}
{PNUMBER}+ = {PNUMBER, PNAME, PLOC}
{SSN, PNUMBER}+ = {SSN, PNUMBER, ENAME, PNAME,
PLOC, HOURS}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 41
Closure - Example 5

Consider a relation R ( A, B, C, D, E, F ) with the functional


dependencies - F = {AB → C, BC → AD, D → E, CF → B}. Test
whether AB → D and D → A follow from the set of dependencies.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 42
Closure - Example 5

Consider a relation R ( A, B, C, D, E, F ) with the functional


dependencies - F = {AB → C, BC → AD, D → E, CF → B}. Test
whether AB → D and D → A follow from the set of dependencies.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 42
Closure - Example 5

Consider a relation R ( A, B, C, D, E, F ) with the functional


dependencies - F = {AB → C, BC → AD, D → E, CF → B}. Test
whether AB → D and D → A follow from the set of dependencies.
Solution:
AB → D (Correct)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 42
Closure - Example 5

Consider a relation R ( A, B, C, D, E, F ) with the functional


dependencies - F = {AB → C, BC → AD, D → E, CF → B}. Test
whether AB → D and D → A follow from the set of dependencies.
Solution:
AB → D (Correct)
Since, AB + = {A, B, C, D, E} and D ∈ {A, B, C, D, E}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 42
Closure - Example 5

Consider a relation R ( A, B, C, D, E, F ) with the functional


dependencies - F = {AB → C, BC → AD, D → E, CF → B}. Test
whether AB → D and D → A follow from the set of dependencies.
Solution:
AB → D (Correct)
Since, AB + = {A, B, C, D, E} and D ∈ {A, B, C, D, E}
D → A (Incorrect)
Since, {D}+ = {D, E} and A ∈ / {D}+ , hence, we can conclude that
D → A does not follow from the given set of dependencies.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 42
Closure - Example 6

Consider a relation R ( ABCDEFGH ) with the functional dependencies - F


= {A → B, CH → A, B → E, BD → C, EG → H, DE → F}. Which of
the following FD is also guaranteed to be satisfied by R?
⇒ BFG → AE
⇒ ACG → DH
⇒ CEG → AB

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 43
Closure - Example 6

Consider a relation R ( ABCDEFGH ) with the functional dependencies - F


= {A → B, CH → A, B → E, BD → C, EG → H, DE → F}. Which of
the following FD is also guaranteed to be satisfied by R?
⇒ BFG → AE
⇒ ACG → DH
⇒ CEG → AB
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 43
Closure - Example 6

Consider a relation R ( ABCDEFGH ) with the functional dependencies - F


= {A → B, CH → A, B → E, BD → C, EG → H, DE → F}. Which of
the following FD is also guaranteed to be satisfied by R?
⇒ BFG → AE
⇒ ACG → DH
⇒ CEG → AB
Solution:
BFG → AE

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 43
Closure - Example 6

Consider a relation R ( ABCDEFGH ) with the functional dependencies - F


= {A → B, CH → A, B → E, BD → C, EG → H, DE → F}. Which of
the following FD is also guaranteed to be satisfied by R?
⇒ BFG → AE
⇒ ACG → DH
⇒ CEG → AB
Solution:
BFG → AE
Incorrect! {BFG }+ = {BFGEH}, which includes E, but not A.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 43
Closure - Example 6

Consider a relation R ( ABCDEFGH ) with the functional dependencies - F


= {A → B, CH → A, B → E, BD → C, EG → H, DE → F}. Which of
the following FD is also guaranteed to be satisfied by R?
⇒ BFG → AE
⇒ ACG → DH
⇒ CEG → AB
Solution:
BFG → AE
Incorrect! {BFG }+ = {BFGEH}, which includes E, but not A.
ACG → DH
Incorrect! {ACG }+ = {ACGBE}, which includes neither D nor H.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 43
Closure - Example 6

Consider a relation R ( ABCDEFGH ) with the functional dependencies - F


= {A → B, CH → A, B → E, BD → C, EG → H, DE → F}. Which of
the following FD is also guaranteed to be satisfied by R?
⇒ BFG → AE
⇒ ACG → DH
⇒ CEG → AB
Solution:
BFG → AE
Incorrect! {BFG }+ = {BFGEH}, which includes E, but not A.
ACG → DH
Incorrect! {ACG }+ = {ACGBE}, which includes neither D nor H.
CEG → AB
Correct {CEG }+ = {CEGHAB}, which contains AB.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 43
Closure [Determining Candidate Key] - Example 7

Check whether A is the candidate key of a relation scheme R(A, B, C, D,


M, F, G) FDS = {A → B, B → CD, C → M, D → FG}.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 44
Closure [Determining Candidate Key] - Example 7

Check whether A is the candidate key of a relation scheme R(A, B, C, D,


M, F, G) FDS = {A → B, B → CD, C → M, D → FG}.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 44
Closure [Determining Candidate Key] - Example 7

Check whether A is the candidate key of a relation scheme R(A, B, C, D,


M, F, G) FDS = {A → B, B → CD, C → M, D → FG}.
Solution:
A+ = {A}
= {A, B} ( Using A → B )
= {A, B, C, D} ( Using B → CD )
= {A, B, C, D, M} ( Using C → M )
= {A, B, C, D, F, G, M} ( Using D → FG )
Thus A+ = {A, B, C, D, F, G, M}. Hence, A is the candidate key of
the relation.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 44
Closure [Determining Candidate Key] - Example 8

Check whether AC is the candidate key of a relation scheme R(A, B, C, D,


F, G, M, N) FDS = {AC → B, B → CD, C → MN, D → FG}.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 45
Closure [Determining Candidate Key] - Example 8

Check whether AC is the candidate key of a relation scheme R(A, B, C, D,


F, G, M, N) FDS = {AC → B, B → CD, C → MN, D → FG}.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 45
Closure [Determining Candidate Key] - Example 8

Check whether AC is the candidate key of a relation scheme R(A, B, C, D,


F, G, M, N) FDS = {AC → B, B → CD, C → MN, D → FG}.
Solution:
{AC }+ = {A, C}
= {A, C, B} ( Using AC → B )
= {A, C, B, D} ( Using B → CD )
= {A, C, B, D, M, N} ( Using C → MN )
= {A, C, B, D, M, N, F, G} ( Using D → FG )
Thus {AC }+ = {A, B, C, D, F, G, M, N}. Hence, AC can be the
candidate key of the relation, if A or C are not candidate keys.
A+ = {A} // Not a candidate key
C + = {C, M, N} // Not a candidate key
So, AC is the candidate key.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 45
Closure [Determining Candidate Key] - Example 9

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F)


with the following FDS = {A → C, C → D, D → B, E → F}.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 46
Closure [Determining Candidate Key] - Example 9

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F)


with the following FDS = {A → C, C → D, D → B, E → F}.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 46
Closure [Determining Candidate Key] - Example 9

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F)


with the following FDS = {A → C, C → D, D → B, E → F}.
Solution:
As A and E can not be derived from any other attributes, so all possible
candidate key must have attributes A and E
{AE }+ = {A, E}
= {A, E, C} ( Using A → C )
= {A, E, C, D} ( Using C → D )
= {A, E, C, D, B} ( Using D → B )
= {A, E, C, D, B, F} ( Using E → F )
Thus {AE }+ = {A, B, C, D, E, F}. Hence, AE is the only candidate
key of the relation.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 46
Closure [Determining Candidate Key] - Example 10

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 10

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 10

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.
Solution:
Since EFG never appear on RHS of any FD. So, EFG must be part of
any key of R.
As A never appears on LHS of any FD, but appear on RHS. So A is
not part of any key of R.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 10

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.
Solution:
Since EFG never appear on RHS of any FD. So, EFG must be part of
any key of R.
As A never appears on LHS of any FD, but appear on RHS. So A is
not part of any key of R.
{EFG }+ = {E, F, G} // not a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 10

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.
Solution:
Since EFG never appear on RHS of any FD. So, EFG must be part of
any key of R.
As A never appears on LHS of any FD, but appear on RHS. So A is
not part of any key of R.
{EFG }+ = {E, F, G} // not a ck
{BEFG }+ = {B, E, F, G, C, D, A, H} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 10

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.
Solution:
Since EFG never appear on RHS of any FD. So, EFG must be part of
any key of R.
As A never appears on LHS of any FD, but appear on RHS. So A is
not part of any key of R.
{EFG }+ = {E, F, G} // not a ck
{BEFG }+ = {B, E, F, G, C, D, A, H} // it’s a ck
{CEFG }+ = {C, E, F, G, D, B, A, H} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 10

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.
Solution:
Since EFG never appear on RHS of any FD. So, EFG must be part of
any key of R.
As A never appears on LHS of any FD, but appear on RHS. So A is
not part of any key of R.
{EFG }+ = {E, F, G} // not a ck
{BEFG }+ = {B, E, F, G, C, D, A, H} // it’s a ck
{CEFG }+ = {C, E, F, G, D, B, A, H} // it’s a ck
{DEFG }+ = {D, E, F, G} // not a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 10

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.
Solution:
Since EFG never appear on RHS of any FD. So, EFG must be part of
any key of R.
As A never appears on LHS of any FD, but appear on RHS. So A is
not part of any key of R.
{EFG }+ = {E, F, G} // not a ck
{BEFG }+ = {B, E, F, G, C, D, A, H} // it’s a ck
{CEFG }+ = {C, E, F, G, D, B, A, H} // it’s a ck
{DEFG }+ = {D, E, F, G} // not a ck
{HEFG }+ = {H, E, F, G, B, C, D, A} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 10
Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,
G, H) with the following FDS = {CD → A, EC → H, GHB → AB, C →
D, H → B, BE → CD, EC → B}.
Solution:
Since EFG never appear on RHS of any FD. So, EFG must be part of
any key of R.
As A never appears on LHS of any FD, but appear on RHS. So A is
not part of any key of R.
{EFG }+ = {E, F, G} // not a ck
{BEFG }+ = {B, E, F, G, C, D, A, H} // it’s a ck
{CEFG }+ = {C, E, F, G, D, B, A, H} // it’s a ck
{DEFG }+ = {D, E, F, G} // not a ck
{HEFG }+ = {H, E, F, G, B, C, D, A} // it’s a ck
Hence, BEFG, CEFG, HEFG are the candidate keys of the relation R.
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 47
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
As D can not be derived from any other attributes, so all possible
candidate keys must have attributes D.
As G never appears on LHS of any FD, but appears on RHS. So G is
not part of any key of R.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
As D can not be derived from any other attributes, so all possible
candidate keys must have attributes D.
As G never appears on LHS of any FD, but appears on RHS. So G is
not part of any key of R.
{D}+ = {D} // not a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
As D can not be derived from any other attributes, so all possible
candidate keys must have attributes D.
As G never appears on LHS of any FD, but appears on RHS. So G is
not part of any key of R.
{D}+ = {D} // not a ck
{DA}+ = {A, D, B, C, F, H, E, G} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
As D can not be derived from any other attributes, so all possible
candidate keys must have attributes D.
As G never appears on LHS of any FD, but appears on RHS. So G is
not part of any key of R.
{D}+ = {D} // not a ck
{DA}+ = {A, D, B, C, F, H, E, G} // it’s a ck
{DB}+ = {B, D, C, F, H, E, G, A} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
As D can not be derived from any other attributes, so all possible
candidate keys must have attributes D.
As G never appears on LHS of any FD, but appears on RHS. So G is
not part of any key of R.
{D}+ = {D} // not a ck
{DA}+ = {A, D, B, C, F, H, E, G} // it’s a ck
{DB}+ = {B, D, C, F, H, E, G, A} // it’s a ck
{DC }+ = {D, C} // not a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
As D can not be derived from any other attributes, so all possible
candidate keys must have attributes D.
As G never appears on LHS of any FD, but appears on RHS. So G is
not part of any key of R.
{D}+ = {D} // not a ck
{DA}+ = {A, D, B, C, F, H, E, G} // it’s a ck
{DB}+ = {B, D, C, F, H, E, G, A} // it’s a ck
{DC }+ = {D, C} // not a ck
{DE }+ = {D, E, A, B, C, F, H, G} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11
Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,
G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
As D can not be derived from any other attributes, so all possible
candidate keys must have attributes D.
As G never appears on LHS of any FD, but appears on RHS. So G is
not part of any key of R.
{D}+ = {D} // not a ck
{DA}+ = {A, D, B, C, F, H, E, G} // it’s a ck
{DB}+ = {B, D, C, F, H, E, G, A} // it’s a ck
{DC }+ = {D, C} // not a ck
{DE }+ = {D, E, A, B, C, F, H, G} // it’s a ck
{DF }+ = {D, F, E, G, A, B, C, H} // it’s a ck
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11
Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,
G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
As D can not be derived from any other attributes, so all possible
candidate keys must have attributes D.
As G never appears on LHS of any FD, but appears on RHS. So G is
not part of any key of R.
{D}+ = {D} // not a ck
{DA}+ = {A, D, B, C, F, H, E, G} // it’s a ck
{DB}+ = {B, D, C, F, H, E, G, A} // it’s a ck
{DC }+ = {D, C} // not a ck
{DE }+ = {D, E, A, B, C, F, H, G} // it’s a ck
{DF }+ = {D, F, E, G, A, B, C, H} // it’s a ck
{DH}+ = {D, H} // not a ck
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 48
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 49
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 49
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
Hence, DA, DB, DE, DF are the candidate keys of the relation R.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 49
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
Hence, DA, DB, DE, DF are the candidate keys of the relation R.
IS DCE is a candidate key?

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 49
Closure [Determining Candidate Key] - Example 11

Find all possible candidate keys of a relation scheme R(A, B, C, D, E, F,


G, H) with the following FDS = {CH → G, A → BC, B → CFH, E → A,
F → EG}.
Solution:
Hence, DA, DB, DE, DF are the candidate keys of the relation R.
IS DCE is a candidate key?
No, DCE is not a candidate key as its subset DE is the candidate key.
But DCE is the superkey.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 49
Prime and Non-Prime Attributes

Attributes of the relation which exist in at least one of the possible


candidate keys, are called prime or key attributes.
Attributes of the relation which does not exist in any of the possible
candidate keys of the relation, such attributes are called non-prime or
non-key attributes.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 50
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:
Since AD cannot be derived from any other attributes of R, so all the
possible candidate key must have attributes AD.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:
Since AD cannot be derived from any other attributes of R, so all the
possible candidate key must have attributes AD.
{AD}+ = {A, D} // not a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:
Since AD cannot be derived from any other attributes of R, so all the
possible candidate key must have attributes AD.
{AD}+ = {A, D} // not a ck
{ABD}+ = {A, B, D, C, E} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:
Since AD cannot be derived from any other attributes of R, so all the
possible candidate key must have attributes AD.
{AD}+ = {A, D} // not a ck
{ABD}+ = {A, B, D, C, E} // it’s a ck
{ADC }+ = {A, D, B, C, E} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:
Since AD cannot be derived from any other attributes of R, so all the
possible candidate key must have attributes AD.
{AD}+ = {A, D} // not a ck
{ABD}+ = {A, B, D, C, E} // it’s a ck
{ADC }+ = {A, D, B, C, E} // it’s a ck
{ADE }+ = {A, D, E, B, C} // it’s a ck

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:
Since AD cannot be derived from any other attributes of R, so all the
possible candidate key must have attributes AD.
{AD}+ = {A, D} // not a ck
{ABD}+ = {A, B, D, C, E} // it’s a ck
{ADC }+ = {A, D, B, C, E} // it’s a ck
{ADE }+ = {A, D, E, B, C} // it’s a ck
Hence ABD, ADC, ADE are the three possible keys of the given
relation R as their closure contain all the attributes of R.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12

Consider a relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:
Since AD cannot be derived from any other attributes of R, so all the
possible candidate key must have attributes AD.
{AD}+ = {A, D} // not a ck
{ABD}+ = {A, B, D, C, E} // it’s a ck
{ADC }+ = {A, D, B, C, E} // it’s a ck
{ADE }+ = {A, D, E, B, C} // it’s a ck
Hence ABD, ADC, ADE are the three possible keys of the given
relation R as their closure contain all the attributes of R.
PRIME ATTRIBUTES = {A, B, D, C, E}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure [Prime and Non-Prime Attributes] - Example 12
Consider a relation scheme R(A, B, C, D, E) with the following FDS =
{AB → C, DE → B, CD → E}. Find all possible candidate keys and prime
and non-prime attributes.
Solution:
Since AD cannot be derived from any other attributes of R, so all the
possible candidate key must have attributes AD.
{AD}+ = {A, D} // not a ck
{ABD}+ = {A, B, D, C, E} // it’s a ck
{ADC }+ = {A, D, B, C, E} // it’s a ck
{ADE }+ = {A, D, E, B, C} // it’s a ck
Hence ABD, ADC, ADE are the three possible keys of the given
relation R as their closure contain all the attributes of R.
PRIME ATTRIBUTES = {A, B, D, C, E}
NON-PRIME ATTRIBUTES = {ϕ}
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 51
Closure - Practice Exercise - 1

Consider the relation scheme R(A, B, C, D, E) with the following FDS =


{AB → C, C → D, B → EA}. Find all possible candidate keys and prime
and non-prime attributes.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 52
Closure - Practice Exercise - 2

Consider the relation scheme R(A, B, C, D). Find all possible candidate
keys of the relation R.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 53
Finding Equivalence Sets of FDs

Two sets of FDs F and G are equivalence if:


➔ Every FD in F can be inferred from G, and
➔ Every FD in G can be inferred from F
➔ Hence, F and G are equivalent (F = G) if F covers G and G covers F.
Definition (Covers):
➔ F covers G if every FD in G can be inferred from F.
Determine whether F covers G:
For each FD X → Y in G, calculate X + with respect to F, then check
whether X + ⊇ Y

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 54
Finding Equivalence Sets of FDs - Example 1

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 55
Finding Equivalence Sets of FDs - Example 2

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 56
Finding Equivalence Sets of FDs - Example 3

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 57
Canonical Cover / Minimal Cover
In any relational model, there exists a set of functional dependencies.
These functional dependencies when closely observed might contain
redundant attributes.
The ability of removing these redundant attributes without affecting
the capabilities of the functional dependency is known as “Canonical
Cover / Minimal Cover of Functional Dependency”.
Definition: A Canonical cover for a set of functional dependencies
(F) is another set of functional dependencies (FC ) such that all the
functional dependencies in F logically imply all the functional
dependencies in FC and vice versa.
Steps for finding minimal cover:
➔ Step 1: Singleton attribute on RHS [Decompose the functional
dependencies using Decomposition rule]
➔ Step 2: Remove extraneous attributes [Remove extraneous attributes
from LHS of functional dependencies by calculating the closure of FD’s
having two or more attributes on LHS]
➔ Step 3: Eliminate redundant FDs [Remove FD’s having transitivity]
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 58
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 59
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 59
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
Given FD = {A → BC, B → C, AB → D}
Step 1: All singleton attributes on RHS.
How? Decompose each functional dependency in F to have singleton
(single) attribute on the Right Hand Side (RHS).

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 59
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
Given FD = {A → BC, B → C, AB → D}
Step 1: All singleton attributes on RHS.
How? Decompose each functional dependency in F to have singleton
(single) attribute on the Right Hand Side (RHS).
Decompose, A → BC

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 59
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
Given FD = {A → BC, B → C, AB → D}
Step 1: All singleton attributes on RHS.
How? Decompose each functional dependency in F to have singleton
(single) attribute on the Right Hand Side (RHS).
Decompose, A → BC
A → B and A → C

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 59
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
Given FD = {A → BC, B → C, AB → D}
Step 1: All singleton attributes on RHS.
How? Decompose each functional dependency in F to have singleton
(single) attribute on the Right Hand Side (RHS).
Decompose, A → BC
A → B and A → C
FD1 = {A → B, A → C, B → C, AB → D}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 59
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD1 = {A → B, A → C, B → C, AB → D}
Step 2: Remove extraneous attributes.
How? By computing the closure of FD’s having two or more
attributes on LHS

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 60
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD1 = {A → B, A → C, B → C, AB → D}
Step 2: Remove extraneous attributes.
How? By computing the closure of FD’s having two or more
attributes on LHS
Check, AB → D

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 60
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD1 = {A → B, A → C, B → C, AB → D}
Step 2: Remove extraneous attributes.
How? By computing the closure of FD’s having two or more
attributes on LHS
Check, AB → D
To check A is extraneous in AB → D
B+ = {BC}. As A ∈ / {BC}, hence A is not extraneous.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 60
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD1 = {A → B, A → C, B → C, AB → D}
Step 2: Remove extraneous attributes.
How? By computing the closure of FD’s having two or more
attributes on LHS
Check, AB → D
To check A is extraneous in AB → D
B+ = {BC}. As A ∈ / {BC}, hence A is not extraneous.
To check B is extraneous in AB → D
A+ = {ABC}. As B ∈ {ABC}, hence B is extraneous.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 60
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD1 = {A → B, A → C, B → C, AB → D}
Step 2: Remove extraneous attributes.
How? By computing the closure of FD’s having two or more
attributes on LHS
Check, AB → D
To check A is extraneous in AB → D
B+ = {BC}. As A ∈ / {BC}, hence A is not extraneous.
To check B is extraneous in AB → D
A+ = {ABC}. As B ∈ {ABC}, hence B is extraneous.
Hence FD2 = {A → B, A → C, B → C, A → D}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 60
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD2 = {A → B, A → C, B → C, A → D}
Step 3: Remove redundant FDs
How? Remove FD’s having transitivity

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 61
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD2 = {A → B, A → C, B → C, A → D}
Step 3: Remove redundant FDs
How? Remove FD’s having transitivity
To check whether x → y is redundant in set of FDs F;
Exclude x → y from F to form another set of FDs F’.
Find x+ using F’. If x+ includes y, then x → y is redundant.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 61
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD2 = {A → B, A → C, B → C, A → D}
Step 3: Remove redundant FDs
How? Remove FD’s having transitivity
To check whether x → y is redundant in set of FDs F;
Exclude x → y from F to form another set of FDs F’.
Find x+ using F’. If x+ includes y, then x → y is redundant.
To check whether A → B is redundant;
Exclude A → B from F2 . We get F2 ’ = {A → C, B → C, A → D}
Find A+ using F2 ’, i.e., A+ = {ACD}
As the closure does not include B, the FD, A → B is not redundant.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 61
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD2 = {A → B, A → C, B → C, A → D}
Step 3: Remove redundant FDs
How? Remove FD’s having transitivity
To check whether A → C is redundant;
Exclude A → C from F2 . We get F2 ’ = {A → B, B → C, A → D}
Find A+ using F2 ’, i.e., A+ = {ABCD}
As the closure includes C, the FD, A → C is redundant and requires
to be removed.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 62
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD2 = {A → B, A → C, B → C, A → D}
Step 3: Remove redundant FDs
How? Remove FD’s having transitivity
To check whether A → C is redundant;
Exclude A → C from F2 . We get F2 ’ = {A → B, B → C, A → D}
Find A+ using F2 ’, i.e., A+ = {ABCD}
As the closure includes C, the FD, A → C is redundant and requires
to be removed.
Hence FD3 = {A → B, B → C, A → D}

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 62
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD3 = {A → B, B → C, A → D}
Step 3: Remove redundant FDs
How? Remove FD’s having transitivity
To check whether B → C is redundant;
Exclude B → C from F3 . We get F3 ’ = {A → B, A → D}
Find B+ using F3 ’, i.e., B+ = {B}
As the closure does not include C, the FD, B → C is not redundant.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 63
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD3 = {A → B, B → C, A → D}
Step 3: Remove redundant FDs
How? Remove FD’s having transitivity
To check whether B → C is redundant;
Exclude B → C from F3 . We get F3 ’ = {A → B, A → D}
Find B+ using F3 ’, i.e., B+ = {B}
As the closure does not include C, the FD, B → C is not redundant.
To check whether A → D is redundant;
Exclude A → D from F3 . We get F3 ’ = {A → B, B → C}
Find A+ using F3 ’, i.e., A+ = {ABC}
As the closure does not include D, the FD, A → D is not redundant.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 63
Canonical Cover / Minimal Cover - Example

Consider a relation R(A,B,C,D) having mentioned functional dependencies


FD = {A → BC, B → C, AB → D}. Find minimal cover.
Solution:
FD3 = {A → B, B → C, A → D} is the minimal (canonical) cover
for the set of functional dependencies FD = {A → BC, B → C, AB
→ D}.
Hence, FD3 = {A → BD, B → C} - on applying union rule
FD logically implies FD3 and FD3 logically implies F.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 64
Canonical Cover / Minimal Cover - Practice Exercises

1 Given a relational Schema R( A, B, C, D) and set of Function


Dependency FD = { B → A, AD → BC, C → ABD }. Find the
canonical cover?
2 Let the given set of FDs be E: {B → A, D → A, AB → D}. Find the
minimal cover of E.
3 Let the given set of FDs be G: {A → BCDE, CD → E}. Find the
canonical cover of G.
4 Given a relational Schema R( A, B, C) and set of Functional
Dependencies FD = {A → BC, B → C, A → B, AB → C}. Find the
minimal cover?

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 65
Canonical Cover / Minimal Cover

Example:
The following functional dependencies hold true for the relational scheme
R (W, X, Y, Z) –
X→W
WZ → XY
Y → WXZ
Write the irreducible equivalent for the given set of functional
dependencies.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 66
Canonical Cover / Minimal Cover

Solution:
STEP 1: Write all the functional dependencies such that each
dependency contains only one attribute on its right side i.e- X → W,
WZ → X, WZ → Y, Y → W, Y → X, Y → Z
STEP 2: Check each functional dependency one by one whether it is
essential or not.
For X → W:
Including X → W, (X) + = X, W
Ignoring X → W, (X) + = X
Now, as the two results are different, it is concluded that X → W is
essential and cannot be eliminated.

For WZ → X:
Including WZ → X, (WZ) + = W, X, Y, Z
Ignoring WZ → X, (WZ) + = W, X, Y, Z

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 67
Canonical Cover / Minimal Cover

Now, as the results are same, it is concluded that WZ → X is not


essential and can be eliminated. After eliminating WZ → X , the
resultant set of functional dependencies is : X → W, WZ → Y, Y →
W, Y → X, Y → Z
STEP 3: Continue the same process for the rest of FDs.
At the end, it will be observed that our essential functional dependencies
are -
X→W
WZ → Y
Y→X
Y→Z

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 68
Database Normalization

“Database Normalization” is a process or technique to reduce


attribute redundancy and functional dependency within the set of
tables present in any database.
It can be defined as a process of organizing the data in database to
avoid data redundancy, insertion anomaly, update anomaly & deletion
anomaly.
The process of decomposing unsatisfactory relations schema that do
not meet certain normal form tests are decomposed into smaller
relation schema that meet certain normal form tests(Desirable
Properties).
Normal form - Condition using keys and FDs of a relation to certify
whether a relation schema is in a particular normal form.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 69
Database Normalization

Database Normalization - Why it is Required?

Here in this table, Department, Dept ID, and Manager Name are the
attributes that are same for all the employees. This type of repetition
of data is called redundancy.
Is There Any Solution?

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 70
Database Normalization

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 71
Database Normalization

Goal:
➔ Satisfy the attribute preservation property.
➔ Satisfy the lossless join or non-additive join property.
➔ Satisfy the dependency preservation property.

Types of Normalization:
➔ 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)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 72
First Normal Form (1NF)

A relation is in the first normal form iff:


The domain of an attribute must include atomic values, and
The value of each attribute in a tuple must be a single value from the
domain of that attribute.
Disallows:
Composite attributes
Multi-valued attributes
nested relations; attributes whose values for an individual tuple are
non-atomic
Every relation is in 1NF by definition - If not, the database is termed
as a bad design.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 73
First Normal Form (1NF)

Example - 1:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 74
First Normal Form (1NF)

Example - 2:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 75
First Normal Form (1NF)

Example - 3:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 76
First Normal Form (1NF)

First Technique to Normalize in 1NF:


Create a separate relation DEPT-LOC for the multi-valued attribute
DLOC
The primary key of DEPT-INFO becomes the foreign key in
DEPT-LOC.
The primary key of DEPT-LOC is DLOC and DNO.
DEPT is decomposed into 1NF (DEPT-LOC & DEPT-INFO)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 77
First Normal Form (1NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 78
First Normal Form (1NF)

Second Technique to Normalize in 1NF:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 79
First Normal Form (1NF)

Third Technique to Normalize in 1NF:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 80
Second Normal Form (2NF)

Second normal form (2NF) is based on the concept of full functional


dependency.
A f.d x → y is a Full Functional Depedency(FFD), if removal of any
attribute from x means that the dependency does not hold any more.
if A ∈ x then {x - A} ↛ y
A relational schema R is in 2NF if each attribute A in R satisfies one
of the following criteria:
➔ The table must be in the first normal form.
➔ every non-prime attribute A in R is fully functionally dependent on the
primary key.
In other words, no non-prime attribute (not a part of any candidate
key) is dependent on a proper subset of any candidate key.
2NF tries to reduce redundant information.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 81
Second Normal Form (2NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 82
Second Normal Form (2NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 83
Second Normal Form (2NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 84
Second Normal Form (2NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 85
Second Normal Form (2NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 86
Third Normal Form (3NF)

Third normal form (3NF) is based on the concept of transitive


dependency.
According to Codd’s original definition, a relation schema R is in 3NF
if it satisfies the following:
➔ It has to be in a 2NF.
➔ There should be no transitivity dependency for non-prime attributes.

(or)
A relation schema R is in 3NF if, whenever a nontrivial functional
dependency x → y holds in R, then either
➔ x is a superkey of R or
➔ y is a prime attribute of R.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 87
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 88
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 89
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 90
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 91
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 92
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 93
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 94
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 95
Third Normal Form (3NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 96
Third Normal Form (3NF) - Practice Exercise

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 97
Boyce-Codd Normal form (BCNF)

Boyce-Codd Normal Form (BCNF) is the advanced version of the


third normal form (3NF).
According to the E.F. Codd, a relation is in Boyce-Codd normal form.
If it satisfies the following conditions:
A relation is in 3NF.
and for any non-trivial FD X → A holds in R, then X is a super key of
R.
It is simpler and stricter than 3NF.
BCNF is the stronger form of 3NF.
In simple words, it means, that for a dependency X → Y, X cannot be
a non-prime attribute, if Y is a prime attribute.
Every relation in BCNF is also in 3NF but a relation schema in 3NF is
not necessarily in BCNF.
It does not guarantee dependency preservation property.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 98
Boyce-Codd Normal form (BCNF)

Consider the relation schema LOTS which describes parcels of land


for sale in various counties of a state.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 99
Boyce-Codd Normal form (BCNF)

Consider the relation schema LOTS which describes parcels of land


for sale in various counties of a state.

Suppose that there are two candidate keys: Property id# and
{County name, Lot#}; that is, lot numbers are unique only within
each county, but Property id# numbers are unique across counties for
the entire state.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 99
Boyce-Codd Normal form (BCNF)

2NF

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 100
Boyce-Codd Normal form (BCNF)
2NF

3NF

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 100
Boyce-Codd Normal form (BCNF)

BCNF

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 101
Boyce-Codd Normal form (BCNF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 102
Boyce-Codd Normal form (BCNF)

The above picture shows the relation TEACH with the following
dependencies:
FD1: Student, Course → Instructor and FD2: Instructor → Course.
Student, Course is a candidate key for this relation.
This relation is in 3NF but not BCNF.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 103
Boyce-Codd Normal form (BCNF)

This relation schema may be decomposed into one of the three


following possible pairs:
1 R1 (Student, Instructor) and R2(Student, Course)
2 R1 (Course, Instructor) and R2(Course, Student)
3 R1 (Instructor, Course) and R2(Instructor, Student)
All three decompositions lose the functional dependency FD1.
We strive to meet two properties of decomposition during the
normalization process: the nonadditive join property and the
functional dependency preservation property.
We cannot meet the functional dependency preservation for any of
the above BCNF decompositions as seen above; but we must meet
the nonadditive join property.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 104
Boyce-Codd Normal form (BCNF)

NJB (Nonadditive Join Test for Binary Decompositions):


decomposition D = {R1, R2} of R has the lossless (nonadditive) join
property with respect to a set of functional dependencies F on R if
and only if either
The FD ((R1 ∩ R2) → (R1 - R2)) is in F+ , or
The FD ((R1 ∩ R2) → (R2 - R1)) is in F+
If we apply this test to the above three decompositions, we find that
only the third decomposition meets the test.
Hence, the proper decomposition of TEACH into BCNF relations is:
TEACH1 (Instructor, Course) and TEACH2 (Instructor, Student)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 105
Properties of a Relational Decomposition

As already discussed, there are 3 properties of a relational decomposition.


Attribute Preservation
Dependency Preservation
Lossless Join

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 106
Properties of a Relational Decomposition

Attribute Preservation
Consider a Universal relation schema R = A1 , A2 , ..., An that includes
all the attributes of database.
Let F be the set of functional dependencies that hold on the
attributes of R.
Suppose that the universal schema R has decomposed into a set of
relations Ri in the decomposition set D so that no attributes are lost.
m R =R
Let D = R1, R2,. . . . . . , Rm Then Ui=1 i

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 107
Properties of a Relational Decomposition

Dependency Preservation
Each functional dependency x → y specified in F either appears
directly in one of the relations schemas Ri in the decomposition set D
or could be inferred from the dependencies that appear in Ri
(F1 ∪ F2 ∪ ..., ∪ Fn )+ ≡ F +
It is always possible to find a dependency preservation decomposition
D with respect to F such that each relation Ri in D is in 3NF.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 108
Properties of a Relational Decomposition

Lossless or Non-additive Join Property


Ensures that no spurious tuples are generated when a natural join
operation is applied to the relations in the decomposition set, i.e.,
R1 ∗ R2 ∗ .... ∗ Rm = R
The word in lossless refers to loss of information, alternatively known
as addition of spurious tuples.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 109
Lossless or Non-additive Join Property - Example

Consider the following relational schema R(A, B, C, D, E, F, G, H, I, J)


with the following fds F = {AB → C, A → DE, B → F, F → GH, D →
IJ} and D = {R1 , R2 , R3 , R4 , R5 }, where R1 = (A,B,C), R2 = (A,D,E), R3
= (B,F), R4 = (F,G,H) and R5 = (D,I,J). Check whether the given
decomposition is lossless or not.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 110
Lossless or Non-additive Join Property - Example

Consider the following relational schema R(A, B, C, D, E, F, G, H, I, J)


with the following fds F = {AB → C, A → DE, B → F, F → GH, D →
IJ} and D = {R1 , R2 , R3 , R4 , R5 }, where R1 = (A,B,C), R2 = (A,D,E), R3
= (B,F), R4 = (F,G,H) and R5 = (D,I,J). Check whether the given
decomposition is lossless or not.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 110
Lossless or Non-additive Join Property - Example
Consider the following relational schema R(A, B, C, D, E, F, G, H, I, J)
with the following fds F = {AB → C, A → DE, B → F, F → GH, D →
IJ} and D = {R1 , R2 , R3 , R4 , R5 }, where R1 = (A,B,C), R2 = (A,D,E), R3
= (B,F), R4 = (F,G,H) and R5 = (D,I,J). Check whether the given
decomposition is lossless or not.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 110
Lossless or Non-additive Join Property - Example

Consider the following relational schema R(A, B, C, D, E, F, G, H, I, J)


with the following fds F = {AB → C, A → DE, B → F, F → GH, D →
IJ} and D = {R1 , R2 , R3 }, where R1 = (A,B,C,D,E), R2 = (B,F,G,H), R3
= (D,I,J). Check whether the given decomposition is lossless or not.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 111
Lossless or Non-additive Join Property - Example

Consider the following relational schema R(A, B, C, D, E, F, G, H, I, J)


with the following fds F = {AB → C, A → DE, B → F, F → GH, D →
IJ} and D = {R1 , R2 , R3 }, where R1 = (A,B,C,D,E), R2 = (B,F,G,H), R3
= (D,I,J). Check whether the given decomposition is lossless or not.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 111
Lossless or Non-additive Join Property - Example

Consider the following relational schema R(A, B, C, D, E, F, G, H, I, J)


with the following fds F = {AB → C, A → DE, B → F, F → GH, D →
IJ} and D = {R1 , R2 , R3 }, where R1 = (A,B,C,D,E), R2 = (B,F,G,H), R3
= (D,I,J). Check whether the given decomposition is lossless or not.
Solution:

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 111
Lossless or Non-additive Join Property - Example
For a decomposition to be lossless, it should hold the following conditions:
Union of attributes of R1 and R2 must be equal to attribute R. each
attribute of R must be either in R1 or in R2 i.e., Att(R1) ∪ Att(R2)
= Att(R)
Intersection of attributes of R1 and R2 must not be null i.e., Att(R1)
∩ Att(R2) ̸= ϕ
Common attribute must be a key for atleast one relation(R1 or R2)
i.e., Att(R1) ∩ Att(R2) → Att(R1) or Att(R1) ∩ Att(R2) → Att(R2)
A relation R(A,B,C,D) with FD set A → BC is decomposed into R1(ABC)
and R2(AD). This is lossless join decomposition because:
First rule holds true as Att(R1) ∪ Att(R2)=(ABC) ∪ (AD)= (ABCD)
= Att(R)
Second rule holds true as Att(R1) ∩ Att(R2) = (ABC) ∩ (AD) ̸= ϕ
Third rule holds true as Att(R1) ∩ Att(R2) = A is a key of R1(ABC)
because A → BC is given
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 112
Fourth Normal Form (4NF)

A relation will be in 4NF if it is in Boyce Codd normal form and has


no multi-valued dependency.
For a dependency A → B, if for a single value of A, multiple values of
B exist, then the relation will be a multi-valued dependency.
➔ To understand how 4NF works it is necessary to understand
multi-valued dependency.
➔ And, for a relation, R(A,B,C), if there is a multi-valued dependency
between, A and B, then B and C should be independent of each other.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 113
Fourth Normal Form (4NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 114
Fourth Normal Form (4NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 115
Fifth Normal Form (5NF)

A database is said to be in 5NF, if and only if,


It’s in 4NF
If we can decompose table further to eliminate redundancy and
anomaly, and when we re-join the decomposed tables by means of
candidate keys, we should not be losing the original data or any new
record set should not arise.
In simple words, joining two or more decomposed table should not
lose records nor create new records.
The 5NF (Fifth Normal Form) is also known as project-join normal
form.
In other words, it can be said that a 5NF table should not have join
dependency. If the table is having join dependency then it should be
broken into smaller tables.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 116
Fifth Normal Form (5NF)

The above Supplier-Product-Customer table is in 4th normal form.


But still there exists anomalies. The above table is defined by ternary
relationship among supplier,product and customers.
A single supplier can supply a product which will be used by more
than one customers.
A customer can buy two or more products from a single supplier.
A product used by a customer can be supplied by more then one
supplier.
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 117
Fifth Normal Form (5NF)

How to eliminate join dependency ? Join dependency is converted to


separate tables.

The simplest solution to eliminate join dependency from the above


table is to break the table into 3 binary one-one relationships.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 118
Fifth Normal Form (5NF)

When we combine the above three tables, the resultant table will be
the original SPC table.
But this might not be true in all cases i.e., when we combine the
separated tables, the resultant will not be equivalent to the original
table, in that case we should not break down the original table.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 119
Practice Question (4NF & 5NF)

Consider a Student table which has information about the subjects and the
activity the students have enrolled in. Subject and Activity are the two
attributes that are independent of each other.
1 Check whether the given table is in 4NF? If not, partition the table
and convert to 4NF.
2 If the partition tables are in 4NF, check whether it is in 5NF?

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 120
Practice Question (4NF & 5NF)
Solution (i):
The table consists of multivalue dependency since all the column of
the table has duplicate values and the Subject ad Activity are
independent.
Hence, Student↠Subject and Student↠Activity exists in the table.
All the attributes of the table act as key.
So the Given table is not in 4NF.
So decompose the table R into R1(Student, Subject) and R2(Student,
Activity). In both the decomposed table, all attributes are key.
Now, the table R1 and R2 is in 4NF.
Solution (ii):
If above partition is considered then it is not in 5NF.
We decompose the table into R1, R2, and R3 such as R1(Student,
Subject), R2(Student, Activity) and R3(Subject, Activity).
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 121
Practice Question (4NF & 5NF)

Hence the table are in 4NF.


To check R1, R2 and R3 are in 5NF, it should satisfy, R1 ▷◁ R2 ▷◁ R3
≡R
Perform R1 ▷◁Subject R3
Then, perform (R1 ▷◁Subject R3) ▷◁Activity R2.
We will get R1 ▷◁ R2 ▷◁ R3 ≡ R
Hence R1, R2 and R3 are in 5NF.

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 122
Practice Question (4NF & 5NF)

Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 123
Dr. Shashank Mouli Satapathy VIT - SCOPE - Database Systems BCSE302L - Module 3 September 3, 2024 124

You might also like