Overview of C Language
Compile & Run C Code
What are Variables?
C Operators (with Examples)
See all →
Armstrong Number Program
Check Number is Odd/Even
First n Prime Numbers
Reverse String using Pointer
See all Programs (100+) →
MCQs to test your C language knowledge.
Run C programs and code examples online.
C++ Datatypes and Modifiers
sizeof and typedef
Create Class and Object
Check if Number is Positive/Negative
Half Pyramid with Numbers
MCQs to test your C++ language knowledge.
Run C++ programs and code examples online.
Python Installation & Setup
Concept of OOP & Class
Python Projects →
Print Colored Text in Python
Remove Numbers from String
Compare two Dates
See all How Tos (80+) →
MCQs to test your Python knowledge.
Run Python code examples in browser.
Setting Java Environment
Concept of Constructor
Running a JAR File
Serialization and Deserialization
See all Examples (80+) →
Java Library Functions
Type Conversion Examples
Java 11 Features
Basics Of Digital Components
Different type of Logic gates
Types of Computer Networks
Types of Operating System
First come First Serve
Shortest Job First
Classical Synchronization Problem
What are Semaphores?
What are Deadlocks?
Relational Algebra & Calculus
Types of DBMS Keys
Datatypes in PL/SQL
How to create Cursor?
MongoDB vs. RDBMS
Using MongoDB with Java
Practice SQL Query in browser with sample Dataset.
Normalization in DBMS is a technique using which you can organize the data in the database tables so that:
There is less repetition of data,
A large set of data is structured into a bunch of smaller tables,
and the tables have a proper relationship between them.
DBMS Normalization is a systematic approach to decompose (break down) tables to eliminate data redundancy(repetition) and undesirable characteristics like Insertion anomaly in DBMS, Update anomaly in DBMS, and Delete anomaly in DBMS.
It is a multi-step process that puts data into tabular form, removes duplicate data, and set up the relationship between tables.
Normalization is required for,
Eliminating redundant(useless) data, therefore handling data integrity, because if data is repeated it increases the chances of inconsistent data.
Normalization helps in keeping data consistent by storing the data in one table and referencing it everywhere else.
Storage optimization although that is not an issue these days because Database storage is cheap.
Breaking down large tables into smaller tables with relationships, so it makes the database structure more scalable and adaptable.
Ensuring data dependencies make sense i.e. data is logically stored.
This video will give you a good overview of Database Normalization. If you want you can skip the video, as the concept is covered in this tutorial as well - Normalization in DBMS (YouTube Video).
If a table is not properly normalized and has data redundancy(repetition) then it will not only eat up extra memory space but will also make it difficult for you to handle and update the data in the database, without losing data.
Insertion, Updation, and Deletion Anomalies are very frequent if the database is not normalized.
To understand these anomalies let us take an example of a Student table.
In the table above, we have data for four Computer Sci. students.
As we can see, data for the fields branch, hod(Head of Department), and office_tel are repeated for the students who are in the same branch in the college, this is Data Redundancy.
Suppose for a new admission, until and unless a student opts for a branch, data of the student cannot be inserted, or else we will have to set the branch information as NULL.
Also, if we have to insert data for 100 students of the same branch, then the branch information will be repeated for all those 100 students.
These scenarios are nothing but Insertion anomalies.
If you have to repeat the same data in every row of data, it's better to keep the data separately and reference that data in each row.
So in the above table, we can keep the branch information separately, and just use the branch_id in the student table, where branch_id can be used to get the branch information.
What if Mr. X leaves the college? or Mr. X is no longer the HOD of the computer science department? In that case, all the student records will have to be updated, and if by mistake we miss any record, it will lead to data inconsistency.
This is an Updation anomaly because you need to update all the records in your table just because one piece of information got changed.
In our Student table, two different pieces of information are kept together, the Student information and the Branch information.
So if only a single student is enrolled in a branch, and that student leaves the college, or for some reason, the entry for the student is deleted, we will lose the branch information too.
So never in DBMS, we should keep two different entities together, which in the above example is Student and branch,
The solution for all the three anomalies described above is to keep the student information and the branch information in two different tables. And use the branch_id in the student table to reference the branch.
Before we move on to learn different Normal Forms in DBMS, let's first understand what is a primary key and what are non-key attributes.
As you can see in the table above, the student_id column is a primary key because using the student_id value we can uniquely identify each row of data, hence the remaining columns then become the non-key attributes.
Normalization rules are divided into the following normal forms:
First Normal Form
Second Normal Form
Third Normal Form
Fourth Normal Form
Fifth Normal Form
Let's cover all the Database Normal forms one by one with some basic examples to help you understand the DBMS normal forms.
For a table to be in the First Normal Form, it should follow the following 4 rules:
It should only have single(atomic) valued attributes/columns.
Values stored in a column should be of the same domain.
All the columns in a table should have unique names.
And the order in which data is stored should not matter.
Watch this YouTube video to understand First Normal Form (if you like videos) - DBMS First Normal Form 1NF with Example
Let's see an example.
If we have an Employee table in which we store the employee information along with the employee skillset, the table will look like this:
The above table has 4 columns:
All the columns have different names.
All the columns hold values of the same type like emp_name has all the names, emp_mobile has all the contact numbers, etc.
The order in which we save data doesn't matter
But the emp_skills column holds multiple comma-separated values, while as per the First Normal form, each column should have a single value.
Hence the above table fails to pass the First Normal form.
So how do you fix the above table? There are two ways to do this:
Remove the emp_skills column from the Employee table and keep it in some other table.
Or add multiple rows for the employee and each row is linked with one skill.
So the Employee table will look like this,
And the new Employee_Skill table:
You can also simply add multiple rows to add multiple skills. This will lead to repetition of the data, but that can be handled as you further Normalize your data using the Second Normal form and the Third Normal form.
If you want to learn about the First Normal Form in detail, check out DBMS First Normal Form tutorial.
For a table to be in the Second Normal Form,
It should be in the First Normal form.
And, it should not have Partial Dependency.
Watch this YouTube video to understand Second Normal Form (if you like videos) - DBMS Second Normal Form 2NF with Example
Let's take an example to understand Partial dependency and the Second Normal Form.
When a table has a primary key that is made up of two or more columns, then all the columns(not included in the primary key) in that table should depend on the entire primary key and not on a part of it. If any column(which is not in the primary key) depends on a part of the primary key then we say we have Partial dependency in the table.
Confused? Let's take an example.
If we have two tables Students and Subjects, to store student information and information related to subjects.
And we have another table Score to store the marks scored by students in any subject like this,
Now in the above table, the primary key is student_id + subject_id, because both these information are required to select any row of data.
But in the Score table, we have a column teacher_name, which depends on the subject information or just the subject_id, so we should not keep that information in the Score table.
The column teacher_name should be in the Subjects table. And then the entire system will be Normalized as per the Second Normal Form.
Updated Subject table:
Updated Score table:
To understand what is Partial Dependency and how you can normalize a table to 2nd normal form, jump to the DBMS Second Normal Form tutorial.
A table is said to be in the Third Normal Form when,
It satisfies the First Normal Form and the Second Normal form.
And, it doesn't have Transitive Dependency.
Watch this YouTube video to understand the Third Normal Form (if you like videos) - DBMS Third Normal Form 3NF with Example
In a table we have some column that acts as the primary key and other columns depends on this column. But what if a column that is not the primary key depends on another column that is also not a primary key or part of it? Then we have Transitive dependency in our table.
Let's take an example. We had the Score table in the Second Normal Form above. If we have to store some extra information in it, like,
To store the type of exam and the total marks in the exam so that we can later calculate the percentage of marks scored by each student.
The Score table will look like this,
In the table above, the column exam_type depends on both student_id and subject_id, because,
a student can be in the CSE branch or the Mechanical branch,
and based on that they may have different exam types for different subjects.
The CSE students may have both Practical and Theory for Compiler Design,
whereas Mechanical branch students may only have Theory exams for Compiler Design.
But the column total_marks just depends on the exam_type column. And the exam_type column is not a part of the primary key. Because the primary key is student_id + subject_id, hence we have a Transitive dependency here.
You can create a separate table for ExamType and use it in the Score table.
New ExamType table,
We have created a new table ExamType and we have added more related information in it like duration(duration of exam in mins.), and now we can use the exam_type_id in the Score table.
Here is the DBMS Third Normal Form tutorial. But we suggest you first study the second normal form and then head over to the third normal form.
Boyce and Codd Normal Form is a higher version of the Third Normal Form.
This form deals with a certain type of anomaly that is not handled by 3NF.
A 3NF table that does not have multiple overlapping candidate keys is said to be in BCNF.
For a table to be in BCNF, the following conditions must be satisfied:
R must be in the 3rd Normal Form
and, for each functional dependency ( X → Y ), X should be a Super Key.
You can also watch our YouTube video to learn about BCNF - DBMS BCNF with Example
To learn about BCNF in detail with a very easy-to-understand example, head to the Boye-Codd Normal Form tutorial.
A table is said to be in the Fourth Normal Form when,
It is in the Boyce-Codd Normal Form.
And, it doesn't have Multi-Valued Dependency.
You can also watch our YouTube video to learn about Fourth Normal Form - DBMS Fourth Normal Form 4NF with Example
Here is the Fourth Normal Form tutorial. But we suggest you understand other normal forms before you head over to the fourth normal form.
The fifth normal form is also called the PJNF - Project-Join Normal Form
It is the most advanced level of Database Normalization.
Using Fifth Normal Form you can fix Join dependency and reduce data redundancy.
It also helps in fixing Update anomalies in DBMS design.
We have an amazing video to showcase the Fifth Normal Form with the help of Examples and to explain when it occurs and how you can fix it, check out the video on YouTube - Fifth Normal Form in DBMS
Here are some frequently asked questions related to the normalization in DBMS.
Database Normalization helps you design and structure your table properly so that you have proper relationships between tables. It helps you with the following:
Better relationship between tables
More scalable design for tables.
No large tables, small tables with a proper relationship.
Removing dependencies, like Partial Dependency, Transitive Dependency, Join Dependency, etc.
Following are the different Database Normal Forms:
First Normal Form also known as 1NF
Second Normal Form or 2NF
Third Normal Form or 3NF
Boyce-Codd Normal Form or BCNF
Fourth Normal Form or 4NF
Fifth Normal Form or 5NF or PJNF (Project-Join Normal Form)
A Primary key is a column that can be used to uniquely identify each row in a table. It can be a single column, or it can be multiple columns together. Yes, a primary key can have two columns or even more than two columns in it.
All the columns that are not a primary key or not a part of the primary key are called as non-Key columns in a Table.
For example, if we have a table Students with columns student_id, student_name, student_address, and student_id is the primary key in this table, then student_name and student_address will be the non-Key attributes.
BCNF stands for Boyce-Codd Normal Form. BCNF is a higher version of the Third Normal Form.
No. BCNF is a higher version of the Third Normal Form. The purpose of the Third Normal Form or 3NF is to remove Transitive dependency whereas BCNF is more strict than 3NF, and it focuses on removing all non-trivial functional dependencies.
PJNF stands for Project-Join Normal Form. This is a name given to the Fifth Normal Form because the Fifth Normal Form or 5NF is used to fix Join dependency in tables.
The Fifth Normal Form is also known as PJNF or Project-Join Normal Form. The fifth normal form fixes the Join dependency in tables hence it is called PJNF. This is an advanced Normal form that helps in reducing Data redundancy and Updation anomaly.