Header Ads Widget

Third Normal Form (3NF)

Third Normal Form (3NF)

  • A relation will be in 3NF if it is in 2NF and not contain any transitive partial dependency.
  • 3NF is used to reduce the data duplication. It is also used to achieve the data integrity.
  • If there is no transitive dependency for non-prime attributes, then the relation must be in third normal form.

A relation is in third normal form if it holds atleast one of the following conditions for every non-trivial function dependency X → Y.

  1. X is a super key.
  2. Y is a prime attribute, i.e., each element of Y is part of some candidate key.
  3. Example:

    EMPLOYEE_DETAIL table:

    EMP_IDEMP_NAMEEMP_ZIPEMP_STATEEMP_CITY
    222Harry201010UPNoida
    333Stephan02228USBoston
    444Lan60007USChicago
    555Katharine06389UKNorwich
    666John462007MPBhopal

    Super key in the table above:

    1. {EMP_ID}, {EMP_ID, EMP_NAME}, {EMP_ID, EMP_NAME, EMP_ZIP}....so on  

    Candidate key: {EMP_ID}

    Non-prime attributes: In the given table, all attributes except EMP_ID are non-prime.

    Here, EMP_STATE & EMP_CITY dependent on EMP_ZIP and EMP_ZIP dependent on EMP_ID. The non-prime attributes (EMP_STATE, EMP_CITY) transitively dependent on super key(EMP_ID). It violates the rule of third normal form.

    That's why we need to move the EMP_CITY and EMP_STATE to the new <EMPLOYEE_ZIP> table, with EMP_ZIP as a Primary key.

    EMPLOYEE table:

    EMP_IDEMP_NAMEEMP_ZIP
    222Harry201010
    333Stephan02228
    444Lan60007
    555Katharine06389
    666John462007

    EMPLOYEE_ZIP table:

    EMP_ZIPEMP_STATEEMP_CITY
    201010UPNoida
    02228USBoston
    60007USChicago
    06389UKNorwich
    462007MPBhopal

Post a Comment

0 Comments