2081 8

CSC326 ยท 2081 ยท 5 marks

List the advantages of Normalization. Explain 2NF with an example.

List the advantages of Normalization. Explain 2NF with an example. [5]

System Analysis and DesignChapter 4: DesignNormalization

Quick answer

Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. Its key advantages are: Eliminates Data Redundancy; Prevents Update Anomalies; Prevents Insertion Anomalies.

Advantages of Normalization and Explanation of 2NF


Advantages of Normalization

Normalization is the process of organizing data in a database to reduce redundancy and improve data integrity. Its key advantages are:

  1. Eliminates Data Redundancy: Removes duplicate data stored across multiple tables, saving storage space.
  2. Prevents Update Anomalies: Ensures that updating a single fact requires changing it in only one place.
  3. Prevents Insertion Anomalies: Allows new data to be inserted without requiring unrelated data to be present.
  4. Prevents Deletion Anomalies: Ensures that deleting a record does not unintentionally remove other important data.
  5. Improves Data Integrity and Consistency: Data remains accurate and consistent throughout the database.
  6. Easier Maintenance: A well-normalized database is easier to modify and extend.

Second Normal Form (2NF)

Definition

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

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

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


Example

Consider the following relation with a composite primary key (StudentID, CourseID):

StudentIDCourseIDStudentNameCourseNameMarks
S01C01RamDBMS75
S01C02RamOS80
S02C01SitaDBMS70

Primary Key: (StudentID, CourseID)

Identifying Partial Dependencies:

  • StudentName depends only on StudentID (not on the full key) -- Partial Dependency
  • CourseName depends only on CourseID (not on the full key) -- Partial Dependency
  • Marks depends on both StudentID and CourseID -- Full Dependency (OK)

Since partial dependencies exist, this relation is NOT in 2NF.


Converting to 2NF

We decompose the table to remove partial dependencies:

Table 1: Student (depends on StudentID)

StudentIDStudentName
S01Ram
S02Sita

Table 2: Course (depends on CourseID)

CourseIDCourseName
C01DBMS
C02OS

Table 3: Enrollment (depends on full composite key)

StudentIDCourseIDMarks
S01C0175
S01C0280
S02C0170

Now all non-key attributes are fully functionally dependent on the entire primary key in each table. The database is now in 2NF.


Note: 2NF is only relevant when the primary key is composite. If a relation has a single-attribute primary key and is in 1NF, it is automatically in 2NF.

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