of Chapter-2.1 Functional Dependencies and Normalization
of Chapter-2.1 Functional Dependencies and Normalization
ENGINEERING
1. To have good understanding of database system concepts and design databases for
different applications.
2. To learn how to use a DBMS and RDBMS.
3. To implement and understand different types of DDL, DML and DCL statements.
4. To understand transaction concepts related to databases and recovery/backup
techniques required for the proper storage of data.
Functional Dependency
Partial Dependency
Fully Functional Dependency
Multivalued dependency
Transitive dependency
Types of Dependencies
• Partial Dependency
• Full Dependency
• Transitive Dependency
A Partial Dependency occurs when a non-prime attribute (an attribute that is
not part of any candidate key) depends on part of a composite primary key
rather than the whole key.
OrderID, ProductID, ProductName, Quantity
OrderID and ProductID together form the composite primary key.
ProductName depends only on ProductID (not on the whole composite key).
This is a Partial Dependency because ProductName is determined by a part of
the composite key (ProductID), not the entire key.
Example
Let's take an example, we have a table where we have
columns of student roll number, name, city where student live,
and zip-code of city .
where R1 , R2, ... , Rn are the relations and ⨝ represents the natural join
operator.
Also,
– any relation that is in BCNF, is in 3NF;
– any relation in 3NF is in 2NF; and
– any relation in 2NF is in 1NF.
❖ You must have single value in a single column, null value can be
present.
In the above relation, AB is the only candidate key and there is no partial
dependency, i.e., any proper subset of AB doesn’t determine any non-prime
attribute.
• 2NF (and 3NF) both involve the concepts of key and non-key
attributes.
In other words,
A relation that is in First and Second Normal Third Normal Form
Form and in which no non-primary-key
attribute is transitively dependent on the
primary key, then it is in Third Normal Form
(3NF).
Definition
• Transitive functional dependency – if there a set of atribute
Z that are neither a primary or candidate key and both X –> Z
and Y –> Z holds.
Now all non-key attributes are fully functional dependent only on the primary
key. In [TABLE_BOOK], both [Genre ID] and [Price] are only dependent on
[Book ID]. In [TABLE_GENRE], [Genre Type] is only dependent on [Genre ID].
Candidate Key:
{STUD_NO}
For this relation in table , STUD_NO -> STUD_STATE and STUD_STATE ->
STUD_COUNTRY are true. So STUD_COUNTRY is transitively dependent
on STUD_NO. It violates the third normal form. To convert it in third normal
form, we will decompose the relation STUDENT (STUD_NO, STUD_NAME,
STUD_PHONE, STUD_STATE, STUD_COUNTRY_STUD_AGE) as:
Example
Find the highest normal form of a relation R(A, B, C, D, E) with FD set as:
Explanation:
Step-1: As we can see, (AC)+ ={A, C, B, E, D} but none of its subsets can
determine all attributes of the relation, So AC will be the candidate key. A or C
can’t be derived from any other attribute of the relation, so there will be only 1
candidate key {AC}.
Step-2: Prime attributes are those attributes that are part of candidate key {A, C}
in this example and others will be non-prime {B, D, E} in this example.
Step-3: The relation R is in 1st normal form as a relational DBMS does not allow
multi-valued or composite attributes.
12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Boyce-Codd Normal Form (BCNF)
Although, 3NF is an adequate normal form for relational databases, this (3NF)
normal form may not remove 100% redundancy because of X−>Y functional
dependency if X is not a candidate key of the given relation. This can be solved
by the Boyce-Codd Normal Form (BCNF).
Note –
In other words, 4NF states that no entity can have more than a single one-to-many
relationship within an entity if the one-to-many attributes are independent of each
other.
Definition: A table is in fourth normal form (4NF) if and only if it is in BCNF and
contains no more than one multi-valued dependency.
MovieOne UK
MovieOne UK
Let us convert the
above table in 4NF MovieTwo Australia
− MovieTwo Australia
MovieTwo Action
MovieTwo Crime
MovieThree Drama
EmpName EmpJob
David E145
EmpSkills EmpJob
John E146
Java E145
Jamie E146
JavaScript E146
Emma E147
jQuery E146
Java E147
Fifth normal form, also known as join-projection normal form (JPNF), states that no
non-trivial join dependencies exist. 5NF states that any fact should be able to be
reconstructed without any anomalous results in any case, regardless of the number
of tables being joined. A 5NF table should have only candidate keys and it's primary
key should consist of only a single column.
Result of Natural Join of R1 and R3 over ‘Company’ and then Natural Join of R13
and R2 over ‘Agent’and ‘Product’ will be table ACP.
Hence, in this example, all the redundancies are eliminated, and the
decomposition of ACP is a lossless join decomposition. Therefore, the relation is in
5NF as it does not violate the property of lossless join.