Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
UNIT III
Overview
Functional dependencies
Examples of FDs
Inference rules
Functional Dependencies
Functional dependencies (FDs)
Are used to specify formal measures of the
"goodness" of relational designs
And keys are used to define normal forms
for relations
Are constraints that are derived from the
meaning and interrelationships of the data
attributes
A set of attributes X functionally
Functional Dependencies
X -> Y holds if whenever two tuples have the
instances r(R)
Written as X -> Y; can be displayed graphically
on a relation schema as in Figures. ( denoted
by the arrow: ).
FDs are derived from the real-world constraints
on the attributes
Examples of FD constraints
Social security number determines
employee name
SSN -> ENAME
and location
PNUMBER -> {PNAME, PLOCATION}
Examples of FD constraints
An FD is a property of the attributes in
the schema R
The constraint must hold on every
relation instance r(R)
If K is a key of R, then K functionally
determines all attributes in R
(since we never have two distinct tuples with
t1[K]=t2[K])
Examples of FD constraints
FDs are a property of the meaning of
of inference rules
These are rules hold and all other rules that hold can
be deduced from these
useful:
Decomposition: If X -> YZ, then X -> Y
and X -> Z
Union: If X -> Y and X -> Z, then X -> YZ
Psuedotransitivity: If X -> Y and WY -> Z,
then WX -> Z
covers F
There is an algorithm for checking equivalence
of sets of FDs
following conditions:
1. Every dependency in F has a single attribute
for its RHS.
2. We cannot remove any dependency from F
and have a set of dependencies that is
equivalent to F.
3. We cannot replace any dependency X -> A
in F with a dependency Y -> A, where Y
proper-subset-of X ( Y subset-of X) and still
have a set of dependencies that is
equivalent to F.
minimal set
There can be several equivalent minimal
sets
There is no simple algorithm for
computing a minimal set of FDs that is
equivalent to a set F of FDs
Participating in Keys
First Normal Form
Second Normal Form
Third Normal Form
Normalization of Relations
Proposed by Codd(1972) three NFs
Boyce and Codd proposed BCNF
Normalization:
The process of decomposing unsatisfactory
"bad" relations by breaking up their
attributes into smaller relations
Normal form:
Condition using keys and FDs of a relation to
certify whether a relation schema is in a
particular normal form
Normalization of Relations
2NF, 3NF, BCNF
based on keys and FDs of a relation schema
4NF
based on keys, multi-valued dependencies :
MVDs;
5NF
based on keys, join dependencies : JDs
Additional properties may be needed to
Denormalization:
The process of storing the join of higher normal form
relations as a base relationwhich is in a lower
normal form
relation
Examples:
SSN -> DMGRSSN is a transitive FD
Since SSN -> DNUMBER and DNUMBER ->
DMGRSSN hold
Example
BCNF
The goal is to have each relation in BCNF (or
3NF)
this relation
So this relation is in 3NF but not in BCNF
Example 1: Determine NF
ISBN Title
ISBN Publisher
Publisher Address
BOOK
ISBN
Title
Publisher
Address
Example 1: Determine NF
ISBN Title
ISBN Publisher
Publisher Address
BOOK
ISBN
Title
Publisher
Address
Example 1: Determine NF
ISBN Title
ISBN Publisher
Publisher Address
BOOK
ISBN
Title
Publisher
Address
Example 1: Determine NF
ISBN Title
ISBN Publisher
Publisher Address
BOOK
ISBN
Title
Publisher
Address
Example 1: Determine NF
ISBN Title
ISBN Publisher
Publisher
Address
BOOK
ISBN
Title
Publisher
Address
Example 2: Determine NF
Product_ID Description
ORDER
Order_No
Product_ID
Description
Example 2: Determine NF
Product_ID Description
ORDER
Order_No
Product_ID
Description
Example 2: Determine NF
Product_ID Description
ORDER
Order_No
Product_ID
Description
Example 2: Determine NF
Product_ID
Description
In your solution you will write the
following justification:
1) No M/V attributes, therefore at least 1NF
2) There is a partial dependency
(Product_ID Description), therefore not
in 2NF
Conclusion: The relation is in 1NF
ORDER
Order_No
Product_ID
Description
Example 3: Determine NF
Part_ID Description
Part_ID Price
Part_ID, Comp_ID No
PART
Part_ID
Descr
Price
Comp_ID
No
Example 3: Determine NF
Part_ID Description
Part_ID Price
Part_ID, Comp_ID No
PART
Part_ID
Descr
Price
Comp_ID
No
STUDENT
Stud_ID
Name
Course_ID
Units
101
Lennon
MSI 250
3.00
101
Lennon
MSI 415
3.00
125
Johnson
MSI 331
3.00
STUDENT
Stud_ID
Name
Course_ID
Units
101
Lennon
MSI 250
3.00
101
Lennon
MSI 415
3.00
125
Johnson
MSI 331
3.00
Name
Course_ID
Units
101
Lennon
MSI 250
3.00
101
Lennon
MSI 415
3.00
125
Johnson
MSI 331
3.00
Name
101
Lennon
125
Jonson
STUDENT_COURSE
Stud_ID
Course
Units
101
MSI 250
101
MSI 415
125
MSI 331
Composite
Primary Key
STUDENT
Stud_ID
Name
Course_ID
Units
101
Lennon
MSI 250
3.00
101
Lennon
MSI 415
3.00
125
Johnson
MSI 331
3.00
Composite
Primary Key
STUDENT
Stud_ID
Name
Course_ID
Units
101
Lennon
MSI 250
3.00
101
Lennon
MSI 415
3.00
125
Johnson
MSI 331
3.00
Name
Course_ID
Units
101
Lennon
MSI 250
3.00
101
Lennon
MSI 415
3.00
125
Johnson
MSI 331
3.00
STUDENT_COURSE
Stud_ID
Name
Course_ID
Units
101
Lennon
MSI 250
3.00
101
Lennon
MSI 415
3.00
125
Johnson
MSI 331
3.00
Stud_ID
Course_ID
101
MSI 250
101
MSI 415
125
MSI 331
COURSE
STUDENT
Stud_ID
Name
Course_ID
Units
101
Lennon
MSI 250
3.00
101
Lennon
MSI 415
3.00
125
Johnson
MSI 331
3.00
Transitive
Dependency
EMPLOYEE
Emp_ID
F_Name
L_Name
Dept_ID Dept_Name
111
Mary
Jones
Acct
122
Sarah
Smith
Mktg
EMPLOYEE
Emp_ID
F_Name
L_Name
Dept_ID Dept_Name
111
Mary
Jones
Acct
122
Sarah
Smith
Mktg
F_Name
L_Name
Dept_ID Dept_Name
111
Mary
Jones
Acct
122
Sarah
Smith
Mktg
EMPLOYEE
Emp_ID
F_Name
L_Name
Dept_ID
111
Mary
Jones
122
Sarah
Smith
DEPARTMENT
Dept_ID Dept_Name
1
Acct
Mktg