2080 7

BIT202 ยท 2080 ยท 5 marks

What is Normalization? Explain the 2NF with Examples.

What is Normalization? Explain the 2NF with Examples. [5]

Database Management SystemChapter 5: Normalization and Database DesignSecond normal form

Quick answer

Normalization is the process of organizing the attributes and tables of a relational database to minimize data redundancy and improve data integrity. It involves decomposing a large table into smaller, well-structured tables and defining relationships between them.

Normalization and Second Normal Form (2NF)

What is Normalization?

Goals of Normalization:

  • Eliminate redundant data
  • Ensure data dependencies make sense
  • Reduce anomalies (insertion, update, deletion anomalies)

Second Normal Form (2NF)

A relation is in Second Normal Form (2NF) if:

  1. It is already in First Normal Form (1NF), AND
  2. Every non-key attribute is fully functionally dependent on the entire primary key (i.e., there is no partial dependency).

Partial Dependency: A non-key attribute depends on only a part of a composite primary key, not the whole key.

Note: 2NF is only relevant when the primary key is composite (made up of more than one attribute).


Example

Table NOT in 2NF

Consider the following relation:

StudentIDCourseIDStudentNameCourseNameGrade
S01C01RamDBMSA
S01C02RamOSB
S02C01SitaDBMSA+
  • Primary Key: (StudentID, CourseID) -- composite key
  • Functional Dependencies:
    • (StudentID, CourseID) โ†’ Grade โœ… (full dependency)
    • StudentID โ†’ StudentName โŒ (partial dependency)
    • CourseID โ†’ CourseName โŒ (partial dependency)

StudentName depends only on StudentID, and CourseName depends only on CourseID. These are partial dependencies, so this table violates 2NF.


Converting to 2NF

Decompose the table to remove partial dependencies:

Table 1: Student

StudentIDStudentName
S01Ram
S02Sita

Table 2: Course

CourseIDCourseName
C01DBMS
C02OS

Table 3: Enrollment

StudentIDCourseIDGrade
S01C01A
S01C02B
S02C01A+

Now:

  • Each non-key attribute is fully dependent on the whole primary key.
  • All three tables are in 2NF.

Summary

Normal FormCondition
1NFAtomic values, no repeating groups
2NF1NF + No partial dependency on composite key

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.