For working professionals
For fresh graduates
More
DBMS Tutorial: Learn Database …
1. DBMS Tutorial
2. DBMS Architecture
3. Relational Database Management System
4. Data Models in DBMS
5. First Normal Form (1NF)
6. Second Normal Form (2NF)
7. 3rd Normal Form (3NF)
Now Reading
8. BCNF in DBMS
9. Functional Dependency in DBMS
10. Anomalies in DBMS
11. Super Key in DBMS
12. Candidate key DBMS
13. Composite key in DBMS
14. Foreign Key in DBMS
15. Relational Algebra in Database Management
16. Joins in DBMS
17. Indexing In DBMS
18. Transaction in DBMS
19. ACID Properties in DBMS
20. Lock Based Protocol in DBMS
21. Deadlock in DBMS
22. Decomposition in DBMS
23. Aggregation in DBMS
24. Generalization and Specialization in DBMS
25. Data Independence in DBMS
26. Redundancy in DBMS
27. Role-Based Access Control (RBAC)
28. Spatial Databases in DBMS
29. B+ Tree
30. CAP Theorem in DBMS
31. Database Schemas
32. Concurrency Control in DBMS
Data has slowly become the backbone of every organization. Companies, governments, and individuals utilize databases to store and manage huge volumes of data. Databases therefore need to be well-designed to guarantee that information shared remains accurate, reliable, and easy to analyze. This is where database normalization comes into the picture.
Database normalization is a systematized way of arranging data in relational databases. It involves designing data tables to avoid repetition and helps improve data quality. The facility of redundancy can be referred to as the same data being stored in multiple places within a database. This results in a lack of congruence leads to mistakes, and is generally ineffective.
Data normalization helps to normalize using sets of rules called normal forms. These forms are data organization levels and each subsequent form is built upon the previous one. There are several normal forms, but the ones most commonly used are the 1st Normal Form (1NF), 2nd Normal Form (2NF), and 3rd Normal Form (3NF) in DBMS.
Formally, a database table is in 3rd normal form in DBMS, if it satisfies the following conditions:
Third normal form in DBMS with an example
Student | Name | Course | Result |
24 | Aarti Kumar | BCom | Passed |
25 | Sachin Sharma | BCom | Awaited |
26 | Karthik Kapoor | BSc | Awaited |
27 | Archana Rana | BBA | Passed |
28 | Anubhav Sinha | BCom | Passed |
29 | Riya Singh | BSc | Awaited |
Here, “Course ID” is the foreign key, and “Student ID” is the primary key. This makes Course ID and Student Name no longer functionally dependent on each other and thus, deletion anomalies do not occur.
Since the Third Normal Form (3NF) in DBMS provides the database design with several benefits, it is the central pillar for reliable data management.
Here's a closer look at some of the key advantages of 3NF.
3rd normal form in DBMS not only provides data that is the same as the real objects but also ensures that data reflects real-world entities.
3NF can delete the repetition of data within an entire database. To avoid transitive dependencies, data is split into tables which are decomposed and stored in a single location.
3NF provides a logical and ordered manner of data structuring. It allows ease of conducting queries, data updates, and other data manipulation tasks.
3NF is a method that allows for modular database design. When your data volumes grow or schema requirements change, tables in 3NF can be easily modified or extended without affecting the whole database structure.
Here's a step-by-step guide to normalize a database table to 3NF:
The primary action is to learn the functional relationship between the attributes within your table. An FD (functional dependency) occurs when the value of attribute X leads to the knowledge of the value of attribute Y. In other words, if you know the value of X, you can always find the corresponding value of Y, and there won't be any doubts about it.
Example:
Visualize a table storing details of the students enrolled in the courses (StudentID, CourseID, CourseName, InstructorName). It is a functional dependency that StudentID and CourseID are interconnected. Hence, it implies that the student's ID is the main factor to be considered. It will identify which course is being attended by the student.
The candidate key is a collection of minimal elements that only can be used to distinguish each line in a table. In the case of the current example, both StudentID and {StudentID, CourseID} can be candidate keys. The primary candidate key is StudentID with CourseID dependent on it since StudentID already determines CourseID.
Example:
The main key, which is selected from the candidate keys, acts as an identifier. It is usually suggested to pick a small candidate key for the sake of reducing the amount of data repetition. In this instance, StudentID is the preferred choice for the primary key.
It is necessary to verify that there are no non-transitive partial dependencies, which are not transitive to the primary key. There is a partial dependency when one attribute (A) is the determiner of another attribute (B) and not the whole primary key. The transitive dependency is when A causes B and B causes C.
Example:
Imagine that we add an 'InstructorEmail' attribute to our table to illustrate this example. If CourseID determines InstructorEmail (given the class you have, you know the teacher's email), a partial dependency is developed. This is a problem because the CourseID is not the super key. An error could appear when you want to update InstructorEmail for a specific course but not for other courses taught by the same instructor.
To obtain 3NF, the table must be decomposed into tables of smaller sizes that remove partial dependency. So, this decomposition means that each attribute is reliant on the primary key and not on the partial one. This would lead to partial dependencies and, consequently, anomalies.
Example:
For this case, we can have different tables such as 'Courses' (CourseID, CourseName, InstructorID) and 'Enrollments' (StudentID, CourseID). The table 'Courses' would have the primary key of CourseID, and the table 'Enrollments' would have the composite primary key of {StudentID, CourseID}. This can be followed by making a foreign key relationship between the tables. The CourseID in the 'Enrollments' table would be the foreign key (CourseID) corresponding to the primary key (CourseID) in the 'Courses' table.
Visualize a library management system that will have a table with information about books (BookID, Title, Author, Genre, Category, BranchID) as its data. One can easily feel that this table is not that bad. Nevertheless, this is the case as it reveals a breach of 3NF.
Category is the factor that determines the number of branches. This leads to partial dependency as the category of book (e.g., fiction) does not inform you of the exact branch of the library where the book is located (fiction books could be in more than one branch).
To achieve 3NF, we can decompose the table:
One needs to examine 3NF as a means to avoid data redundancy and dependency on the performance implications of practical scenarios.
Here’s why:
3NF helps in removing data redundancy and dependency and also assures that each non-key attribute should depend on the primary key(s). It helps to remove unnecessary data and maintain consistency of data, which contributes to the data integrity that is required for the process of database operations to be reliable.
3NF commonly results in a more disjointed data structure, where the data that relate to each other is stored in different tables. This requires more frequent joins to retrieve information, which can slow down the performance of queries.
In certain instances, denormalization (a method of including a limited amount of redundancy in data) is used to enhance query performance. In this case, it becomes necessary to create a calculated field in the table, even if it's technically unnecessary, to avoid complex joins.
Although 3NF is a key principle for data integrity and consistency, the performance implications of normalization decisions in practical database implementations must be considered. Finding the sweet spot between normalization and optimization of performance guarantees that databases preserve data integrity and provide quick and efficient query processing. This is the basis for scalable and reliable data management systems.
While 3NF and BCNF aim to lower data redundancy and inconsistencies, they work at different levels of normalization, providing different benefits to database management.
Here’s how they relate:
The 3NF is an element of database normalization. It focuses on reducing the redundancy and dependency in the relational database. It is based on the principles of 1NF and 2NF. This means that non-key attributes fully functionally depend on the primary key instead of other non-key attributes.
A more stringent form of normalization than 3NF is the BCNF. It deals with issues left over even in databases that have been normalized up to the 3NF. BCNF specifies that all determinants (attributes that make another attribute unique) must be candidate keys, thus, no trivial dependency between attributes is supported.
Both 3NF and BCNF aim to reduce data redundancy and inconsistency, however, BCNF is stricter than 3NF. Any table in BCNF will have to be in 3NF. While not all tables that comply with 3NF might meet stringent BCNF conditions, it is not always the case that all tables that comply with the 3NF conditions will also comply with the BCNF conditions. With the knowledge of the connection between the 3NF and BCNF, database designers can make educated choices to guarantee the accuracy and efficiency of data in relational databases.
Learning the 3rd normal form in DBMS will enable you to create efficient and stable databases. By exploring functional dependencies, determining candidate keys, and excluding partial dependencies, you will have a soundly structured data backbone for your applications.
Remember, 3NF should be the basis of most database designs, as it ensures data integrity and enables efficient data management.
1. How to make a 3NF table in SQL?
To create a table in Third Normal Form (3NF) in SQL, follow these steps:
2. What is the process of converting to 3NF?
To convert a database schema to 3NF, follow these steps:
3. What is 1NF, 2NF, 3NF, 4NF, 5NF in DBMS?
Author
Talk to our experts. We are available 7 days a week, 9 AM to 12 AM (midnight)
Indian Nationals
1800 210 2020
Foreign Nationals
+918045604032
1.The above statistics depend on various factors and individual results may vary. Past performance is no guarantee of future results.
2.The student assumes full responsibility for all expenses associated with visas, travel, & related costs. upGrad does not provide any a.