SlideShare a Scribd company logo
1 of 8
BCNF vs 3NF
• BCNF: For every functional dependency X->Y in a set F of functional
dependencies over relation R, either:
– Y is a subset of X or,
– X is a superkey of R
• 3NF: For every functional dependency X->Y in a set F of functional
dependencies over relation R, either:
– Y is a subset of X or,
– X is a superkey of R, or
– Y is a subset of K for some key K of R
• N.b., no subset of a key is a key
3NF Schema
Account Client Office
A Joe 1
B Mary 1
A John 1
C Joe 2
For every functional
dependency X->Y in a set F
of functional dependencies
over relation R, either:
– Y is a subset of X or,
– X is a superkey of R, or
– Y is a subset of K for
some key K of R Client, Office -> Client, Office, Account
Account -> Office
3NF Schema
Account Client Office
A Joe 1
B Mary 1
A John 1
C Joe 2
For every functional
dependency X->Y in a set F
of functional dependencies
over relation R, either:
– Y is a subset of X or,
– X is a superkey of R, or
– Y is a subset of K for
some key K of R Client, Office -> Client, Office, Account
Account -> Office
BCNF vs 3NF
For every functional
dependency X->Y in a set F
of functional dependencies
over relation R, either:
– Y is a subset of X or,
– X is a superkey of R
– Y is a subset of K for
some key K of R
3NF has some redundancy
BCNF does not
Unfortunately, BCNF is not dependency
preserving, but 3NF is
Client, Office -> Client, Office, Account
Account -> Office
Account Client Office
A Joe 1
B Mary 1
A John 1
C Joe 2
Account Office
A 1
B 1
C 2
Account Client
A Joe
B Mary
A John
C Joe
Account -> Office
No non-trivial FDs
Lossless
decomposition
Closure
• Want to find all attributes A such that X -> A is true, given a set
of functional dependencies F
define closure of X as X*
Closure(X):
c = X
Repeat
old = c
if there is an FD Z->V such that
Z ⊂ c and
V ⊄ c then
c = c U V
until old = c
return c
BCNFify
Closure(X):
c = X
Repeat
old = c
if there is an FD Z->V such that
Z ⊂ c and
V ⊄ c then
c = c U V
until old = c
return c
BCNFify(schema R, functional dependency set F):
D = {{R,F}}
while there is a schema S with dependencies F' in D that is not in BCNF, do:
given X->Y as a BCNF-violating FD in F
such that XY is in S
replace S in D with
S1={XY,F1} and
S2={(S-Y) U X, F2}
where F1 and F2 are the FDs in F over S1 or S2
(may need to split some FDs using decomposition)
End
return D
For every functional
dependency X->Y in a set F
of functional dependencies
over relation R, either:
– Y is a subset of X or,
– X is a superkey of R
B-tree Insertion
INSERTION OF KEY ’K’
find the correct leaf node ’L’;
if ( ’L’ overflows ){
split ’L’, by pushing the middle key upstairs to parent node ’P’;
if (’P’ overflows){
repeat the split recursively;
}
else{
add the key ’K’ in node ’L’; /* maintaining the key order in ’L’ */
}
Slide from Mitch Cherniak and George Kollios
B-tree deletion - pseudocode
DELETION OF KEY ’K’
locate key ’K’, in node ’N’
if( ’N’ is a non-leaf node) {
delete ’K’ from ’N’;
find the immediately largest key ’K1’;
/* which is guaranteed to be on a leaf node ’L’ */
copy ’K1’ in the old position of ’K’;
invoke this DELETION routine on ’K1’ from the leaf node ’L’;
else { /* ’N’ is a leaf node */
if( ’N’ underflows ){
let ’N1’ be the sibling of ’N’;
if( ’N1’ is "rich"){ /* ie., N1 can lend us a key */
borrow a key from ’N1’ THROUGH the parent node;
}else{ /* N1 is 1 key away from underflowing */
MERGE: pull the key from the parent ’P’,
and merge it with the keys of ’N’ and ’N1’ into a new node;
if( ’P’ underflows){ repeat recursively }
}
}
Slide from Mitch Cherniak and George Kollios

More Related Content

What's hot (20)

Query processing-and-optimization
Query processing-and-optimizationQuery processing-and-optimization
Query processing-and-optimization
 
Normalization in SQL | Edureka
Normalization in SQL | EdurekaNormalization in SQL | Edureka
Normalization in SQL | Edureka
 
Relational algebra ppt
Relational algebra pptRelational algebra ppt
Relational algebra ppt
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Unit 3 dbms
Unit 3 dbmsUnit 3 dbms
Unit 3 dbms
 
Database constraints
Database constraintsDatabase constraints
Database constraints
 
Introduction to oracle database (basic concepts)
Introduction to oracle database (basic concepts)Introduction to oracle database (basic concepts)
Introduction to oracle database (basic concepts)
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancy
 
The relational database model
The relational database modelThe relational database model
The relational database model
 
Relational data base management system (Unit 1)
Relational data base management system (Unit 1)Relational data base management system (Unit 1)
Relational data base management system (Unit 1)
 
Dbms normalization
Dbms normalizationDbms normalization
Dbms normalization
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Ms sql-server
Ms sql-serverMs sql-server
Ms sql-server
 
SQL Constraints
SQL ConstraintsSQL Constraints
SQL Constraints
 
Introduction to sql
Introduction to sqlIntroduction to sql
Introduction to sql
 
Date time function in Database
Date time function in DatabaseDate time function in Database
Date time function in Database
 
Fifth normal form
Fifth normal formFifth normal form
Fifth normal form
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 

Recently uploaded

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

BCNF vs 3NF Explained

  • 1. BCNF vs 3NF • BCNF: For every functional dependency X->Y in a set F of functional dependencies over relation R, either: – Y is a subset of X or, – X is a superkey of R • 3NF: For every functional dependency X->Y in a set F of functional dependencies over relation R, either: – Y is a subset of X or, – X is a superkey of R, or – Y is a subset of K for some key K of R • N.b., no subset of a key is a key
  • 2. 3NF Schema Account Client Office A Joe 1 B Mary 1 A John 1 C Joe 2 For every functional dependency X->Y in a set F of functional dependencies over relation R, either: – Y is a subset of X or, – X is a superkey of R, or – Y is a subset of K for some key K of R Client, Office -> Client, Office, Account Account -> Office
  • 3. 3NF Schema Account Client Office A Joe 1 B Mary 1 A John 1 C Joe 2 For every functional dependency X->Y in a set F of functional dependencies over relation R, either: – Y is a subset of X or, – X is a superkey of R, or – Y is a subset of K for some key K of R Client, Office -> Client, Office, Account Account -> Office
  • 4. BCNF vs 3NF For every functional dependency X->Y in a set F of functional dependencies over relation R, either: – Y is a subset of X or, – X is a superkey of R – Y is a subset of K for some key K of R 3NF has some redundancy BCNF does not Unfortunately, BCNF is not dependency preserving, but 3NF is Client, Office -> Client, Office, Account Account -> Office Account Client Office A Joe 1 B Mary 1 A John 1 C Joe 2 Account Office A 1 B 1 C 2 Account Client A Joe B Mary A John C Joe Account -> Office No non-trivial FDs Lossless decomposition
  • 5. Closure • Want to find all attributes A such that X -> A is true, given a set of functional dependencies F define closure of X as X* Closure(X): c = X Repeat old = c if there is an FD Z->V such that Z ⊂ c and V ⊄ c then c = c U V until old = c return c
  • 6. BCNFify Closure(X): c = X Repeat old = c if there is an FD Z->V such that Z ⊂ c and V ⊄ c then c = c U V until old = c return c BCNFify(schema R, functional dependency set F): D = {{R,F}} while there is a schema S with dependencies F' in D that is not in BCNF, do: given X->Y as a BCNF-violating FD in F such that XY is in S replace S in D with S1={XY,F1} and S2={(S-Y) U X, F2} where F1 and F2 are the FDs in F over S1 or S2 (may need to split some FDs using decomposition) End return D For every functional dependency X->Y in a set F of functional dependencies over relation R, either: – Y is a subset of X or, – X is a superkey of R
  • 7. B-tree Insertion INSERTION OF KEY ’K’ find the correct leaf node ’L’; if ( ’L’ overflows ){ split ’L’, by pushing the middle key upstairs to parent node ’P’; if (’P’ overflows){ repeat the split recursively; } else{ add the key ’K’ in node ’L’; /* maintaining the key order in ’L’ */ } Slide from Mitch Cherniak and George Kollios
  • 8. B-tree deletion - pseudocode DELETION OF KEY ’K’ locate key ’K’, in node ’N’ if( ’N’ is a non-leaf node) { delete ’K’ from ’N’; find the immediately largest key ’K1’; /* which is guaranteed to be on a leaf node ’L’ */ copy ’K1’ in the old position of ’K’; invoke this DELETION routine on ’K1’ from the leaf node ’L’; else { /* ’N’ is a leaf node */ if( ’N’ underflows ){ let ’N1’ be the sibling of ’N’; if( ’N1’ is "rich"){ /* ie., N1 can lend us a key */ borrow a key from ’N1’ THROUGH the parent node; }else{ /* N1 is 1 key away from underflowing */ MERGE: pull the key from the parent ’P’, and merge it with the keys of ’N’ and ’N1’ into a new node; if( ’P’ underflows){ repeat recursively } } } Slide from Mitch Cherniak and George Kollios