Sobes.tech
Middle

Tell about the third normal form in database normalization process.

sobes.tech AI

Answer from AI

The Third Normal Form (3NF) is based on 2NF and requires that all non-key attributes in a table depend directly only on the primary key, not on other non-key attributes. This eliminates transitive dependencies and reduces data duplication related to these dependencies.

To achieve 3NF, the following must be met:

  1. Be in 2NF.
  2. Remove any transitive dependencies. A transitive dependency exists when a non-key attribute depends on another non-key attribute, which in turn depends on the primary key.

Example of a transitive dependency:

Orders table:

Order ID Order Date Customer ID Customer Name Customer Address
1 2023-10-26 101 Ivanov Ivan Pushkin St., 1
2 2023-10-27 102 Petrov Petr Lermontov St., 5
3 2023-10-28 101 Ivanov Ivan Pushkin St., 1

In this table, Customer Name and Customer Address depend on Customer ID, and Customer ID depends on Order ID. This is a transitive dependency. To move to 3NF, split this table into two:

Orders table:

Order ID Order Date Customer ID
1 2023-10-26 101
2 2023-10-27 102
3 2023-10-28 101

Customers table:

Customer ID Customer Name Customer Address
101 Ivanov Ivan Pushkin St., 1
102 Petrov Petr Lermontov St., 5

Now, in the Orders table, all non-key attributes (Order Date, Customer ID) depend only on the primary key (Order ID). In the Customers table, all non-key attributes (Customer Name, Customer Address) depend only on the primary key (Customer ID). The transitive dependency is eliminated.

Applying 3NF reduces data redundancy, simplifies data updates and deletions, and increases database integrity. However, full normalization to 3NF can sometimes lead to increased JOIN operations during data retrieval, which may affect performance. In such cases, denormalization may be considered.

Tell about the third normal form in database… - sobes.tech