0% found this document useful (0 votes)
46 views

Lecture13 Part1

The relation violates BCNF because the dependency DeptID, WorkerID -> Salary has a determinant set that is not a superkey. To decompose for BCNF, split the relation into Dept(DeptID, DeptName, Location) and Employee(WorkerID, WorkerName, Age, Salary, DeptID).

Uploaded by

Faruk Karagoz
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)
46 views

Lecture13 Part1

The relation violates BCNF because the dependency DeptID, WorkerID -> Salary has a determinant set that is not a superkey. To decompose for BCNF, split the relation into Dept(DeptID, DeptName, Location) and Employee(WorkerID, WorkerName, Age, Salary, DeptID).

Uploaded by

Faruk Karagoz
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/ 25

Functional dependencies

• Definition: a -> b
• ‘a’ functionally determines ‘b’ Informally: ‘if you know ‘a’,
there is only one ‘b’ to match’
Functional Dependencies
• formally:

• if two tuples agree on the ‘X’ attribute, they *must* agree on the ‘Y’
attribute, too (eg., if ssn is the same, so should address)
Goal
• Design ‘good’ tables
• sub-goal#1: define what ‘good’ means
• sub-goal#2: fix ‘bad’ tables
• In short: “we want tables where the attributes depend on the primary
key, on the whole key, and nothing but the key”
• Let’s see why and how:
Solution: Decomposition
• split offending table in two (or more), eg.:
Decompositions
• There are ‘bad’ decompositions. Good ones are:
• lossless and MUST HAVE

• dependency preserving Nice to have


Decompositions - lossless
Decompositions – dependency preserving
Today’s Agenda

1. 1NF

2. 2NF

3. 3NF

4. BCNF

5. How to decompose a table tconform to BCNF


Normal forms
• 1NF: attributes are atomic (ie., no set valued attr., a.k.a. ‘repeating
groups’)
Normal forms
• 2NF: 1NF and non-key attr. fully depend on the key
Normal forms
• 3NF: 2NF and no transitive dependencies
• counter-example:
R(A, B, C, D)
Normal forms
• STJ( Student, Teacher, subJect)
• Key: Student, subJect
• T-> J
• S,J -> T

informally, 3NF ‘forgives’ the red


arrow in the canonical cover
In 3NF, but not in BCNF
Normal forms – 3NF
• STJ( Student, Teacher, subJect) Formally, a rel. R with
• T-> J
FDs ‘F’ is in 3NF if: for
• S,J -> T
every a->b in F:
• it is trivial or
• a is a superkey or
b: part of a candidate
key
Question
• Question 1:
What maximum normal
form is the relation in?

Has set-valued attributes?


Question
• Question 1:
What maximum normal
form is the relation in?

Has set-valued attributes?


No => 1NF
Question
• Question 1:
What maximum normal
form is the relation in?

Has set-valued attributes?


No => 1NF
Are all non-key attributes
fully determined by the
key?
No => not 2NF
Question
• Question 1:
Is this 3NF?
It is not 2NF, so it is not
3NF

Another way to solve this


question?
Question
• Question 1:
Is this 3NF?
It is not 2NF, so it is not
3NF

Another way to solve this


question?
for every a->b in F:
• it is trivial or
• a is a superkey or
• b: part of a candidate key
Normal forms - BCNF
• Formally: for every FD a->b in F
• a->b is trivial (a superset of b) or
• a is a superkey
Sailors(SID, SName, Age, Rating, ZipCode)
Reserves(SID, BID, StartingDate, EndingDate)
Boats(BID, BName, Color, ZipCode)

Which function dependency will make above relations


violate the BCNF?

A. SID, BID -> StartingDate


B. SID -> Rating
C. BID -> ZipCode
D. BName -> BID
Normal forms - BCNF
• Theorem: given a schema R and a set of FD ‘F’, we can always
decompose it to schemas R1, … Rn, so that
• R1, … Rn are in BCNF and
• the decompositions are lossless.
• (but, some decompositions might lose dependencies)
Normal forms - BCNF
• How? algorithm in book: for a relation R
• for every FD X->A that violates BCNF, decompose to tables (X,A) and (R-A)
• repeat recursively
• eg. TAKES1(ssn, c-id, grade, name, address)
• ssn -> name, address
• ssn, c-id -> grade
Normal forms - BCNF
Consider the relation:

Dept(DeptID, DeptName, Location, WorkerID,


WorkerName, Age, Salary)

Suppose the following dependencies exist:

DeptID → DeptName, Location


WorkerID → WorkerName, Age
DeptID, WorkerID → Salary

Question 1. Is this relation in 3NF?


Question 2. Which dependency violates 3NF and BCNF?
Question 3. How to decompose for BCNF?
Normal forms - 3NF vs BCNF
• If ‘R’ is in BCNF, it is always in 3NF (but not the reverse)
• In practice, aim for
• BCNF; lossless join; and dep. preservation
• if impossible, we accept
• 3NF; but insist on lossless join and dep. Preservation
• in practice, E-R diagrams usually lead to tables in BCNF

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy