0% found this document useful (0 votes)
47 views68 pages

of Chapter-2.1 Functional Dependencies and Normalization

The document outlines a course on Database Management Systems (DBMS) taught by Dr. Gitanjali, focusing on data structure, integrity, and SQL query construction. It details course outcomes, objectives, and key topics including functional dependencies, normalization, and various types of dependencies. Additionally, it emphasizes the importance of understanding these concepts for effective database design and management.

Uploaded by

anshumanvats270
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views68 pages

of Chapter-2.1 Functional Dependencies and Normalization

The document outlines a course on Database Management Systems (DBMS) taught by Dr. Gitanjali, focusing on data structure, integrity, and SQL query construction. It details course outcomes, objectives, and key topics including functional dependencies, normalization, and various types of dependencies. Additionally, it emphasizes the importance of understanding these concepts for effective database design and management.

Uploaded by

anshumanvats270
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 68

UNIVERSITY INSTITUTE OF

ENGINEERING

Department of Computer Science & Engineering

Databases Management System


(23CSH-205/23ITH-205)
DR. GITANJALI
E16525
ASSISTANT PROFESSOR DISCOVER . LEARN . EMPOWER
CSE
ABOUT COURSE
• The main DBMS course, we learn about the structural formation of data, maintain data
integrity, multitasking with concurrent access and recovery without occurring crashes,
data structures, data models etc. and their working in which every organization is
based.
• At the end of the course, the students may understand the concepts of data structures,
data models and design, construction of queries by using SQL, uses and applications of
database design etc

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


COURSE OUTCOMES

CO No. Title BT Level


Will be covered in this
lecture
Students will be able to understand the database system
CO1
concepts and design databases for different applications.
Memorize

Students will be able to identify different types of DDL, DML,


CO2 DCL and TCL commands and their usage. Understanding

Students will be able to classifying Normalization,


CO3 Dependencies and Denormalization along with their Apply
requirements.
Students will be able to analyse and Compare Transaction
CO4
Processing techniques and Recovery techniques.
Analyze
Students will be able to evaluate database performance after
CO5 implementing Triggers, procedures, packages, cursors and Evaluate
views.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


COURSE OBJECTIVES

This course will enable students to,

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.

Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


12/20/2024
Topics covered

Functional dependencies and Normalization:


Functional dependencies, Decomposition, Full Functional Dependency (FFD),
Transitive Dependency (TD), Join Dependency (JD), Multi-valued Dependency
(MVD), Normal Forms (1NF, 2NF, 3NF, BCNF), De-normalization.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Key terms
Here, are some key terms for functional dependency:

Key Terms Description


Axiom Axioms is a set of inference rules used to infer all the
functional dependencies on a relational database.

Decomposition It is a rule that suggests if you have a table that appears to


contain two entities which are determined by the same primary
key then you should consider breaking them up into two
different tables.

Dependent It is displayed on the right side of the functional dependency


diagram.
Determinant It is displayed on the left side of the functional dependency
Diagram.
Union It suggests that if two tables are separate, and the PK is the
same, you should consider putting them. together

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Types of Dependency

 Functional Dependency
 Partial Dependency
 Fully Functional Dependency
 Multivalued dependency
 Transitive dependency

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency
A dependency function (FD) is a database constraint
that determines the relationship of one attribute to
another in a database management system
(DBMS). Functional dependencies help maintain the
quality of data in the database. Functional
dependence is a relationship that exists between
two attributes. It usually exists between the primary
key and non-prime attributes in the table.
Example: X -> Y
In this case, the left side of the arrow is the
determinant and the right of the arrow is dependent.
X will be the primary attribute and Y will be a non-
prime attribute of the table. It shows that the
attributes of column X uniquely identify the attribute
of column Y to satisfy this functional dependency.
12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Functional Dependency
How to represent functional dependency in DBMS?
Functional Dependency is expressed in the form
of equations. Here you have an array of objects
(A, B, C, etc.) and an arrow (->) that represents
the dependency. For example, if we have an
employee record with fields "EmployeeID",
"FirstName" and "LastName", we can specify the
function as follows:

EmployeeID -> FirstName, LastName


To represent functional dependency in DBMS
has two main features: left (LHS) and right
(RHS) of the arrow (->).

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency
Types of Functionality in DBMS
Trivial Functional Dependency: Trivial functional dependency occurs when an
attribute or attributes (columns) appear in the DBMS. When the (->) function is
present, the left element (LHS) already determines the right element (RHS)
without additional information.
Example: Suppose we have a student table with attributes "EmployeeID" and
"EmployeeName". In this case, if we declare the dependency function as
EmployeeID -> EmployeeName
It will be a rivial functional dependency. Because there is only one
"EmployeeName" in "EmployeeID". That is, the value of "EmployeeID"
determines the value of "EmployeeName" without the need for any additional
information or conditions.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency
Non-trivial Functional Dependency
Non-trivial functional dependencies are a type of dependency between
attributes (columns) in a table. Here the relationship is neither obvious nor
important. It provides valuable information about how values ​in one feature set
determine values ​in another feature set.
Example: Here is the functional dependency based on the employee's date of
birth (EmployeeDOB) and Department. In this case the non-trivial dependency
will be
EmployeeDOB, Department -> EmployeeName.
In this functional dependency given combination of employee's date of birth and
class can uniquely determines employee names. It is important because it
provides important information about the relationship between attributes in the
language.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency
Properties of Functional Dependency in DBMS
• Reflexivity: If A is a set of attributes and B is a part of A, then the function A
-> B is valid.
• Augmentation: If the A -> B dependency is valid, adding multiple elements
to either side of the dependency will not affect the dependency.
• Transitivity: If the functions X → Y and Y → Z are both valid, then X → Z is
also valid according to the transitivity rule.
Advantages of functional dependency in
• Data Integrity DBMS
• Normalization
• Effective Storage
• Easy to maintain

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Decomposition
What is Decomposition in DBMS?
When we divide a table into multiple tables or divide a relation into multiple
relations, then this process is termed Decomposition in DBMS. We perform
decomposition in DBMS when we want to process a particular data set. It is
performed in a database management system when we need to ensure
consistency and remove anomalies and duplicate data present in the
database. When we perform decomposition in DBMS, we must try to ensure
that no information or data is lost.
Types of Decomposition
There are two types of Decomposition:
• Lossless Decomposition
• Lossy Decomposition

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Decomposition
Properties of Decomposition
• Lossless: All the decomposition that we perform in Database
management system should be lossless. All the information should not be
lost while performing the join on the sub-relation to get back the original
relation. It helps to remove the redundant data from the database.
• Dependency Preservation: Dependency Preservation is an important
technique in database management system. It ensures that the functional
dependencies between the entities is maintained while performing
decomposition. It helps to improve the database efficiency, maintain
consistency and integrity.
• Lack of Data Redundancy: Data Redundancy is generally termed as
duplicate data or repeated data. This property states that the
decomposition performed should not suffer redundant data. It will help us
to get rid of unwanted data and focus only on the useful data or
information.
12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Fully Functional Dependency
What is Fully Functional Dependency?
Real-life dependencies emerge when, within one relationship, the value of
one of the attributes is capable of identifying the value of another attribute.
Simply put, if A fully determines B without any proper subset of A giving full
cause to B, then A is said to fully depend on B. In other words, you cannot
derive B from a smaller part of A.
An Example of Fully Functional Dependency
To visualize a relation called "Employee” with
the attributes {Employee_ID, Employee_Name,
Department, Salary}, use the following diagram:
Basically, if that the Employee_ID attribute
figures out the other attributes in the table, such
as the Employee_Name, Department, and
Salary, the Employee_ID attribute fully
functionally depends on all these attributes.
12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Fully Functional Dependency
Importance of Fully Functional Dependency
• Data Integrity: Instantaneous reference derives ones and only one value from
others on the elements, which provides data integrity.
• Normalization: Finding and ensuring all the relationships are incomplete for
one (and only one) of the attributes is the central part of the normalization
process. It plays a role in recording large tables into smaller, structured tables,
which reduces redundancy and helps people to handle transactions
successfully.
• Efficient Queries: Databases with well-thought-out dependencies that provide
maximum functionality are usually the ones that tend to outperform in query
response. In the data has a logical structure, the search process becomes
faster as time goes by.
• Update Anomalies: All major operations will be enabled by this through
reduced anomalies in updates. An update anomaly happens when performing
an action on one attribute results in the ratification other attributes or errors.
12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Functional 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.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency

A Full Dependency occurs when a non-prime attribute depends on all parts of


a composite primary key and not just a subset.
Example:
• OrderID, ProductID, Quantity
Quantity depends on both OrderID and ProductID.
This is a Full Dependency because Quantity depends on the entire composite
primary key.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency
Transitive Dependency
• If the value of a non-primary attribute can be defined using another non-
primary attribute, then it is called a transitive dependency.
• When any attribute does not require primary key and can easily get value
using another non-primary attribute then it is called as Transitive
Dependency.

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 .

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Functional Dependency

• Here the primary key is roll_no but we can


identify the city using zip-code where city
and zip-code both are the primary key
• So here roll_no → city and city→zip-code
eventually resulting into roll_no →zip-code.
so, we can find a non-primary attribute
using another non-primary attribute. For
example, roll-no = 1 has city=pune and
city=pune will have zip-code=411044.So
wherever city is pune , zip-code will be
411044
• This type of functional Dependency is
known as Transitive Dependency.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Join Dependency
• Join Dependency (JD) can be illustrated as when the relation R is equal to
the join of the sub-relations R1, R2,..., and Rn are present in the database.
Join Dependency arises when the attributes in one relation are dependent
on attributes in another relation, which means certain rows will exist in the
table if there is the same row in another table. Multiple tables are joined to
create a single table where one of the attributes is common in the sub-
tables. We can also relate the join dependency to the 5th Normal Form. A
join dependency is said to be not that important if any relational schemas in
the join dependency are equivalent to the original relation R.
• Join dependency on a database is denoted by:
R1 ⨝ R2 ⨝ R3 ⨝ ..... ⨝ Rn ;

where R1 , R2, ... , Rn are the relations and ⨝ represents the natural join
operator.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Join Dependency
Types of Join Dependency
There are two types of Join Dependencies:
• Lossless Join Dependency: It means that whenever the join occurs between the tables,
then no information should be lost, the new table must have all the content in the original
table.
• Lossy Join Dependency: In this type of join dependency, data loss may occur at some
point in time which includes the absence of a tuple from the original table or duplicate
tuples within the database.
Importance of Join Dependencies
Data Integrity: Join Dependency helps maintain data integrity in a database. Database
designers can make sure that the queries are consistent after checking for the dependencies.
This will remove the data that is not accurate.
Query Optimization: Query optimization leads to improving the performance of the database
system. The database designers can choose the best join order to execute the queries which
in turn reduces the computational costs, memory utilization and i/o operations to get the
queries executed quickly.
12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Multivalued Dependency
Multivalued Dependency
When one attribute in a database depends on another attribute and has many
independent values, it is said to have multivalued dependency (MVD). It
supports maintaining data accuracy and managing intricate data interactions.
Example of Multivalued Dependency:

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Introduction to Normalization
• Normalization: Process of decomposing unsatisfactory "bad"
relations by breaking up their attributes into smaller relations
• Normalization is the process of removing redundant data from your
tables in order to improve storage efficiency, data integrity and
scalability.
• This improvement is balanced against an increase in complexity and
potential performance losses from the joining of the normalized tables
at query-time.
• There are two goals of the normalization process: eliminating
redundant data (for example, storing the same data in more than one
table) and ensuring data dependencies make sense (only storing
related data in a table). Both of these are worthy goals as they reduce
the amount of space a database consumes and ensure that data is
logically stored.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Introduction to Normalization
Normal form: Condition using keys and FDs of a relation to certify
whether a relation schema is in a particular normal form
– 2NF, 3NF, BCNF based on keys and FDs of a relation schema
– 4NF based on keys, multi-valued dependencies
There is a sequence to normal forms:
– 1NF is considered the weakest,
– 2NF is stronger than 1NF,
– 3NF is stronger than 2NF, and
– BCNF is considered the strongest

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.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


WHY WE NEED NORMALIZATION?
Normalization is the aim of well design Relational Database Management
System (RDBMS). It is step by step set of rules by which data is put in its
simplest forms. We normalize the relational database management
system because of the following reasons:

❑ Minimize data redundancy i.e. no unnecessarily duplication of data.


❑ To make database structure flexible i.e. it should be possible to add
new data values and rows without reorganizing the database
structure.
❑ Data should be consistent throughout the database i.e. it should not
suffer from following anomalies.
❑ Complex queries required by the user should be easy to handle.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Types of Normalization

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


1 Normal Form
As per the rule of first normal form, an attribute (column) of a table cannot
hold multiple values. It should hold only atomic values.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


First Normal Form
• Disallows composite attributes, multivalued attributes, and nested
relations; attributes whose values for an individual tuple are non-
atomic.

• We say a relation is in 1NF if all values stored in the relation are


single-valued and atomic.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Normal Forms in DBMS

Example 1 – Relation STUDENT in table 1 is not in 1NF because of multi-


valued attribute STUD_PHONE. Its decomposition into 1NF has been shown in
table 2.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


First Normal Form (1NF)

• An outer join between Employee and EmployeeDegree will produce


the information we saw before

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Implication of INF

❖ You must have single value in a single column, null value can be

present.

❖ Order of row and order of column is insignificant.

❖ Every value must belong to same domain.

❖ Every column should have unique name.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Second Normal Forms
A relation is in 2NF if it is in 1NF and any non-prime attribute (attributes which
are not part of any candidate key) is not partially dependent on any proper
subset of any candidate key of the table. In other words, we can say that, every
non-prime attribute must be fully dependent on each candidate key.
A functional dependency X->Y (where X and Y
are set of attributes) is said to be in partial Second Normal Form
dependency, if Y can be determined by any
proper subset of X.
However, in 2NF it is possible for a prime
attribute to be partially dependent on any
candidate key, but every non-prime attribute
must be fully dependent(or not partially
dependent) on each candidate key of the table.
12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Example 2 – Consider following functional dependencies in relation R (A, B , C,
D)

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.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Second Normal Form
• A relation is in 2NF if it is in 1NF, and every non-key attribute
is fully dependent on each candidate key. (That is, we don’t
have any partial functional dependency.)

• 2NF (and 3NF) both involve the concepts of key and non-key
attributes.

• A key attribute is any attribute that is part of a key; any


attribute that is not a key attribute, is a non-key attribute .

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Second Normal Form

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Third Normal Form

A relation is in the third normal form, if there is no transitive dependency for


non-prime attributes as well as it is in the second normal form. A relation is in
3NF if at least one of the following conditions holds in every non-trivial function
dependency X –> Y.
X is a super key.
Y is a prime attribute (each element of Y is part of some candidate key).

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).

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Third Normal Form
The normalization of 2NF relations to 3NF involves the removal of transitive
dependencies. If a transitive dependency exists, we remove the transitively
dependent attribute(s) from the relation by placing the attribute(s) in a new
relation along with a copy of the determinant. Consider the examples given
below. Y is a prime attribute (each element of Y is part of some candidate key).

Example 2: Consider Relation R(A, B, C, D, E)

All possible candidate keys in above relation are


{A, E, CD, BC} All attribute are on right sides of
all functional dependencies are prime.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Third Normal Form
• A database is in third normal form if it satisfies the following
conditions:
• It is in second normal form
• There is no transitive functional dependency

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.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Third Normal Form
• In the table able, [Book ID] determines [Genre ID], and [Genre ID]
determines [Genre Type]. Therefore, [Book ID] determines [Genre
Type] via [Genre ID] and we have transitive functional dependency,
and this structure does not satisfy third normal form.
• To bring this table to third normal form, we split the table into two as
follows:

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].

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


The 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.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


EXAMPLE
Consider this
table:
FD set:
{STUD_NO -> STUD_NAME, STUD_NO -> STUD_STATE, STUD_STATE ->
STUD_COUNTRY, STUD_NO -> STUD_AGE}

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:

STUDENT (STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,


STUD_AGE) STATE_COUNTRY (STATE, COUNTRY)

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


BCNF (Boyce-Codd Normal Form)
For a table to be in BCNF, following conditions must be satisfied:
• R must be in 3rd Normal Form
• and, for each functional dependency ( X -> Y ), X should be a super
Key.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Rules for BCNF
Rule 1: The table should be in the 3rd Normal Form.
Rule 2: X should be a superkey for every functional dependency (FD) X−>Y in a
given relation.

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).

Boyce-Codd Normal Form (BCNF) An


advanced version of the third normal form,
which is a little more strict. This is a tougher
criterion that helps eliminate redundancy and
anomalies from your Database. BCNF
(Boyce-Codd Normal Form) is a further
refinement of the third normal form which
simplifies our database design.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Example:

For example consider relation R(A, B, C)


A -> BC, B -> A
A and B both are super keys so above relation is in BCNF.

Note –

BCNF decomposition may always not possible with dependency


preserving, however, it always satisfies lossless join condition. For
example, relation R (V, W, X, Y, Z), with functional dependencies:
V, W -> X Y, Z -> X W -> Y
It would not satisfy dependency preserving BCNF decomposition.

Note -:Redundancies are sometimes still present in a BCNF relation as it


is not always possible to eliminate them completely.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Boyce Codd Normal Form
In BCNF:
❖ When a relation has more than one candidate key, anomalies may result even though the
relation is in 3NF.
❖ 3NF does not deal satisfactorily with the case of a relation with overlapping candidate keys
❖ i.e. composite candidate keys with at least one attribute in common.
❖ BCNF is based on the concept of a determinant.
❖ A determinant is any attribute (simple or composite) on which some other attribute is fully
functionally dependent.
❖ A relation is in BCNF is, and only if, every determinant is a candidate key.
❖ Definition: A relation is in Boyce-Codd Normal Form (BCNF) if every determinant is a
candidate key.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


EXAMPLE
It (like, chomsky hierarchy) can be inferred
that every relation in BCNF is also in 3NF. To put it
another way, a relation in 3NF need not to be in
BCNF. Ponder over this statement for a while.
To determine the highest normal form of a given
relation R with functional dependencies, the first
step is to check whether the BCNF condition holds.
If R is found to be in BCNF, it can be safely
deduced that the relation is also in 3NF, 2NF and
1NF as the hierarchy shows. The 1NF has the
least restrictive constraint – it only requires a
relation R to have atomic values in each tuple. The
2NF has a slightly more restrictive constraint. The
3NF has more restrictive constraint than the first
two normal forms but is less restrictive than the
BCNF. In this manner, the restriction increases as
we traverse down the hierarchy.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Fourth Normal Form
• A relation will be in 4NF if it is in Boyce Codd normal form
and has no multi-valued dependency.
• For a dependency A → B, if for a single value of A, multiple
values of B exists, then the relation will be a multi-valued
dependency.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


4th Normal Form
An entity is in Fourth Normal Form (4NF) when it meets the requirement of being in
Third Normal Form (3NF) and additionally: Has no multiple sets of multi-valued
dependencies.

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.

Fourth Normal Form applies to situations involving many-to-many relationships.

In relational databases, many-to-many relationships are expressed through cross-


reference tables.

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.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Example: 4th NF
Consider the database table of a class which has two relations R1 contains
student ID(SID) and student name (SNAME) and R2 contains course id(CID)
and course name (CNAME).

Table – R1(SID, SNAME) Table – R2(CID, CNAME) Table – R1 X R2

SID SNAME CID CNAME SNA CNA


SID CID
ME ME
S1 A C1 C
S1 A C1 C
S2 B C2 D
S1 A C2 D
S2 B C1 C
When there cross product is done it
resulted in multivalued dependencies: S2 B C2 D

Multivalued dependencies (MVD) are:


SID->->CID; SID->->CNAME; SNAME->->CNAME

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Fourth Normal Form
Let us see an example −
<Movie>
Movie_Nam Shooting_Loc Listing
The above is not in 4NF, e ation
since
•Many shooting
MovieOne UK Comedy
locations can have the
same movie
MovieOne UK Thriller
•More than one movie
can have the same MovieTwo Australia Action
listing
MovieTwo Australia Crime

MovieThree India Drama

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Fourth Normal Form
Movie_Name Shooting_Location

MovieOne UK

MovieOne UK
Let us convert the
above table in 4NF MovieTwo Australia

− MovieTwo Australia

<Movie_Shooting> MovieThree India


<Movie_Listing>
Now the violation is
Movie_Name Listing
removed and the
MovieOne Comedy
tables are in 4NF.
MovieOne Thriller

MovieTwo Action

MovieTwo Crime

MovieThree Drama

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Fifth Normal Form
The 5NF (Fifth Normal Form) is also known as
project-join normal form. A relation is in Fifth Normal EmpName EmpSkills EmpJob (As
Form (5NF), if it is in 4NF, and won’t have lossless signed Work)
decomposition into smaller tables.
You can also consider that a relation is in 5NF, if the David Java E145
candidate key implies every join dependency in it.
Example John JavaScript E146
The below relation violates the Fifth Normal Form
(5NF) of Normalization − Jamie jQuery E146
<Employee>
The above relation can be decomposed into the Emma Java E147
following three tables; therefore, it is not in 5NF −

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Fifth Normal Form
EmployeeSkills> EmpName EmpSkills
The following is the <EmployeeJob> relation that displays
the jobs assigned to each employee − David Java
<EmployeeJob>
Here is the skills that are related to the assigned jobs −
John JavaScript
<JobSkills>
Our Join Dependency −
The above relations have join dependency, so they are Jamie jQuery
not in 5NF. That would mean that a join relation of the
above three relations is equal to our original
Emma Java
relation <Employee>.

EmpName EmpJob

David E145
EmpSkills EmpJob
John E146
Java E145
Jamie E146
JavaScript E146
Emma E147
jQuery E146

Java E147

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


5th Normal Form
In 5th NF:

A relation that has a join dependency cannot be decomposed by a projection into


other relations without spurious results
A relation is in 5NF when its information content cannot be reconstructed from
several smaller relations i.e. from relations having fewer attributes than the original
relation
Definition: A table is in fifth normal form (5NF) or Project-Join Normal Form (PJNF)
if it is in 4NF and it cannot have a lossless decomposition into any number of
smaller tables.

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.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


A relation R is in 5NF if and only if every join dependency in R is implied by
the candidate keys of R. A relation decomposed into two relations must have
loss-less join Property, which ensures that no spurious or extra tuples are
generated, when relations are reunited through a natural join.

Properties – A relation R is in 5NF if and only if it satisfies following


conditions:
❖ R should be already in 4NF.
❖ It cannot be further non loss decomposed (join dependency)
Example – Consider the AGENT COMPANY PRODUCT
schema, with a case as “if A1 PQR Nut
a company makes a
product and an agent is an A1 PQR Bolt
agent for that company, A1 XYZ Nut
then he always sells that
product for the company”. A1 XYZ Bolt
Under these PQR
A2 Nut
circumstances, the ACP
table is shown as: Table – ACP

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


The relation ACP is again decompose into 3 relations. Now, the natural Join of all
the three relations will be shown as:
Table – R1 Table – R2 Table – R3

AGENT COMPANY AGENT PRODUCT COMPANY PRODUCT


A1 PQR A1 Nut PQR Nut
A1 XYZ A1 Bolt PQR Bolt

A2 PQR XYZ Nut


A2 Nut
XYZ Bolt

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.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Denormalization in Databases
Denormalization is a database optimization technique in which we add redundant
data to one or more tables. This can help us avoid costly joins in a relational
database. Note that denormalization does not mean ‘reversing normalization’ or
‘not to normalize’. It is an optimization technique that is applied after normalization.
Basically, The process of taking a normalized schema and making it non-
normalized is called denormalization, and designers use it to tune the performance
of systems to support time-critical operations.
How is Denormalization Different From Normalization ?
One side normalization is used for reduce or removing the redundancy which
means there will be no duplicate data or entries in the same table and also
optimizes for data integrity and efficient storage, while Denormalization is used for
add the redundancy into normalized table so that enhance the functionality and
minimize the running time of database queries (like joins operation ) and optimizes
for performance and query simplicity.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


Denormalization in Databases
Advantages of Denormalization
• Improved Query Performance: Denormalization can
improve query performance by reducing the number of joins
required to retrieve data.
• Reduced Complexity: By combining related data into fewer
tables, denormalization can simplify the database schema
and make it easier to manage.
• Easier Maintenance and Updates: Denormalization can
make it easier to update and maintain the database by
reducing the number of tables.
• Improved Read Performance: Denormalization can improve
read performance by making it easier to access data.
• Better Scalability: Denormalization can improve the
scalability of a database system by reducing the number of
tables and improving the overall performance.
12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University
Denormalization in Databases
Disadvantages of Denormalization
• Reduced Data Integrity: By adding redundant data,
denormalization can reduce data integrity and increase the
risk of inconsistencies.
• Increased Complexity: While denormalization can simplify
the database schema in some cases, it can also increase
complexity by introducing redundant data.
• Increased Storage Requirements: By adding redundant
data, denormalization can increase storage requirements
and increase the cost of maintaining the database.
• Increased Update and Maintenance Complexity:
Denormalization can increase the complexity of updating
and maintaining the database by introducing redundant
data.

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University


THANK YOU

12/20/2024 Dr. Gitanjali , Asst. Prof., UIE-CSE, Chandigarh University

You might also like