Describe the concept of transitive dependency and describe how this concept relates to 3NF

  1. Describe the concept of transitive dependency and describe how this concept relates to 3NF. Provide an example to illustrate your answer.
  2. Discuss how the definitions of 2NF and 3NF based on primary keys differ from the general definitions of 2NF and 3NF. Provide an example to illustrate your answer.

The Correct Answer and Explanation is :

1. Transitive Dependency and Its Relation to 3NF

Transitive Dependency occurs when one non-prime attribute (a column not part of any candidate key) depends on another non-prime attribute through a third non-prime attribute. In other words, a transitive dependency happens when an attribute indirectly depends on the primary key via another attribute.

Example:
Consider a table containing the following columns: StudentID, StudentName, StudentCity, and CityZipCode. The StudentID is the primary key, and the CityZipCode depends on the StudentCity, which in turn depends on StudentID. So, the relationship between StudentCity and CityZipCode is a transitive dependency.

StudentIDStudentNameStudentCityCityZipCode
1AliceNew York10001
2BobLos Angeles90001

Here, CityZipCode depends on StudentCity, and StudentCity depends on StudentID. So, CityZipCode depends transitively on StudentID through StudentCity.

3NF and Transitive Dependency:
Third Normal Form (3NF) requires that a table be in Second Normal Form (2NF) and that no transitive dependency exists between non-prime attributes and the primary key. In other words, every non-prime attribute must directly depend on the primary key, not through another non-prime attribute.

To bring the above table into 3NF, we would split it into two tables: one for students and another for cities.

Corrected tables:

  1. Student (StudentID, StudentName, StudentCity)
  2. City (StudentCity, CityZipCode)

2. Definitions of 2NF and 3NF Based on Primary Keys

2NF (Second Normal Form) based on primary keys requires:

  1. The table must first satisfy 1NF (no repeating groups).
  2. No partial dependency should exist, meaning no non-prime attribute should depend on only part of a composite primary key.

3NF (Third Normal Form) based on primary keys requires:

  1. The table must satisfy 2NF.
  2. There should be no transitive dependency; non-prime attributes must depend directly on the primary key, not on another non-prime attribute.

Example:
Consider a table for Orders with OrderID, ProductID, ProductName, Price, and Quantity as columns, where OrderID and ProductID together form the composite primary key.

OrderIDProductIDProductNamePriceQuantity
1101Apple210
1102Banana15

In this case, ProductName and Price depend on ProductID, not OrderID. These are partial dependencies and violate 2NF based on primary keys. To correct this, we would split the table into:

  1. Orders (OrderID, ProductID, Quantity)
  2. Products (ProductID, ProductName, Price)

Now the table is in 2NF.

To bring it to 3NF, we also ensure that there are no transitive dependencies (for example, where Price depends on ProductID, which depends on OrderID).

By splitting and adjusting tables properly, we can avoid partial and transitive dependencies, ensuring 2NF and 3NF compliance based on primary keys.

Scroll to Top