SlideShare a Scribd company logo
1 of 31
Pearson Education © 2014
Chapter 15
Advanced Normalization
Pearson Education © 2014
2
Chapter 15 - Objectives
Normal forms that go beyond Third Normal
Form (3NF), which includes Boyce-Codd
Normal Form (BCNF), Fourth Normal Form
(4NF), and Fifth Normal Form (5NF).
How to identify Boyce–Codd Normal Form
(BCNF).
How to represent attributes shown on a
report as BCNF relations using normalization.
Pearson Education © 2014
3
Chapter 15 - Objectives
Concept of multi-valued dependencies and
Fourth Normal Form (4NF).
The problems associated with relations that
break the rules of 4NF.
How to create 4NF relations from a relation,
which breaks the rules of to 4NF.
Pearson Education © 2014
4
Boyce–Codd Normal Form
(BCNF)
Based on functional dependencies that take
into account all candidate keys in a relation,
however BCNF also has additional constraints
compared with the general definition of 3NF.
Boyce–Codd normal form (BCNF)
A relation is in BCNF if and only if every
determinant is a candidate key.
Pearson Education © 2014
5
Boyce–Codd Normal Form
(BCNF)
Difference between 3NF and BCNF is that for a
functional dependency A → B, 3NF allows this
dependency in a relation if B is a primary-key
attribute and A is not a candidate key.
Whereas, BCNF insists that for this
dependency to remain in a relation, A must be
a candidate key.
Every relation in BCNF is also in 3NF. However,
a relation in 3NF is not necessarily in BCNF.
Pearson Education © 2014
6
Boyce–Codd Normal Form
(BCNF)
Violation of BCNF is quite rare.
The potential to violate BCNF may occur in a
relation that:
contains two (or more) composite candidate keys;
the candidate keys overlap, that is have at least
one attribute in common.
Pearson Education © 2014
7
Review of Normalization (UNF to
BCNF)
Pearson Education © 2014
Review of Normalization (UNF to
BCNF)
StaffProperyInspection in UNF
– Must handle multi-valued attribute to get to 1NF
8
Pearson Education © 2014
Review of Normalization (UNF to
BCNF)
• StaffPropertyInspection in 1NF
– 2 tuples -> 5 tuples
9
Pearson Education © 2014
10
Identify all Functional
Dependencies in 1NF version
Pearson Education © 2014
1NF -> 2NF
• 1NF
– StaffPropertyInspection (propertyNo, iDate, iTime,
pAddress, comments, staffNo, sName, carReg)
– Primary key: propertyNo, iDate
– Functional dependencies fd1 to fd6 (see previous
slide)
• 1NF -> 2NF
– Remove partial fd (fd2): propertyNo -> pAddress
– Create 2 tables from StaffPropertyInspection
– PropertyInspection & Property
Pearson Education © 2014
2NF -> 3NF
• 2NF
– PropertyInspection (propertyNo, iDate, iTime,
comments, staffNo, sName, carReg)
– Property (propertyNo, pAddress)
• 2NF -> 3NF
– Remove transitive fd (fd3) from PropertyInspection
– fd1 propertyNo, iDate -> … staffNo..
– fd3 staffNo-> sName
– Create 2 tables from PropertyInspection
• PropertyInspect & Staff
Pearson Education © 2014
3NF Schema
• PropertyInspect (propertyNo, iDate, iTime,
comments, staffNo, carReg)
– fd1’ propertyNo, iDate -> iTime, comments,
staffNo, sName, carReg
– fd4 staffNo, iDate -> carReg
– fd5’ carReg, iDate, iTime -> propertyNo,
commends, staffNo
– fd6’ staffNo, iDate, iTime -> propertyNo, comments
• Property (propertyNo, pAddress)
– fd2 propertyNo -> pAddress
• Staff (staffNo, sName)
– fd3 staffNo -> sName
Pearson Education © 2014
3NF -> BCNF
• All determinants (lhs) must be candidate keys
• Staff and Property in BCNF
• PropertyInspect: not in BCNF
– fd4 staffNo, iDate -> carReg
• Staff assigned same car for the whole day
– staffNo, iDate is not a candidate key for
PropertyInspect
• Staff could inspect >1 properties on the same day
(domain knowledge)
• Create two new relations from PropertyInspect
– Inspection (propertyNo, iDate, iTime, comments,
staffNo)
– StaffCar (staffNo iDate, carReg)
Pearson Education © 2014
BCNF Schema
• Inspection (propertyNo, iDate, iTime,
comments, staffNo)
– fd1’’ propertyNo, iDate -> iTime, comments,
staffNo, sName
– fd5’’ iDate, iTime -> propertyNo, comments,
staffNo
– fd6’ staffNo, iDate, iTime -> propertyNo, comments
• Property (propertyNo, pAddress)
– fd2 propertyNo -> pAddress
• Staff (staffNo, sName)
– fd3 staffNo -> sName
• StaffCarReg (staffNo, iDate, carReg)
– fd4 staffNo, iDate -> carReg
Pearson Education © 2014
16
Review of Normalization (1NF to
BCNF)
Pearson Education © 2014
17
Fourth Normal Form (4NF)
• Multi-valued Dependency (MVD)
– Dependency between attributes (for example, A,
B, and C) in a relation, such that for each value of
A there is a set of values for B and a set of values
for C. However, the set of values for B and C are
independent of each other.
• Defined as a relation that is in Boyce-Codd
Normal Form and contains no nontrivial multi-
valued dependencies.
Pearson Education © 2014
18
Fourth Normal Form (4NF)
• MVD between attributes A, B, and C in a
relation using the following notation:
A −>> B
A −>> C
Pearson Education © 2014
Example
• BranchStaffOwner
– Has two independent, mulivalued dependencies in
same table:
• branchNo ->> sName (branches have multiple staff)
• branchNo ->> oName (branches have multiple properties
which may have different owners)
– End up having to duplicate tuples to show each
staff member with each owner
• E.g., add a new staff member, have to add 2 new tuples,
one for each oName
• Solution: make a separate relation for each
dependency
Pearson Education © 2014
20
4NF - Example
Pearson Education © 2014
21
Fifth Normal Form (5NF)
Pearson Education © 2014
22
Fifth Normal Form (5NF)
• In other words, in 5NF, all relations are
decomposed into as many relations as possible
without introducing errors
– All tables are key, and attributes that depend on
key; no other fd
Pearson Education © 2014
5NF
• Do NOT decompose tables if all attributes
depend on same key
– E.g., <SSN, Name, Birthdate, Zip> stays in one
table
– Do not decompose into
• <SSN, Name>
• <SSN, Birthdate>
• <SSN, Zip>
Pearson Education © 2014
24
5NF – Example (table is in 4NF)
Traveling Salesman Brand Product Type
Jack Schneider Acme Vacuum Cleaner
Jack Schneider Acme Breadbox
Mary Jones Robusto Pruning Shears
Mary Jones Robusto Vacuum Cleaner
Mary Jones Robusto Breadbox
Mary Jones Robusto Umbrella Stand
Louis Ferguson Robusto Vacuum Cleaner
Louis Ferguson Robusto Telescope
Louis Ferguson Acme Vacuum Cleaner
Louis Ferguson Acme Lava Lamp
Louis Ferguson Nimbus Tie Rack
Pearson Education © 2014
5NF - Example
• Primary Key: Composite of all three attributes
(Traveling Salesman, Brand, Product Type)
• In 4NF
• Suppose there is a rule that, if a salesman offers
the same product from TWO different Brands
– Then he must offer all other products from those
brands IF he sells those products at all
25
Pearson Education © 2014
5NF - Example
• So, If Jack Schneider starts to sell Robusto’s
Vacuum Cleaners
– He must also now sell Robusto’s Breadboxes, too,
because he sells Breadboxes
• But, he doesn’t sell Pruning Shears or Umbrella Stands
(from Robusto) or Lava Lamps (from Acme)
– That’s okay
– If not in 5NF,
• Need logic in the insert function to enforce rules
• Add 2 tuples
– <Jack Schneider, Robusto, Vacuum Cleaner>
– <Jack Schneider, Robusto, Breadbox>
• Possibility of update/insert/deletion errors
26
Pearson Education © 2014
5NF - Example
• Instead, decompose into 3 relations:
– Traveling Salesman -> Product Type
– Traveling Salesman -> Brand
– Brand -> Product Type
• Now, table design excludes possibility of
inconsistencies
– He starts selling Robusto Vaccuum cleaners
– Add <Jack Schneider, Robusto> to
TravellingSalesman+Brand table
– Captures that he sells Breadboxes and Vacuum
Cleaners from Robusto and Acme 27
Pearson Education © 2014
28
5NF - Example
Traveling Salesman Product Type
Jack Schneider Vacuum Cleaner
Jack Schneider Breadbox
Mary Jones Pruning Shears
Mary Jones Vacuum Cleaner
Mary Jones Breadbox
Mary Jones Umbrella Stand
Louis Ferguson Vacuum Cleaner
Louis Ferguson Telescope
Louis Ferguson Lava Lamp
Louis Ferguson Tie Rack
Traveling Salesman Brand
Jack Schneider Acme
Mary Jones Robusto
Louis Ferguson Robusto
Louis Ferguson Acme
Louis Ferguson Nimbus
Brand Product Type
Acme Vacuum Cleaner
Acme Breadbox
Acme Lava Lamp
Robusto Pruning Shears
Robusto Vacuum Cleaner
Robusto Breadbox
Robusto Umbrella Stand
Robusto Telescope
Nimbus Tie Rack
Pearson Education © 2014
5NF - Example
• Need to join all 3 relations to get original
relation
– Can get spurious tuples by just joining two relations
• E.g., join <Jack Schneider, Acme> with <Acme, Lava
Lamp>
– Conclude that Jack sells Acme Lava Lamps and he
doesn’t
– Must join with all 3 relations
• <Jack Schneider, Acme> with
• <Jack Schneider, Vacuum Cleaner> AND <Jack Schneider,
Breadbox> with
• <Acme, Vacuum Cleaner> <Acme, Breadbox> <Acme,
Lava Lamp> 29
Pearson Education © 2014
30
Normalization Summary
• As we normalize, we change schema to contain
more and more tables with fewer and fewer
attributes in each table
– Reduces redundancy
– BUT need to do joins to answer queries
• E.g., can get sName for a given date, time an property
from StaffPropertyInspection (2NF)
• Need to join PropertyInspect and Staff on staffNo to get
the name in 3NF
• Classic time/space trade-off in CS
Pearson Education © 2014
31
Normalization Summary
• If you do an object-oriented design of your
database, you will be generally be in 4NF
– E.g., classes (relations) for: property, staff,
owners, cars, etc…
– Attributes for each class in the relation for that
class

More Related Content

What's hot

What's hot (20)

Lecture 4 sql {basics keys and constraints}
Lecture 4 sql {basics  keys and constraints}Lecture 4 sql {basics  keys and constraints}
Lecture 4 sql {basics keys and constraints}
 
Relational Data Model Introduction
Relational Data Model IntroductionRelational Data Model Introduction
Relational Data Model Introduction
 
Bcnf
BcnfBcnf
Bcnf
 
Transaction management and concurrency control
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency control
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joinsSql joins inner join self join outer joins
Sql joins inner join self join outer joins
 
Primary Key & Foreign Key part10
Primary Key & Foreign Key part10Primary Key & Foreign Key part10
Primary Key & Foreign Key part10
 
DBMS - FIRST NORMAL FORM
DBMS - FIRST NORMAL FORMDBMS - FIRST NORMAL FORM
DBMS - FIRST NORMAL FORM
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
 
Functional dependancy
Functional dependancyFunctional dependancy
Functional dependancy
 
Lesson 7 io statements
Lesson 7 io statementsLesson 7 io statements
Lesson 7 io statements
 
Normalization
NormalizationNormalization
Normalization
 
Normalization in SQL | Edureka
Normalization in SQL | EdurekaNormalization in SQL | Edureka
Normalization in SQL | Edureka
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
SQL subquery
SQL subquerySQL subquery
SQL subquery
 
Normalization PRESENTATION
Normalization PRESENTATIONNormalization PRESENTATION
Normalization PRESENTATION
 
Normalization
NormalizationNormalization
Normalization
 
Normalisation - 2nd normal form
Normalisation - 2nd normal formNormalisation - 2nd normal form
Normalisation - 2nd normal form
 
Dbms slides
Dbms slidesDbms slides
Dbms slides
 

Recently uploaded

Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 

Advanced normalization - Bcnf

  • 1. Pearson Education © 2014 Chapter 15 Advanced Normalization
  • 2. Pearson Education © 2014 2 Chapter 15 - Objectives Normal forms that go beyond Third Normal Form (3NF), which includes Boyce-Codd Normal Form (BCNF), Fourth Normal Form (4NF), and Fifth Normal Form (5NF). How to identify Boyce–Codd Normal Form (BCNF). How to represent attributes shown on a report as BCNF relations using normalization.
  • 3. Pearson Education © 2014 3 Chapter 15 - Objectives Concept of multi-valued dependencies and Fourth Normal Form (4NF). The problems associated with relations that break the rules of 4NF. How to create 4NF relations from a relation, which breaks the rules of to 4NF.
  • 4. Pearson Education © 2014 4 Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF also has additional constraints compared with the general definition of 3NF. Boyce–Codd normal form (BCNF) A relation is in BCNF if and only if every determinant is a candidate key.
  • 5. Pearson Education © 2014 5 Boyce–Codd Normal Form (BCNF) Difference between 3NF and BCNF is that for a functional dependency A → B, 3NF allows this dependency in a relation if B is a primary-key attribute and A is not a candidate key. Whereas, BCNF insists that for this dependency to remain in a relation, A must be a candidate key. Every relation in BCNF is also in 3NF. However, a relation in 3NF is not necessarily in BCNF.
  • 6. Pearson Education © 2014 6 Boyce–Codd Normal Form (BCNF) Violation of BCNF is quite rare. The potential to violate BCNF may occur in a relation that: contains two (or more) composite candidate keys; the candidate keys overlap, that is have at least one attribute in common.
  • 7. Pearson Education © 2014 7 Review of Normalization (UNF to BCNF)
  • 8. Pearson Education © 2014 Review of Normalization (UNF to BCNF) StaffProperyInspection in UNF – Must handle multi-valued attribute to get to 1NF 8
  • 9. Pearson Education © 2014 Review of Normalization (UNF to BCNF) • StaffPropertyInspection in 1NF – 2 tuples -> 5 tuples 9
  • 10. Pearson Education © 2014 10 Identify all Functional Dependencies in 1NF version
  • 11. Pearson Education © 2014 1NF -> 2NF • 1NF – StaffPropertyInspection (propertyNo, iDate, iTime, pAddress, comments, staffNo, sName, carReg) – Primary key: propertyNo, iDate – Functional dependencies fd1 to fd6 (see previous slide) • 1NF -> 2NF – Remove partial fd (fd2): propertyNo -> pAddress – Create 2 tables from StaffPropertyInspection – PropertyInspection & Property
  • 12. Pearson Education © 2014 2NF -> 3NF • 2NF – PropertyInspection (propertyNo, iDate, iTime, comments, staffNo, sName, carReg) – Property (propertyNo, pAddress) • 2NF -> 3NF – Remove transitive fd (fd3) from PropertyInspection – fd1 propertyNo, iDate -> … staffNo.. – fd3 staffNo-> sName – Create 2 tables from PropertyInspection • PropertyInspect & Staff
  • 13. Pearson Education © 2014 3NF Schema • PropertyInspect (propertyNo, iDate, iTime, comments, staffNo, carReg) – fd1’ propertyNo, iDate -> iTime, comments, staffNo, sName, carReg – fd4 staffNo, iDate -> carReg – fd5’ carReg, iDate, iTime -> propertyNo, commends, staffNo – fd6’ staffNo, iDate, iTime -> propertyNo, comments • Property (propertyNo, pAddress) – fd2 propertyNo -> pAddress • Staff (staffNo, sName) – fd3 staffNo -> sName
  • 14. Pearson Education © 2014 3NF -> BCNF • All determinants (lhs) must be candidate keys • Staff and Property in BCNF • PropertyInspect: not in BCNF – fd4 staffNo, iDate -> carReg • Staff assigned same car for the whole day – staffNo, iDate is not a candidate key for PropertyInspect • Staff could inspect >1 properties on the same day (domain knowledge) • Create two new relations from PropertyInspect – Inspection (propertyNo, iDate, iTime, comments, staffNo) – StaffCar (staffNo iDate, carReg)
  • 15. Pearson Education © 2014 BCNF Schema • Inspection (propertyNo, iDate, iTime, comments, staffNo) – fd1’’ propertyNo, iDate -> iTime, comments, staffNo, sName – fd5’’ iDate, iTime -> propertyNo, comments, staffNo – fd6’ staffNo, iDate, iTime -> propertyNo, comments • Property (propertyNo, pAddress) – fd2 propertyNo -> pAddress • Staff (staffNo, sName) – fd3 staffNo -> sName • StaffCarReg (staffNo, iDate, carReg) – fd4 staffNo, iDate -> carReg
  • 16. Pearson Education © 2014 16 Review of Normalization (1NF to BCNF)
  • 17. Pearson Education © 2014 17 Fourth Normal Form (4NF) • Multi-valued Dependency (MVD) – Dependency between attributes (for example, A, B, and C) in a relation, such that for each value of A there is a set of values for B and a set of values for C. However, the set of values for B and C are independent of each other. • Defined as a relation that is in Boyce-Codd Normal Form and contains no nontrivial multi- valued dependencies.
  • 18. Pearson Education © 2014 18 Fourth Normal Form (4NF) • MVD between attributes A, B, and C in a relation using the following notation: A −>> B A −>> C
  • 19. Pearson Education © 2014 Example • BranchStaffOwner – Has two independent, mulivalued dependencies in same table: • branchNo ->> sName (branches have multiple staff) • branchNo ->> oName (branches have multiple properties which may have different owners) – End up having to duplicate tuples to show each staff member with each owner • E.g., add a new staff member, have to add 2 new tuples, one for each oName • Solution: make a separate relation for each dependency
  • 20. Pearson Education © 2014 20 4NF - Example
  • 21. Pearson Education © 2014 21 Fifth Normal Form (5NF)
  • 22. Pearson Education © 2014 22 Fifth Normal Form (5NF) • In other words, in 5NF, all relations are decomposed into as many relations as possible without introducing errors – All tables are key, and attributes that depend on key; no other fd
  • 23. Pearson Education © 2014 5NF • Do NOT decompose tables if all attributes depend on same key – E.g., <SSN, Name, Birthdate, Zip> stays in one table – Do not decompose into • <SSN, Name> • <SSN, Birthdate> • <SSN, Zip>
  • 24. Pearson Education © 2014 24 5NF – Example (table is in 4NF) Traveling Salesman Brand Product Type Jack Schneider Acme Vacuum Cleaner Jack Schneider Acme Breadbox Mary Jones Robusto Pruning Shears Mary Jones Robusto Vacuum Cleaner Mary Jones Robusto Breadbox Mary Jones Robusto Umbrella Stand Louis Ferguson Robusto Vacuum Cleaner Louis Ferguson Robusto Telescope Louis Ferguson Acme Vacuum Cleaner Louis Ferguson Acme Lava Lamp Louis Ferguson Nimbus Tie Rack
  • 25. Pearson Education © 2014 5NF - Example • Primary Key: Composite of all three attributes (Traveling Salesman, Brand, Product Type) • In 4NF • Suppose there is a rule that, if a salesman offers the same product from TWO different Brands – Then he must offer all other products from those brands IF he sells those products at all 25
  • 26. Pearson Education © 2014 5NF - Example • So, If Jack Schneider starts to sell Robusto’s Vacuum Cleaners – He must also now sell Robusto’s Breadboxes, too, because he sells Breadboxes • But, he doesn’t sell Pruning Shears or Umbrella Stands (from Robusto) or Lava Lamps (from Acme) – That’s okay – If not in 5NF, • Need logic in the insert function to enforce rules • Add 2 tuples – <Jack Schneider, Robusto, Vacuum Cleaner> – <Jack Schneider, Robusto, Breadbox> • Possibility of update/insert/deletion errors 26
  • 27. Pearson Education © 2014 5NF - Example • Instead, decompose into 3 relations: – Traveling Salesman -> Product Type – Traveling Salesman -> Brand – Brand -> Product Type • Now, table design excludes possibility of inconsistencies – He starts selling Robusto Vaccuum cleaners – Add <Jack Schneider, Robusto> to TravellingSalesman+Brand table – Captures that he sells Breadboxes and Vacuum Cleaners from Robusto and Acme 27
  • 28. Pearson Education © 2014 28 5NF - Example Traveling Salesman Product Type Jack Schneider Vacuum Cleaner Jack Schneider Breadbox Mary Jones Pruning Shears Mary Jones Vacuum Cleaner Mary Jones Breadbox Mary Jones Umbrella Stand Louis Ferguson Vacuum Cleaner Louis Ferguson Telescope Louis Ferguson Lava Lamp Louis Ferguson Tie Rack Traveling Salesman Brand Jack Schneider Acme Mary Jones Robusto Louis Ferguson Robusto Louis Ferguson Acme Louis Ferguson Nimbus Brand Product Type Acme Vacuum Cleaner Acme Breadbox Acme Lava Lamp Robusto Pruning Shears Robusto Vacuum Cleaner Robusto Breadbox Robusto Umbrella Stand Robusto Telescope Nimbus Tie Rack
  • 29. Pearson Education © 2014 5NF - Example • Need to join all 3 relations to get original relation – Can get spurious tuples by just joining two relations • E.g., join <Jack Schneider, Acme> with <Acme, Lava Lamp> – Conclude that Jack sells Acme Lava Lamps and he doesn’t – Must join with all 3 relations • <Jack Schneider, Acme> with • <Jack Schneider, Vacuum Cleaner> AND <Jack Schneider, Breadbox> with • <Acme, Vacuum Cleaner> <Acme, Breadbox> <Acme, Lava Lamp> 29
  • 30. Pearson Education © 2014 30 Normalization Summary • As we normalize, we change schema to contain more and more tables with fewer and fewer attributes in each table – Reduces redundancy – BUT need to do joins to answer queries • E.g., can get sName for a given date, time an property from StaffPropertyInspection (2NF) • Need to join PropertyInspect and Staff on staffNo to get the name in 3NF • Classic time/space trade-off in CS
  • 31. Pearson Education © 2014 31 Normalization Summary • If you do an object-oriented design of your database, you will be generally be in 4NF – E.g., classes (relations) for: property, staff, owners, cars, etc… – Attributes for each class in the relation for that class