Normalization of Tables: From 2NF to 3NF

The second normal form (2NF) ensures that each non-key attribute of a table is fully dependent on the primary key. However, it is still possible for a table to have transitive dependencies, where non-key attributes depend on other non-key attributes. To address this issue, we can use the third normal form (3NF) to further normalize the database.

The third normal form (3NF) requires that all non-key attributes in a table be independent of each other, and that each non-key attribute depends only on the primary key. This helps eliminate data redundancy and improves data consistency and maintainability.

Let's consider an example of a fictional database for an online bookstore. Suppose we have a table called "Books" that contains information about books, including their title, author, publisher, and the department they belong to:

ISBNTitleAuthorPublisherDepartment
978-0316067928The Hunger GamesSuzanne CollinsScholasticFiction
978-0316015844Catching FireSuzanne CollinsScholasticFiction
978-0547928227The HobbitJ.R.R. TolkienHoughton MifflinFiction
978-0590353427Harry Potter and the Philosopher's StoneJ.K. RowlingBloomsburyFiction

This table is in 2NF because each non-key attribute depends fully on the primary key (ISBN). However, we can see that there is a transitive dependency between the "Department" column and the "Title" column, because the department of a book is determined by the title of the book, which is determined by the ISBN.

To normalize this table to 3NF, we need to split it into two tables. The first table, "Books", will contain information about each book and its ISBN, author, and publisher:

ISBNTitleAuthorPublisher
978-0316067928The Hunger GamesSuzanne CollinsScholastic
978-0316015844Catching FireSuzanne CollinsScholastic
978-0547928227The HobbitJ.R.R. TolkienHoughton Mifflin
978-0590353427Harry Potter and the Philosopher's StoneJ.K. RowlingBloomsbury

The second table, "Departments", will contain information about each department and the books it contains:

DepartmentISBN
Fiction978-0316067928
Fiction978-0316015844
Fiction978-0547928227
Fiction978-0590353427

In this normalized database, each non-key attribute (title, author, publisher, and department) depends only on the primary key or the combination of the primary key and a single non-key attribute. There are no transitive dependencies, which improves data consistency and maintainability.

Did you find this article valuable?

Support Bit Fetch by becoming a sponsor. Any amount is appreciated!