Professional Documents
Culture Documents
DBMS Mod 5
DBMS Mod 5
DBMS Mod 5
The normalization in the DBMS can be defined as a technique to design the schema of a
database and this is done by modifying the existing schema which also reduces the redundancy
and dependency of the data.
So with Normalization, the unwanted duplication in data is removed along with the anomalies.
In insert anomaly, the values such as null are not allowed to be inserted for a column.
In update anomaly, the data cannot be updated correctly because the same values occur multiple
times in a column and in delete anomaly the deletion of a record creates inconsistency as it gets
deleted from more than one row.
So the aim of normalization is to remove redundant data as well as storing only related data in
the table. This decreases the database size and the data gets logically stored in the database.
In simple words we can say,
Normalization is the process of organizing data to minimize.
Redundancy/duplication/repetition.
Insertion, deletion, updating anomalies.
Normalization Basics
Normalization is basically a process which involves two steps. These are:
Put the data into a tabular form so as to eliminate repeating groups.
Remove any kind of duplication from the related tables.
Advantages of Normalization
Lossless join or non-additive property − It guarantees that the spurious tuples are not
generated with respect to the relation schemas created after decomposition.
Dependency preservation property − It ensures that every functional dependency is
represented in some of the individual relations resulting after decomposition.
Denormalization − It is the process of storing the join of higher normal form relations as a
base relation- which is in a lower normal form.
Functional Dependency in DBMS
The term functional dependency means the association between any two attributes.
Typically, this relationship is demonstrated between the primary key and non-key attributes
within the table of a Database Management System, where the non-key attribute is
functionally dependent on the primary key attribute to operate.
A Functional Dependency case in a table is termed as ‘Minimal’ if the non- key attribute has
dependencies on the primary key attribute with the functional characteristics such as there is
only one non-key attribute in the table, any change made in the primary key attribute brings
in changes to the non-key attribute as well, and if any alteration made on the functional
dependencies will affect the table contents of the primary key.
• Here, the left side of the arrow is identified as a Determinant, while the right side of the
arrow is identified as a Dependent.
• X will always be the primary key attribute and Y will be any dependent non- key
attribute from the same table as the primary key.
• This shows Y non-key attribute is functionally dependent on the X primary key attribute.
In other words, If column X attribute of the table uniquely identifies the column Y
attribute of the same table, then the functional dependency of the column Y on the
column X is symbolized as X → Y.
Student_ID → Student_Name Student_ID → Dept Student_ID → DOB
2. Trivial Functional Dependency in DBMS
The Trivial Functional Dependency is a set of attributes or columns that are known as trivial if the non-
key-dependent attribute is a subset of the determinant attribute, which is a primary key attribute.
This Trivial Functional Dependency scenario occurs when the primary key is formed by two columns,
and one of which is functionally dependent on the combined set.
X → Y, is a trivial functional dependency, if Y is a subset of X. Let us consider the below table,
Here, if the primary key is a combination of the columns Student_ID and Student_Name, then
the Student_Name column is in Trivial Functional Dependency relationship with the primary
key set [Student_ID, Student_Name].
Any changes made in the Student_Name column will have its effects on the primary key set
[Student_ID, Student_Name], as the Student_Name column is a subset of the primary key
attribute set.
For a Student ID, S_001, the primary key combination will be [S_001, Sname01]. If a change
to the name is made as Sname001, then the primary key combination will change as [S_001,
Sname001], as the Student_Name column is a subset of the primary key.
Here, if the primary key is the column Student_ID, and the Student_Name column is not a subset of
Student_ID, then the Student_Name column is in a non Trivial Functional Dependency relationship with the
primary key Student_ID.
4. Transitive Functional Dependency in DBMS
A Transitive Functional Dependency is a type of functional dependency which happens when the non- key
attribute is indirectly formed by its functional dependencies on the primary key attributes.
Either the value or the known factors can be the reason for this type of Functional Dependency occurrence.
The Transitive Functional Dependency can only occur in a relation of three or more non-key attributes that
are functionally dependent on the primary key attribute.
In this table, the Student_ID column is the primary key.
The values in the Student_ID column are formed by the combination of the first letter
from the Student_Name column, last code from the Dept column and date & month from
the DOB column.
If any change is made in any of these columns will reflect changes in the primary key
column, that is, the Student_ID column.
Any new record inserted in this table will also have a Student_ID value formed from the
combination of the other three non-key columns.
What is 1NF in DBMS?
A relation will be 1NF if it contains an atomic value.
It states that an attribute of a table cannot hold multiple values. It must hold only single-valued
attribute.
First normal form disallows the multi-valued attribute, composite attribute, and their
combinations.
Requirements
1. The Attributes must be Single Valued
Every column in your table must be single-valued. It means that no columns should have
multiple values in a single cell. In case we don’t have single values in a cell, we won’t be able to
call it 1NF.
For instance, if we take a look at a table that consists of data regarding a single novel and its
writers, and it has the following columns: [Book ID], [Writer 1], [Writer 2], and [Writer 3]. In
this case, [Writer 1], [Writer 2], and [Writer 3] repeat the same attribute. They do not refer to
different Book 1Ds. Thus, this table would not be in 1NF.
2. The Domain of attributes must not change
Every value stored in every table column must be of the same type/ kind. Random values should not make
up the table.
For instance, if a table consists of a column named DOB that saves the date of birth of various people, we
cannot use this column to save the names of these people. We need a separate column for that. Every
column must hold separate sets of attributes in a DBMS table.
3. Every Column/ Attribute must have a Unique Name
A 1NF table expects that every column present in a table consists of a unique name of its own. This way, it
becomes feasible to avoid any confusion while the system is retrieving, editing, or adding data, or
performing any other operations on the table. In case multiple columns have a similar name, then the
system will be confused in the end.
4. The order of Data does not matter
The order in which we store the data in a table does not matter in 1NF. It is a simple way of storing info- no
shenanigans involved.
Key of R1= (rollno,phone)
Key of R2=(rollno)
Second Normal Form (2NF)
To be in second normal form, a relation must be in first normal form and relation must not contain any
partial dependency. A relation is in 2NF if it has No Partial Dependency, i.e., no non-prime attribute
(attributes which are not part of any candidate key) is dependent on any proper subset of any candidate key
of the table.
In the second normal form, all non-key attributes are fully functional dependent on the primary key.
Rules Followed in 2nd Normal Form in DBMS
For a relation to be in the 2NF, it must be:
in 1NF;
should not consist of partial dependency.
In simpler words,
If a relation is in 1NF and all the attributes of the non-primary keys are fully dependent on primary keys,
then this relation is known to be in the 2NF or the Second Normal Form.
We can conclude that the attribute SUBJECT_FEE is a non-prime one since it doesn’t belong to the
candidate key here {SUBJECT_NO, CAND_ID} ;
But, on the other hand, the SUBJECT_NO – > SUBJECT_FEE, meaning the SUBJECT_FEE depends
directly on the SUBJECT_NO, and it forms the candidate key’s proper subset. Here, the
SUBJECT_FEE is a non-prime attribute, and it depends directly on the candidate key’s proper subset.
Thus, it forms a partial dependency.
Note: The Second Normal Form tries to reduce any redundant data from getting stored in the system’s
memory. For instance, if we take an example of about 100 candidates taking the S1 subject, then we don’t
have to store their fees as 1000 as a record for all the 100 candidates. Rather, we can store them all at once
in the second table as the subject fee for S1 is 1000.
Third Normal Form(3 NF)
A relation is said to be in 3rd normal form in DBMS (or 3NF) when it is in the second normal form, but no
transitive dependency exists for a non-prime attribute.
In simpler words, In a relation that is in 1NF or 2NF, when none of the non-primary key attributes
transitively depend on their primary keys, then we can say that the relation is in the third normal form of
3NF.