0% found this document useful (0 votes)
14 views49 pages

DBMS 13-16

The document provides an overview of normalization in database management systems, detailing the different normal forms (1NF, 2NF) and their requirements. It explains the concepts of candidate keys, prime attributes, and functional dependencies, along with examples to illustrate how to achieve normalization. The focus is on eliminating redundancy and ensuring data consistency through systematic organization of data.
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)
14 views49 pages

DBMS 13-16

The document provides an overview of normalization in database management systems, detailing the different normal forms (1NF, 2NF) and their requirements. It explains the concepts of candidate keys, prime attributes, and functional dependencies, along with examples to illustrate how to achieve normalization. The focus is on eliminating redundancy and ensuring data consistency through systematic organization of data.
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/ 49

2/12/2025

Database Management Systems


Dr. Dev Narayan Yadav
Department of CSE, NIT Rourkela
Email: [email protected]
Mo. – 8349869748
Room – CS204

Department of CSE, National Institute of Technology Rourkela

Normalization and Decomposition

Department of CSE, National Institute of Technology Rourkela

1
2/12/2025

Normalization
 Normalization is a systematic approach to organize data in a
database to eliminate redundancy, avoid anomalies and ensure data
consistency.
• Normal Forms:
• 1NF 1NF
• 2NF 2NF

• 3NF 3NF

• BCNF
BCNF

Department of CSE, National Institute of Technology Rourkela

1st Normal Form (1NF)


 The initial step of normalization.
 By default when you convert an E-R diagram to relations it will
be in 1NF.
 The relation is said to be in 1NF if:
• Each cell in a table contains atomic values.
• Each column of a relation have unique names.
• Every relation have a primary key.

Department of CSE, National Institute of Technology Rourkela

2
2/12/2025

1st Normal Form (1NF)

Un-Normalized

SID SName CName


101 Vineet DBMS, C++
102 Ayush ALGO
103 Surya Micro

Department of CSE, National Institute of Technology Rourkela

1st Normal Form (1NF)


1NF
Un-Normalized
SID SName CName
SID SName CName
101 Vineet DBMS
101 Vineet DBMS, C++
101 Vineet C++
102 Ayush ALGO
102 Ayush ALGO
103 Surya Micro
103 Surya Micro

SID SName CName1 CNa


SID SName SID CName me2

101 Vineet 101 DBMS 101 Vineet DBMS C++


102 Ayush 101 C++ 102 Ayush ALGO Null
103 Surya 102 ALGO 103 Surya Micro Null
103 Micro
Department of CSE, National Institute of Technology Rourkela

3
2/12/2025

2nd Normal Form (2NF)


 The relation R is said to be in 2NF if:
• Relation R is in 1NF.
• R should not contain any partial dependency (every non-prime
attributes should be fully dependent upon candidate key).

 In simple word “each column should be directly related to the


primary key, and not to other columns.”

 How to achieve 2NF?


• Identify composite key
• Locate partial dependency
• Decompose table/relation

Department of CSE, National Institute of Technology Rourkela

2nd Normal Form (2NF)


 Super Keys: A super key is a unique set of attribute(s) that
determine the set of other attributes in a relation.

EID SID SName CID CName


 Super Keys: {EID}, {SID, CID},
1 101 Vineet CS101 DBMS
{SID, CID, SName }, {EID, SID}, etc. 2 101 Vineet CS103 Micro
3 102 Ayush CS102 C++
 Invalid: {SID} {CID, CName} 4 102 Ayush CS101 DBMS
5 103 Surya CS103 Micro
6 103 Surya CS102 C++

Department of CSE, National Institute of Technology Rourkela

4
2/12/2025

2nd Normal Form (2NF)


 Super Keys: {EID}, {SID, CID}, {SID, CID, SName }, {EID, SID}, etc.
 Candidate Key: is a minimal super key ( removing any attribute
from a candidate key will not retain its ability to uniquely
determine other attributes)

EID SID SName CID CName


1 101 Vineet CS101 DBMS
 Candidate Keys: {EID}, {SID, CID}
2 101 Vineet CS103 Micro
3 102 Ayush CS102 C++
4 102 Ayush CS101 DBMS
5 103 Surya CS103 Micro
6 103 Surya CS102 C++

Department of CSE, National Institute of Technology Rourkela

2nd Normal Form (2NF)


 Candidate Keys: {EID}, {SID, CID}.
 Prime Attribute: an attribute which is part of candidate key
attribute.
 Non-Prime Attribute: an attribute which is not part of any of the
candidate key.
EID SID SName CID CName
1 101 Vineet CS101 DBMS
2 101 Vineet CS103 Micro
3 102 Ayush CS102 C++
 Prime Attributes: EID, SID, CID 4 102 Ayush CS101 DBMS
 Non-Prime Attributes: SName, CName 5 103 Surya CS103 Micro
6 103 Surya CS102 C++

Department of CSE, National Institute of Technology Rourkela

5
2/12/2025

2nd Normal Form (2NF)


EID SID SName CID CName
 Candidate Keys: {EID}, {SID, CID}.
1 101 Vineet CS101 DBMS
 Prime Attributes: EID, SID, CID 2 101 Vineet CS103 Micro
 Non-Prime Attributes: SName, CName 3 102 Ayush CS102 C++
4 102 Ayush CS101 DBMS
5 103 Surya CS103 Micro
6 103 Surya CS102 C++
 Fully Functional Dependency: a non-prime attribute depends on
the entire candidate key, not just part of it.
• EIDSID
• EIDCID
• EIDCName
• EIDSname
• {SID, CID } {SName, CName}

Department of CSE, National Institute of Technology Rourkela

2nd Normal Form (2NF)


EID SID SName CID CName
 Candidate Keys: {EID}, {SID, CID}.
1 101 Vineet CS101 DBMS
 Prime Attributes: EID, SID, CID 2 101 Vineet CS103 Micro
 Non-Prime Attributes: SName, CName 3 102 Ayush CS102 C++
4 102 Ayush CS101 DBMS
5 103 Surya CS103 Micro
6 103 Surya CS102 C++
 Partial Functional Dependency: If the proper subset of the
candidate key determines a non-prime attribute, it is called partial
dependency.
• SIDSName {SName only depends on SID}
• CIDCName {CName only depends on CID}

Department of CSE, National Institute of Technology Rourkela

6
2/12/2025

2nd Normal Form (2NF)


 Remove Partial dependency: Create separate table for partial
dependencies, and retain original relation.
CID CName
CS101 DBMS
EID SID SName CID CName
CS102 C++
1 101 Vineet CS101 DBMS
CS103 Micro
2 101 Vineet CS103 Micro
3 102 Ayush CS102 C++
SID SName
4 102 Ayush CS101 DBMS
101 Vineet
5 103 Surya CS103 Micro
102 Ayush
6 103 Surya CS102 C++ EID SID CID
103 Surya
1 101 CS101
2 101 CS103
3 102 CS102
4 102 CS101
5 103 CS103
6 103 CS102
Department of CSE, National Institute of Technology Rourkela

2nd Normal Form (2NF)


 Now Check all relations.

CID CName
CS101 DBMS
EID SID SName CID CName
CS102 C++
1 101 Vineet CS101 DBMS
CS103 Micro
2 101 Vineet CS103 Micro
3 102 Ayush CS102 C++
SID SName
4 102 Ayush CS101 DBMS
101 Vineet
5 103 Surya CS103 Micro
102 Ayush
6 103 Surya CS102 C++ EID SID CID
103 Surya
1 101 CS101
2 101 CS103
3 102 CS102
4 102 CS101
5 103 CS103
6 103 CS102
Department of CSE, National Institute of Technology Rourkela

7
2/12/2025

2nd Normal Form (2NF)


 IF R(A, B, C, D)
• ABCD
• Candidate Key: {AB}
• Prime Attribute: A, B
• Non-Prime Attribute: C, D

 D is completely dependent on key?


• Yes, fully dependency.
 C is completely dependent on key?
• Yes, Full dependency.

Department of CSE, National Institute of Technology Rourkela

2nd Normal Form (2NF)


 IF R(A, B, C, D)
• ABD, AC
• Candidate Key: {AB}
• Prime Attribute: A, B
• Non-Prime Attribute: C, D

 D is completely dependent on key?


• Yes, fully dependency.
 C is completely dependent on key?
• No, {C is dependent on subset of candidate key AB}, partial
dependency.

Department of CSE, National Institute of Technology Rourkela

8
2/12/2025

2nd Normal Form (2NF)


 IF R(A, B, C)
• BC
• Candidate Key  {AB}
• Prime Attribute: A, B
• Non-Prime Attribute: C

 C is completely dependent on key?


• No, {C is dependent on subset of candidate key AB}, partial
dependency.

Department of CSE, National Institute of Technology Rourkela

2nd Normal Form (2NF)


 IF R(A, B, C, D)
• AB, BC, CD, DA
• Candidate Key: {A} {B} {C}, {D}
• Prime Attribute: A, B, C, D
• Non-Prime Attribute: {Null}

Department of CSE, National Institute of Technology Rourkela

9
2/12/2025

2nd Normal Form (2NF)


 IF R(A, B, C, D, E)
• AB, BCD, FC, DA
• Candidate Key: {AE} {DE} {BE}
• Prime Attribute: A, B, D, E
• Non-Prime Attribute: C

Department of CSE, National Institute of Technology Rourkela

2nd Normal Form (2NF)


 IF R(A, B, C, C)
• AB, BC, CD
• Candidate Key  {A}
• Prime Attribute: A
• Non-Prime Attribute: B, C, D

 C is completely dependent on key?


• No, {C is dependent on subset of candidate key AB}, partial
dependency.

Department of CSE, National Institute of Technology Rourkela

10
2/12/2025

2nd Normal Form (2NF)


 IF R(A, B, C) A B C A B
• BC a 1 x a 1 B C
b 2 y b 2
• Composite Key  AB 1 x
a 3 z a 3 2 y
• Prime Attribute: A, B c 3 z c 3 3 z
• Non-Prime Attribute: C d 3 z d 3
e 3 z e 3

 C is completely dependent on key?


• No, {C is dependent on subset of candidate key AB}, partial
dependency.

Department of CSE, National Institute of Technology Rourkela

2nd Normal Form (2NF)


 IF R(A, B, C, D)
• AB, BC, CD, DA
• Composite Key  AB
• Prime Attribute: A, B
• Non-Prime Attribute: C

 C is completely dependent on key?


• No, {C is dependent on subset of candidate key AB}, partial
dependency.

Department of CSE, National Institute of Technology Rourkela

11
2/12/2025

2nd Normal Form (2NF)


 R(A, B, C, D, E, F, G, H)
• AB, CDE, EFG, GH, ACABCDEFG

 Candidate Keys:
• AC
 Non-Prime Attributes:
• B,D,E,F,G,H
 Partial Dependency:
• AB, CDE
 Decomposition
• One table for AB,
• Another table for CDE
• And the main table.

Department of CSE, National Institute of Technology Rourkela

Department of CSE, National Institute of Technology Rourkela

12
2/12/2025

Normalization Example: 1
• Is the given relation is in 1NF?
• Is the given relation is in 2NF?

SID SName CID CName Prof.


101 Vineet CS101 DBMS DNY
101 Vineet CS102 Algo SP
102 Ayush CS101 DBMS DNY
102 Ayush CS103 Python PD

• Candidate Key: (SID, CID)


• Functional Dependencies: SID  SName, CID  CName, Prof.
• Prime Attribute: SID, CID
• Non-Prime Attribute: SName, CName, Prof.
• Is there any partial dependencies: No

Department of CSE, National Institute of Technology Rourkela

Normalization Example: 1
• Is the table is redundant?

SID SName CID CName Prof.


101 Vineet CS101 DBMS DNY
101 Vineet CS102 Algo SP
102 Ayush CS101 DBMS DNY
102 Ayush CS103 Python PD

• Why it can be problematic if the table is redundant: Anamolies.


• Type of Anamolies: Insertion, Deletion and Update Anamolies.
• Insertion: Cannot insert a course unless at least one student is enrolled.
• Updation: Any change in course name, instructor, must be reflected in
all rows.
• Deletion: Deletion a record (last one) delete the course detail.

Department of CSE, National Institute of Technology Rourkela

13
2/12/2025

Example 2
 IF R(A, B, C) A B C
• BC a 1 x
• Is the table is in 1NF? b 2 y
a 3 z
• Is the table is in 2NF?
c 3 z
• Candidate Key: AB
d 3 z
• Prime Attribute: A, B e 3 z
• Non-Prime Attribute: C
• Is there any partial dependencies exist?

Department of CSE, National Institute of Technology Rourkela

Example 2
 IF R(A, B, C)
• BC
• How we can Normalize the table into 2NF.

A B C A B
a 1 x a 1 B C
b 2 y b 2 1 x
a 3 z a 3 2 y
c 3 z c 3 3 z
d 3 z d 3
e 3 z e 3

Department of CSE, National Institute of Technology Rourkela

14
2/12/2025

Department of CSE, National Institute of Technology Rourkela

3rd Normal Form (3NF)


 The relation R is said to be in 3NF if:
• Relation R is in 2NF.
• There should be no transitive dependency in R.
 A relational schema is said be in 3NF if every functional
dependency AB in R; either A is super key or candidate key or
B is the prime attribute.

 Transitive Dependency: A functional dependency from non-


prime attribute to non-prime attribute is called transitive functional
dependency.

 How to achieve 3NF?


• Identify transitive dependency
• Decompose table/relation

Department of CSE, National Institute of Technology Rourkela

15
2/12/2025

3rd Normal Form (3NF)


 R (SID, State, City), FD: {SIDState, StateCity}
 Candidate Key: SID
SID State City
 Prime Attribute: SID
101 OD BBS
 Non-Prime Attributes: State, City 102 HR Ambala
103 OD Bhadrak
 Partial Dependency: No 104 CG Durg
 Transitive Dependency: StateCity 105 CG Raipur
106 OD BBS
107 CG Raipur

 Prime  Non Prime {No Problem}


 Non-Prime Prime {No Problem}
 Non-Prime  Non-Prime {Transitive Dependency}

Department of CSE, National Institute of Technology Rourkela

3rd Normal Form (3NF)


 Remove transitive dependency:

SID State City SID City


101 OD BBS 101 BBS State City
102 HR Ambala 102 Ambala OD BBS
103 OD Bhadrak 103 Bhadrak HR Ambala
104 CG Durg 104 Durg OD Bhadrak
105 CG Raipur 105 Raipur CG Durg
106 OD BBS 106 BBS CG Raipur
107 CG Raipur 107 Raipur

Department of CSE, National Institute of Technology Rourkela

16
2/12/2025

Normalization Example: 1
• What are the transitive dependency in this table?
• SID  SName : Why? SID is part of composite key, but not the both
attributes?
• CID  CName, Prof. : Same as above.

SID SName CID CName Prof.


101 Vineet CS101 DBMS DNY
101 Vineet CS102 Algo SP
102 Ayush CS101 DBMS DNY
102 Ayush CS103 Python PD

Department of CSE, National Institute of Technology Rourkela

Normalization Example: 1
• How it will be converted o 3NF?
SID SName CID CName Prof.
101 Vineet CS101 DBMS DNY
101 Vineet CS102 Algo SP
102 Ayush CS101 DBMS DNY
102 Ayush CS103 Python PD

SID SName CID CName Prof. SID CID


101 Vineet CS101 DBMS DNY 101 CS101
101 Vineet CS102 Algo SP 101 CS102
102 Ayush CS101 DBMS DNY 102 CS101
102 Ayush CS103 Python PD 102 CS103

Department of CSE, National Institute of Technology Rourkela

17
2/12/2025

Normalization Example: 1
• R (A, B, C, D)
• AB  CD, DA

• What are the candidate keys: AB, BD


• Prime Attribute: A, B, D
• Non-Prime Attribute: C
• Is there any partial dependencies: No
• Transitive Dependency: No

• Remember the rule:

• If LHS of all FDs are Either Super Key or Candidate Key


• OR RHS is a Prime Attribute.

Department of CSE, National Institute of Technology Rourkela

Boyce-Codd Normal Form (BCNF)


 3NF: LHS of all FDs are Either Super Key or Candidate Key OR
RHS is a Prime Attribute.
 Special case of 3NF
 The relation R is said to be in BCNF if:
• Relation R is in 3NF.
• There should be no transitive dependency in R.

 For every functional dependency XY, X must be a super


key/candidate key (the or part is removed).

Department of CSE, National Institute of Technology Rourkela

18
2/12/2025

BCNF
 Candidate Key: {SID}, {VID}
 FD = {SID  SName, SID  VID, VID  age, VID  SID}
 Check for the condition: For each FD, LHS should be Super Key
or Candidate Key.
SID SName VID Age
101 Ravi V01 20
102 Varun V02 19
103 Ravi V03 21
104 Rahul V04 22

Department of CSE, National Institute of Technology Rourkela

BCNF Example
• R (A, B, C, D)
• AB  CD, DA

• R(ABCD) will divided into R1(D,A), R2(B, C, D)

Department of CSE, National Institute of Technology Rourkela

19
2/12/2025

BCNF Example 2
• R (A, B, C)
• AB  C, CB

• What are the candidate keys: AB, BC

• If LHS of all FDs are Either Super Key or Candidate Key

• R(A, B, C)  R1(A,B); R2(C,B)

Department of CSE, National Institute of Technology Rourkela

Question
Q1. R(A< B, C, D, E, F, G, H, I ,J); FD {ABC, ADE, BF, FGH,
DIJ }
• Keys?
• Decompose it to 2NF

Department of CSE, National Institute of Technology Rourkela

20
2/12/2025

Decomposition Rule
 Decomposition should be lossless: (No data loss: fulfilled by 1NF,
2NF, 3NF, BCNF)
 Dependency should be preserved (Sometime not fulfilled by
BCNF).

Department of CSE, National Institute of Technology Rourkela

Decomposition Example
• R (A, B, C, D)
• AB  CD, DA

• R(ABCD) will divided into R1(D,A), R2(B, C, D)

• In R1 we have DA, but what about ABCD? It is not available in


both relations.

Department of CSE, National Institute of Technology Rourkela

21
2/12/2025

Questions
 When we can conclude that the relation is in 1NF?
 How to convert a relation into 1NF?
 When we can conclude that any relation is in 2NF?
 What is partial dependency?
 How to convert a relation into 2NF?
 When we can conclude that the relation is in 3NF?
 What is transitive dependency?
 When to say that the relation is in BCNF?
 What is non-trivial dependency?
 Consider a relation R(A, B, C, D), the primary kay for the relation
is {AB}, is that possible that value of A or B can be null?

Department of CSE, National Institute of Technology Rourkela

Questions
 The first reason we have already discussed (we will have many
redundant data which can cause Anamolies)
 It is possible that the dependency given for the relation may not
hold for some instances.
 Consider a relation R(A, B, C, D) and FD = {AB  D, BC}
 The candidate key for this relation is AB, the same will be primary
key.
 The only condition for primary key is it should be unique.
 Thus the value of either A or B can be null, If the value of B is null
the dependency BC will be void.

Department of CSE, National Institute of Technology Rourkela

22
2/12/2025

Questions
 Consider a relation R(A, B, C, D) and FD = {AB  C, CD}
 What will be candidate key and primary key for the relation?
 Is the relation is in 2NF or not?
 Is the relation is in 3NF?
 What about BCNF?
 What is the problem if the relation is not in 3NF?
• Again for the first dependency AB C; AB combined is a primary
key at least one of them will be not null; thus for sure this
dependency will hold.
• But what about CD; C may become null, and thus AB may not
reach to D.
• R1(A, B, C) & R2(C, D)

Department of CSE, National Institute of Technology Rourkela

Questions
 Consider a relation R(A, B, C, D, E) and FD = {A  C, BE
CD}
 What will be candidate key and primary key for the relation?
 Is the relation is in 2NF or not?
 Is the relation is in 3NF?
 What about BCNF?
 How many relations we will get after converting this relation to
3NF?

Department of CSE, National Institute of Technology Rourkela

23
2/12/2025

Questions
 Consider a relation R(A, B, C) and FD = {AB  C, CB}
 What will be candidate key and primary key for the relation?
 Is the relation is in 2NF?
 Is the relation is in 3NF?
 Is the relation is in BCNF?
 Relations after decomposition?

Department of CSE, National Institute of Technology Rourkela

Questions
 If you are asked to identify NF of a relation then from which NF
(1NF, 2NF, 3NF, BCNF) will you start and why?
 Identify normal forms for this relations.
 R(ABCEFGH), FD = {ABC, ADE, BF, FGH}
• 1NF
 R(ABCDEF), FD = {ABC, DCAE, EF}
• 1NF
 R(ABCDEF), FD = {ABC, DCAE, EF}
• 1NF
 R (ABCDEFGHI), FD = {AB C, BDEF, AD GH, AI}
• 1NF
 R (ABCDE), FD = {ABCD, DA, BCDE}
• 3NF

Department of CSE, National Institute of Technology Rourkela

24
2/12/2025

Questions
 Identify normal forms for this relations.
 R (ABCDE), FD = {BCADE, DB}
• 3NF
 R(VWXYZ), FD = {XYV, YZ, ZY, VWX}
• 1NF
 R(ABCDEF), FD = {ABCD, ABDE, CD F, CDF  B, BF
 D}
• 1NF
 R(ABC), FD = {AB, BC, CA} [GATE]
• BCNF

Department of CSE, National Institute of Technology Rourkela

GATE Questions

Department of CSE, National Institute of Technology Rourkela

25
2/12/2025

GATE CSE 2013


 R (ABCDEFGH), FD = {CHG, ABC, BCFH, EA,
FEG}
 The relation is in which normal form

Department of CSE, National Institute of Technology Rourkela

GATE CSE 2024


 Which of the following is true if the relation is in 1NF?
 R can have multi-attribute key.
 R cannot have a foreign key.
 R cannot have composite attribute.
 R cannot have more than one candidate key.

Department of CSE, National Institute of Technology Rourkela

26
2/12/2025

GATE CSE 2012

Department of CSE, National Institute of Technology Rourkela

GATE CSE 2008

Department of CSE, National Institute of Technology Rourkela

27
2/12/2025

GATE CSE 2008

Department of CSE, National Institute of Technology Rourkela

Department of CSE, National Institute of Technology Rourkela

28
2/12/2025

Department of CSE, National Institute of Technology Rourkela

Department of CSE, National Institute of Technology Rourkela

29
2/12/2025

Department of CSE, National Institute of Technology Rourkela

Department of CSE, National Institute of Technology Rourkela

30
2/12/2025

Department of CSE, National Institute of Technology Rourkela

Department of CSE, National Institute of Technology Rourkela

31
2/12/2025

Department of CSE, National Institute of Technology Rourkela

Department of CSE, National Institute of Technology Rourkela

32
2/12/2025

Department of CSE, National Institute of Technology Rourkela

Department of CSE, National Institute of Technology Rourkela

33
2/12/2025

Decomposition

Department of CSE, National Institute of Technology Rourkela

Decomposition
 Normalization: decomposition of tables in smaller table.
 Rule-1 (Mandatory): Decomposition should be Lossless.
• Lossless: if we combine the child table we must get parent table.
• Lossy: if we do not get the parent table (actual tuple) then lossy.
• Problem with lossy decomposition: (a) we may not get original tuple.
(b) We may get redundant tuple.

 Rule 2 (Optional): Decomposition should preserve original


dependency.

Department of CSE, National Institute of Technology Rourkela

34
2/12/2025

Lossless Decomposition
 If a relation R is decomposed into two relations R1 and R2, then
the decomposition will be lossless iff:
a. Attribute(R1) ∪ Attribute(R2) = Attribute (R)  An attribute must
be present in at least one table.
b. Attribute(R1) ∩ Attribute (R2) != Ø  There must be a common
attribute between the decomposed relations.
c. Attribute(R1) ∩ Attribute(R2)  Attribute (R1) or Attribute (R1)
∩ Attribute (R2)  Attribute (R2)  the common attribute must
be a candidate key in one of the decomposed relation.

Department of CSE, National Institute of Technology Rourkela

Decomposition
 Condition (a): Attribute(R1) ∪ Attribute(R2) = Attribute (R) 
An attribute must be present in at least one table.

 We will only get the attributes A B and C if we combine the


decomposed relation.
A B
1 2
2 2
A B C D 3 3
1 2 1 X
2 2 2 Y
3 3 2 Z C
1
2
2

Department of CSE, National Institute of Technology Rourkela

35
2/12/2025

Decomposition
 Condition (b): Attribute(R1) ∩ Attribute (R2) != Ø  There
must be at least one common attribute between the decomposed
relations.
 Query: find the value of C if the value of a is 1.
 We cannot write an equivalent query for this as there is no
common attribute for checking.
A B
1 2
2 2
A B C D 3 3
1 2 1 X
2 2 2 Y
3 3 2 Z C D
1 X
2 Y
2 Z

Department of CSE, National Institute of Technology Rourkela

Decomposition
 Condition (b): Attribute(R1) ∩ Attribute (R2) != Ø  There
must be at least one common attribute between the decomposed
relations.
 Query: find the value of C if the value of a is 1.
Select R2.C from R2 Natural Join Where R1.A = 1.
A B
A B B C
1 2
1 2 2 1
A B C 2 2
1 2 2 2
A B C 3 3
1 2 3 2 1 2 1
1 2 1
2 2 2 1 1 2 2
2 2 2
2 2 2 2 2 2 1
3 3 2 B C
2 2 3 2 2 2 2
2 1
3 3 2 1 3 3 2
2 2
3 3 2 2 3 2
3 3 3 2

Department of CSE, National Institute of Technology Rourkela

36
2/12/2025

Decomposition
 Condition (c): Attribute(R1) ∩ Attribute(R2)  Attribute (R1) or
Attribute (R1) ∩ Attribute (R2)  Attribute (R2)  the common
attribute must be a candidate key in one of the decomposed
relation.
 Query: find the value of C if the value of a is 1.
Select R2.C from R2 Natural Join Where R1.A = 1.
A B A C A B
1 2 1 1 1 2
1 2 2 2 A B C 2 2
A B C 3 3
1 2 3 2 1 2 1
1 2 1
2 2 1 1 2 2 2
2 2 2
2 2 2 2 3 3 2
3 3 2 A C
2 2 3 2
1 1
3 3 1 1
2 2
3 3 2 2
3 2
3 3 3 2
Department of CSE, National Institute of Technology Rourkela

Lossless Decomposition: Example 1


 For the given relation check which of the following decomposition
is lossless.
• R1(AB), R2(CD)
A B C D E
• R1(ABC), R2(DE)
a 123 1 p w
• R1(ABC), R2(CDE) b 234 2 q x
• R1(ABCD), R2(ACDE) a 345 1 r y
• R1(ABCD), R2(DE) c 456 3 s z

• R1(ABC), R2(BCD), R3(DE)

Department of CSE, National Institute of Technology Rourkela

37
2/12/2025

Lossless Decomposition: Example 2


 R (VWXYZ), FD = {ZY, YZ, XYV, VWX}.
• R1(VWX), R2(XYZ)
• R1(VW), R2(YZ)
A B C D E
• R1(VWX), R2(YZ) a 123 1 p w
• R1(VW), R2(WXYZ) b 234 2 q x
a 345 1 r y
c 456 3 s z

Department of CSE, National Institute of Technology Rourkela

Dependency Preserving Decomposition


 If a relation R, having FD set F, is decomposed into two relations
R1 and R2 having FD set F1 and F2 then the decomposition is
said to be dependency preserving decomposition iff:
F1, F2 ⊆ F+ and (F1 ∪ F2)+ = F+

 R(ABC) F ={AB, BC, CA)}


• R1(A, B) R2(B,C)
• F1(AB , BA ) F2(BC, CB)

• (F1 U F2)+  AB, BC, CA.

 Check the dependency based on the dependency given in parent


table.
 Do not put trivial dependency.

Department of CSE, National Institute of Technology Rourkela

38
2/12/2025

Dependency Preservation [GATE]


 R(ABCD) F ={AB, BC, CD, DB}
• R1(A,B); R2(B,C); R3(B,D)

• R1(A,B); All possibilities {AA, AB, BB, BA} F1{AB}


• R2(B,C); F2{BC, CB}
• R3(B,D); F3(BD, DB}

• (F1 U F2)  {AB, BC, CB, BD, DB}


• (F1 U F2)+  {AB, BC, CD, BD, DB}

Department of CSE, National Institute of Technology Rourkela

Dependency Preservation
 R(ABC) F ={ABCD, DA)}
• R1(A, D) R2(B,C,D)
• F1(AD) F2(BDC)

• (F1 U F2)+  DA

Department of CSE, National Institute of Technology Rourkela

39
2/12/2025

Decomposition to Normal Form


 R (A, B, C, D, E, F, G, H, I J)
• FD = {ABC, ADE, BF, DIJ, FGH}
• Candidate Key?
• AB
• Normalize it to 2NF
• R1(ABC);
• R2(ADEIJ);
• R3(BFGH)

Department of CSE, National Institute of Technology Rourkela

Decomposition to Normal Form


 R (A, B, C, D, E, F, G, H, I J)
• FD = {ABC, ADE, BF, DIJ, FGH}
• R1(ABC);
• R2(ADEIJ);
• R3(BFGH)
• Now decompose these relations to 3NF
• R1(ABC);
• R21(ADE);
• R22(DIJ);
• R31(BF);
• R32(FGH)
• Now decompose these relations to BCNF.

Department of CSE, National Institute of Technology Rourkela

40
2/12/2025

Department of CSE, National Institute of Technology Rourkela

4 NF
 The relation should be in BCNF and it should not have multi-
valued dependency.

A B C D
1 X P 2
1 Y Q 3
1 X P 3

 Candidate key  ABD,


 Which Normal Form  3NF.

Department of CSE, National Institute of Technology Rourkela

41
2/12/2025

4 NF
 Now check for BCNF
 Candidate key  ABD
 Dependency BC Note allowed.
 Decompose it to two tables R1 (ABD), R2 (BC)
 Now the relation is in BCNF. A B D
1 X 2
1 Y 3
A B C D
1 X 2
1 X P 2
1 Y Q 3
1 X P 3 B C
X P
Y Q

Department of CSE, National Institute of Technology Rourkela

4 NF
 Multivalued Dependency ()
 AB
 AD
 Decompose the first relation to tow more relations R1’(AB),
R1’’(AD) A B
1 X
1 Y
A B D
1 X 2
A D
1 Y 3
A B C D 1 2
1 X 3
1 X P 2 1 3
1 Y Q 3
1 X P 3 B C
X P
Y Q

Department of CSE, National Institute of Technology Rourkela

42
2/12/2025

5 NF
 The relation should be in 4NF, and the decomposition should be
lossless.
 Also known as Project-Join Normal Form (PJNF)
 We already discussed this concept yesterday.

Department of CSE, National Institute of Technology Rourkela

Normalization Summary
 Summary of Normal Forms:

NF What It Fixes Key Condition


Eliminates duplicate columns Every attribute contains atomic (indivisible)
1NF
and repeating groups values
Removes partial Every non-key attribute is fully dependent
2NF
dependencies on the entire primary key
Every non-key attribute is only dependent
Eliminates transitive
3NF on the primary key (not on other non-key
dependencies
attributes)
Ensures every determinant is Every functional dependency (FD) is on a
BCNF
a superkey superkey
Eliminates multi-valued A table should not contain two
4NF
dependencies (MVDs) independent multi-valued facts
Eliminates join dependencies A relation should not have redundancy due
5NF
(JDs) to join dependencies

Department of CSE, National Institute of Technology Rourkela

43
2/12/2025

GATE Questions [2015]


Q5: Consider a relation R(A,B,C) with a multivalued dependency
A→→BA. Which of the following decompositions is in 4NF?
a. Decompose into R1(A,B) and R2(A,C)
b. Decompose into R1(A,B,C)
c. Decompose into R1(A,B) and R2(B,C)
d. Decompose into R1(A,C) and R2(B,C)

Department of CSE, National Institute of Technology Rourkela

GATE Questions [2015]


Q5: Consider a relation R(A,B,C) with a multivalued dependency
A→→BA. Which of the following decompositions is in 4NF?
a. Decompose into R1(A,B) and R2(A,C)
b. Decompose into R1(A,B,C)
c. Decompose into R1(A,B) and R2(B,C)
d. Decompose into R1(A,C) and R2(B,C)

Department of CSE, National Institute of Technology Rourkela

44
2/12/2025

GATE Questions [2015]


Given a relation R with attributes A,B and C, and a multivalued
dependency A→→B is the decomposition of R into R1(A,B) and
R2(A,C) in 4NF?
a. Yes, because the decomposition removes the multivalued
dependency.
b. No, because the decomposition is not dependency-preserving.
c. Yes, because A→→B is preserved.
d. No, because A→C is not preserved.

Department of CSE, National Institute of Technology Rourkela

GATE Questions [2015]


Given a relation R with attributes A,B and C, and a multivalued
dependency A→→B is the decomposition of R into R1(A,B) and
R2(A,C) in 4NF?
a. Yes, because the decomposition removes the multivalued
dependency.
b. No, because the decomposition is not dependency-preserving.
c. Yes, because A→→B is preserved.
d. No, because A→C is not preserved.

Department of CSE, National Institute of Technology Rourkela

45
2/12/2025

GATE Questions [2014]


Q1: Consider a relation R(A,B,C,D) with functional dependencies
A→B and C→D. Which of the following decompositions is both
lossless and dependency-preserving?
a. Decompose into R1(A,B) and R2(C,D)
b. Decompose into R1(A,C) and R2(A,D)
c. Decompose into R1(A,B,C) and R2(C,D)
d. Decompose into R1(A,B) and R2(A,C,D)

Department of CSE, National Institute of Technology Rourkela

GATE Questions [2014]


Q1: Consider a relation R(A,B,C,D) with functional dependencies
A→B and C→D. Which of the following decompositions is both
lossless and dependency-preserving?
a. Decompose into R1(A,B) and R2(C,D)  lossy, DL
b. Decompose into R1(A,C) and R2(A,D)  lossy, DL
c. Decompose into R1(A,B,C) and R2(C,D)  lossless, DP
d. Decompose into R1(A,B) and R2(A,C,D)  lossless, DL

Department of CSE, National Institute of Technology Rourkela

46
2/12/2025

GATE Questions [2012]


Q2: Given a relation R with attributes A,B,C and D, and functional
dependencies A→B and C→D, is the decomposition of R into R1(A,B)
and R2(C,D) lossless?
a. Yes, because A→B and C→D are preserved.
b. No, because there is no common attribute between R1 and R2
c. Yes, because the decomposition is dependency-preserving.
d. No, because A and C are not keys.

Department of CSE, National Institute of Technology Rourkela

GATE Questions [2012]


Q2: Given a relation R with attributes A,B,C and D, and functional
dependencies A→B and C→D, is the decomposition of R into R1(A,B)
and R2(C,D) lossless?
a. Yes, because A→B and C→D are preserved.
b. No, because there is no common attribute between R1 and R2
c. Yes, because the decomposition is dependency-preserving.
d. No, because A and C are not keys.

Department of CSE, National Institute of Technology Rourkela

47
2/12/2025

GATE Questions [2011]


Q3: For a relation R(A,B,C) with func onal dependencies AB→C and
C→A determine if the decomposition of R into R1(A,B) and R2(B,C) is
lossless.
a. Yes, because AB→C ensures lossless join.
b. No, because C→A is not preserved.
c. Yes, because C→A ensures lossless join.
d. No, because AB→C is not preserved.

Department of CSE, National Institute of Technology Rourkela

GATE Questions [2011]


Q3: For a relation R(A,B,C) with func onal dependencies AB→C and
C→A determine if the decomposition of R into R1(A,B) and R2(B,C) is
lossless.
a. Yes, because AB→C ensures lossless join.
b. No, because C→A is not preserved.
c. Yes, because C→A ensures lossless join.
d. No, because AB→C is not preserved.

Department of CSE, National Institute of Technology Rourkela

48
2/12/2025

GATE Questions [2010]


Q4: Consider a schema R(A,B,C,D) with functional dependencies
A→B and C→D. Is the decomposition of R into R1(A,B) and R2(C,D)
lossless?
a. Yes, because each functional dependency involves a separate set
of attributes.
b. No, because there is no common attribute between R1 and R2.
c. Yes, because the decomposition is in BCNF.
d. No, because the decomposition is not dependency-preserving.

Department of CSE, National Institute of Technology Rourkela

GATE Questions [2010]


Q4: Consider a schema R(A,B,C,D) with functional dependencies
A→B and C→D. Is the decomposition of R into R1(A,B) and R2(C,D)
lossless?
a. Yes, because each functional dependency involves a separate set
of attributes.
b. No, because there is no common attribute between R1 and R2.
c. Yes, because the decomposition is in BCNF.
d. No, because the decomposition is not dependency-preserving.

Department of CSE, National Institute of Technology Rourkela

49

You might also like