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

Database Normalization

Uploaded by

cleophacerevival
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Database Normalization

Uploaded by

cleophacerevival
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

FUNCTIONAL DEPENDENCIES &

NORMALIZATION
FUNCTIONAL DEPENDENCIES
 What is Functional Dependency
Functional dependency in DBMS, is a relationship between attributes of a
table dependent on each other.

A functional dependency specifies the relationship between two sets of


attributes where one set can accurately determine the value of other sets. It is
denoted as X → Y, where X is a set of attributes that is capable of determining
the value of Y.

II was introduced by E. F. Codd, it helps in preventing data redundancy and


avoid bad database designs.

Consider P is a relation/table with attributes A and B in which attribute B is


dependent on A. Functional Dependency is represented by -> (arrow sign)
FUNCTIONAL DEPENDENCIES…
Functional dependency between attributes is denoted
with an arrow sign.
X -> Y

Terminologies:
Y is functionally dependent on X
X is called the Determinant attribute set
Y is the Dependent attribute set
FUNCTIONAL DEPENDENCIES…
For example suppose we have a Students table table
with four attributes as shown below
reg_no name dept_name dept_building
42 abc CO A4

43 pqr IT A3

44 xyz CO A4

45 xyz IT A3

46 mno EC B2

47 jkl ME B2
FUNCTIONAL DEPENDENCIES…
From the above table we can conclude some valid
functional dependencies:
reg_no → dept_name . Reg no can determine
dept_name . i.e. If you know a student’s reg no, you
can determine their dept_name but not vice versa.

reg_no → { name, dept_name, dept_building }


Here, reg_no can determine values of fields name,
dept_name and dept_building, hence a valid Functional
dependency
FUNCTIONAL DEPENDENCIES…
dept_name → dept_building . Dept_name can
identify the dept_building accurately, since
departments with different dept_name will also have a
different dept_building

More valid functional dependencies:


reg_no → name
{reg_no, name} ⇢ {dept_name, dept_building}
etc
FUNCTIONAL DEPENDENCIES…
Here are some invalid functional dependencies:
name → dept_name Students with the same name can have
different dept_name, hence this is not a valid functional
dependency.
dept_building → dept_name There can be multiple
departments in the same building, For example, in the above
table departments ME and EC are in the same building B2, hence
dept_building → dept_name is an invalid functional dependency.
More invalid functional dependencies:
name → reg_no,
{name, dept_name} → reg_no,
dept_building → reg_no, etc.
FUNCTIONAL DEPENDENCIES…
Armstrong’s axioms of functional dependencies:
 Reflexivity: If Y is a subset of X, then X→Y holds by reflexivity
rule
For example, {reg, name} → name is valid.
 Augmentation: If X → Y is a valid dependency, then XZ → YZ is
also valid by the augmentation rule.
For example, If {reg_no, name} → dept_building is valid, hence
{reg_no, name, dept_name} → {dept_building, dept_name} is
also valid.
 Transitivity: If X → Y and Y → Z are both valid dependencies,
then X→Z is also valid by the Transitivity rule.
For example, reg_no → dept_name & dept_name →
dept_building, then reg_no → dept_building is also valid.
Types of Functional Dependency
Trivial functional dependency
Non-Trivial functional dependency
Multivalued functional dependency
Transitive functional dependency

In this class we will discuss the first two types. You can
read on your own on the last two.
Trivial Functional Dependency
In Trivial Functional Dependency, a dependent is
always a subset of the determinant.
i.e. If X → Y and Y is the subset of X, then it is called
trivial functional dependency
Example

reg_no name age


42 abc 17

43 pqr 18

44 xyz 18
Trivial Functional Dependency…
Here, {reg_no, name} → name is a trivial functional
dependency, since the dependent name is a subset of
determinant set {reg_no, name}
Similarly, reg_no → reg_no is also an example of trivial
functional dependency.
Non-trivial Functional Dependency
In Non-trivial functional dependency, the dependent
is strictly not a subset of the determinant.
i.e. If X → Y and Y is not a subset of X, then it is called
Non-trivial functional dependency.
Example
reg_no name age

42 abc 17

43 pqr 18

44 xyz 18
Non-trivial Functional Dependency…
Here, reg_no → name is a non-trivial functional
dependency, since the dependent name is not a subset
of determinant reg_no
Similarly, {reg_no, name} → age is also a non-trivial
functional dependency, since age is not a subset of
{reg_no, name}
Database Normalization
Normalization is a database design technique that
 reduces data redundancy
 eliminates undesirable characteristics like Insertion,
Update and Deletion Anomalies.

Normalization rules divides larger tables into smaller


tables and links them using relationships. Normalization
makes sure that each table contains only attributes that
are related to the entity.

The purpose of Normalisation is to eliminate redundant


(repetitive) data and ensure data is stored logically.
Database Normalization…
Data redundancy
Data redundancy means storing the same data multiple
times unnecessarily. It wastes storage space.
Anomalies
1- Update Anomaly: Let say we have 10 columns in a
table out of which 2 are called employee Name and
employee address. Now if one employee changes it’s
location then we would have to update the table. But the
problem is, if the table is not normalized one employee
can have multiple entries and while updating all of those
entries one of them might get missed.
Database Normalization…
2- Insertion Anomaly: Let’s say we have a table that has 4
columns. Student ID, Student Name, Student Address and
Student Grades. Now when a new student enroll in school,
even though first three attributes can be filled but 4th attribute
will have NULL value because he doesn't have any marks yet.
3-Deletion Anomaly: This anomaly indicates unnecessary
deletion of important information from the table. Let’s say we
have student’s information and courses they have taken as
follows (student ID,Student Name, Course, address). If any
student leaves the school then the entry related to that student
will be deleted. However, that deletion will also delete the
course information even though course depends upon the
school and not the student.
Database Normalization…
Normalization helps to bring the tables to granular state
where these issues can be avoided. In simple words it
tries to split tables into multiple tables and defines
relationships between them using keys.
DATABASE NORMAL FORMS
The normalization process involves a few steps and each step
is called a form. Forms range from the first normal form
(1NF) to fifth normal form (5NF)
1NF (First Normal Form)
2NF (Second Normal Form)
3NF (Third Normal Form)
4NF (Third Normal Form)
5NF (Third Normal Form)

The most widely used are the 1NF,2NF and 3NF and that is
what we will focus on this course.
1NF (First Normal Form)
Each table cell should contain a single value.
each cell in a table must hold atomic values (Atomic
means single-valued)
For example: If we have a column name phone_number
than each row for that column must save only single
phone number.

Read more on the PDF handount supplied.


2NF (Second Normal Form)
Rule 1- Be in 1NF
Rule 2- Single Column Primary Key that does not
functionally dependant on any subset of candidate key
relation

Read more on the PDF handount supplied.


3NF (Third Normal Form)
Rule 1- Be in 2NF
Rule 2- Has no transitive functional dependencies

Read more on the PDF handount supplied.


DATA WAREHOUSING
Background
A Relational Database Management System (RDBMS) stores
data in the form of tables. For example, a DBMS of college has
tables for students, faculty, etc.

A Data Warehouse is separate from DBMS, it stores a huge


amount of data, which is typically collected from multiple
heterogeneous sources like files, DBMS, etc. The goal is to
produce statistical results that may help in decision makings.
For example, a college might want to see quick different
results, like how is the placement of CS students has improved
over the last 10 years, in terms of salaries, counts, etc.
DATA WAREHOUSING…
Background
A Relational Database Management System (RDBMS) stores
data in the form of tables. For example, a DBMS of college has
tables for students, faculty, etc.

A Data Warehouse is separate from DBMS, it stores a huge


amount of data, which is typically collected from multiple
heterogeneous sources like files, DBMS, etc. The goal is to
produce statistical results that may help in decision makings.
For example, a college might want to see quick different
results, like how is the placement of CS students has improved
over the last 10 years, in terms of salaries, counts, etc.
DATA WAREHOUSING…
Need of Data Warehouse
An ordinary Database can store MBs to GBs of data and
that too for a specific purpose. For storing data of TB
size, the storage shifted to Data Warehouse. Besides this,
a transactional database doesn’t offer itself to analytics.
To effectively perform analytics, an organization keeps a
central Data Warehouse to closely study its business by
organizing, understanding, and using its historic data
for taking strategic decisions and analyzing trends.
DATA WAREHOUSING…
Data warehouse vs Database
DATA WAREHOUSING…
Example Applications of Data Warehousing
Data Warehousing can be applied anywhere where we have a huge
amount of data and we want to see statistical results that help in
decision making.

 Social Media Websites: The social networking websites like


Facebook, Twitter, Linkedin, etc. are based on analyzing large data
sets. These sites gather data related to members, groups, locations,
etc., and store it in a single central repository. Being a large amount of
data, Data Warehouse is needed for implementing the same.
 Banking: Most of the banks these days use warehouses to see the
spending patterns of account/cardholders. They use this to provide
them special offers, deals, etc.
 Government: Government uses a data warehouse to store and
analyze tax payments which are used to detect tax thefts.
You can read more on these topics on these links:

Normalization: https://
towardsdatascience.com/softly-explained-data-normaliz
ation-data-anomalies-and-dbms-keys-f8122aefaeb3
Functional Dependency:
https://www.geeksforgeeks.org/types-of-functional-dep
endencies-in-dbms
/
Data Warehousing:
https://www.geeksforgeeks.org/data-warehousing/
-THE END-
THANK YOU

You might also like