5 Normalization And Database Design

Database Management System ยท Unit 5

Normalization and Database Design

Exam-focused notes for Normalization and Database Design (Database Management System, BIT202): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.

Normalization and Database Design in short

Good table design avoids repeated data and update errors. Normalization is the step-by-step method used to reach such a design. It uses functional dependencies to find and remove bad structure.

Normalization and Database Design: notes

Normalization purpose and need

Normalization is the process of organizing tables to reduce redundancy (repeated data) and to avoid anomalies. It splits a large table into smaller, well-structured tables linked by keys.

A badly designed table causes three anomalies. Take Emp(EmpID, Name, DeptID, DeptName):

EmpIDNameDeptIDDeptName
1AshaD1Sales
2BikramD1Sales
3ChandraD2HR
  • Insertion anomaly: a new department cannot be added until it has an employee.
  • Deletion anomaly: deleting employee 3 also deletes the fact that D2 is HR.
  • Update anomaly: renaming Sales needs a change in many rows. Missing one makes the data inconsistent.

Normalization removes these problems and saves space.

Functional dependencies

A functional dependency (FD) $X \rightarrow Y$ means this: two rows with the same $X$ must have the same $Y$. We say $X$ determines $Y$.

Example: $RollNo \rightarrow Name$, because one roll number belongs to one student. But $Name \rightarrow RollNo$ is not true, because two students can share a name.

Types of FD:

  • Trivial: $Y \subseteq X$, such as ${RollNo, Name} \rightarrow Name$.
  • Non-trivial: $Y$ is not part of $X$.
  • Full dependency: $Y$ depends on the whole of $X$ and on no smaller part of it.
  • Partial dependency: $Y$ depends on only part of a composite key.
  • Transitive dependency: $X \rightarrow Y$ and $Y \rightarrow Z$ give $X \rightarrow Z$, where $Y$ is a non-key attribute.

The closure $X^{+}$ is the set of all attributes determined by $X$. Take $R(A,B,C,D)$ with $A \rightarrow B$ and $B \rightarrow C$:

$$\begin{aligned} A^{+} &= {A} \ &= {A, B} \ &= {A, B, C} \end{aligned}$$

$A^{+}$ does not contain $D$, so $A$ alone is not a key. The key is ${A, D}$, because ${A, D}^{+} = {A, B, C, D}$.

What this unit covers

  • Normalization purpose and need
  • Functional dependencies
  • First normal form
  • Second normal form
  • Third normal form
  • Quality measures for relational schema design

Normalization purpose and need

2082 ยท 10 marks

Why is normalization required? Define 1NF, 2NF and 3NF with suitable examples.[10]

Show solved answer

Normalization: Need, 1NF, 2NF, and 3NF


Why is Normalization Required?

Normalization is the process of organizing a relational database to reduce data redundancy and improve data integrity by decomposing large, poorly structured tables into smaller, well-structured ones.

Problems Without Normalization (Anomalies)

Consider the following unnormalized table:

StudentIDStudentNameCourseIDCourseNameInstructorIDInstructorName
1RamC01DBMSI01Dr. Sharma
1RamC02OSI02Dr. Gupta
2SitaC01DBMSI01Dr. Sharma

1. Insertion Anomaly: A new course cannot be inserted unless at least one student is enrolled in it. The course data depends on student data being present.

2. Deletion Anomaly: If Student 2 (Sita) drops Course C01, the information about Dr. Sharma teaching DBMS is also lost.

3. Update Anomaly: If Dr. Sharma's name changes, it must be updated in every row where C01 appears. Missing even one row causes inconsistency.

Goals of Normalization

  • Eliminate redundant data
  • Ensure data dependencies make sense
  • Make the database easier to maintain
  • Reduce storage space

First Normal Form (1NF)

Definition

A relation is in 1NF if:

  • All attributes contain atomic (indivisible) values
  • There are no repeating groups or multi-valued attributes
  • Each column contains values of a single type
  • Each row is uniquely identifiable

Example

Violation of 1NF:

StudentIDStudentNameCourses
1RamDBMS, OS
2SitaDBMS

Here, the Courses column has multiple values -- this violates 1NF.

After converting to 1NF:

StudentIDStudentNameCourse
1RamDBMS
1RamOS
2SitaDBMS

Now every attribute is atomic. The table is in 1NF.


Second Normal Form (2NF)

Definition

A relation is in 2NF if:

  • It is already in 1NF
  • Every non-key attribute is fully functionally dependent on the entire primary key (no partial dependency)

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

Example

Consider the table (Primary Key = {StudentID, CourseID}):

StudentIDCourseIDStudentNameCourseNameGrade
1C01RamDBMSA
1C02RamOSB
2C01SitaDBMSA

Functional Dependencies:

  • {StudentID, CourseID} --> Grade (full dependency -- OK)
  • StudentID --> StudentName (partial dependency -- violates 2NF)
  • CourseID --> CourseName (partial dependency -- violates 2NF)

After converting to 2NF (decompose):

Student Table:

StudentIDStudentName
1Ram
2Sita

Course Table:

CourseIDCourseName
C01DBMS
C02OS

Enrollment Table:

StudentIDCourseIDGrade
1C01A
1C02B
2C01A

Now all non-key attributes are fully dependent on the whole primary key. The tables are in 2NF.


Third Normal Form (3NF)

Definition

A relation is in 3NF if:

  • It is already in 2NF
  • There is no transitive dependency -- no non-key attribute depends on another non-key attribute

Transitive Dependency: If A --> B and B --> C, then A --> C is a transitive dependency (C depends on A through B).

Example

Consider the table (Primary Key = StudentID):

StudentIDStudentNameDeptIDDeptName
1RamD01Computer
2SitaD02Physics
3HariD01Computer

Functional Dependencies:

  • StudentID --> DeptID (direct dependency -- OK)
  • DeptID --> DeptName (DeptName depends on DeptID, not on StudentID)
  • Therefore: StudentID --> DeptID --> DeptName (transitive dependency -- violates 3NF)

After converting to 3NF (decompose):

Student Table:

StudentIDStudentNameDeptID
1RamD01
2SitaD02
3HariD01

Department Table:

DeptIDDeptName
D01Computer
D02Physics

Now there is no transitive dependency. Both tables are in 3NF.


Summary Table

Normal FormCondition
1NFAll attributes are atomic; no repeating groups
2NF1NF + No partial dependency on composite primary key
3NF2NF + No transitive dependency; every non-key attribute depends on the key alone

Conclusion

Normalization is required because an unnormalized table stores the same fact in many rows, which wastes space and, more seriously, allows the copies to disagree. Removing repeating groups gives 1NF, removing partial dependency on part of a composite key gives 2NF, and removing transitive dependency through a non-key attribute gives 3NF. Each step replaces one table by two smaller tables joined on a key, so the insertion, deletion and update anomalies disappear while the original information can still be recovered by a join. Most practical database designs stop at 3NF (or BCNF), since further decomposition begins to cost more in join time than it saves in redundancy.

Open this answer on its own page โ†’

0 ยท 5 marks

Why normalization is needed in database design? Describe third normal form with an example. [5]

--- Normalization is the process of organizing a relational database to reduce data redundancy and improve data integrity. It is needed because poorly designed tables suffer from the following problems (called update anomalies): Anomaly Description ------ Insertion Anomaly Cannot insert data with...

Open this answer on its own page โ†’

Second normal form

2080 ยท 5 marks

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

Show solved answer

Normalization and Second Normal Form (2NF)

What is Normalization?

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.

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
Open this answer on its own page โ†’

2079 ยท 5 marks

What is normalization? Explain 2NF with example. [5]

Normalization is the process of organizing the attributes and tables of a relational database to reduce data redundancy and improve data integrity. It involves decomposing a large, poorly structured table into smaller, well-structured tables while preserving data relationships. Goals of Normaliza...

Open this answer on its own page โ†’

Quality measures for relational schema design

2079 ยท 10 marks

What is a functional dependency? What are the four informal measures of quality for relational schema design? Explain.[10]

--- A functional dependency (FD) is a constraint between two sets of attributes in a relation. It describes the relationship between attributes in a relational schema. Formally, a functional dependency is denoted as: $$X \rightarrow Y$$ This is read as "X functionally determines Y" or "Y is funct...

Open this answer on its own page โ†’

Third normal form

2078 ยท 5 marks

What is Functional Dependency? Explain 3NF with Examples. [5]

--- A functional dependency is a constraint between two sets of attributes in a relation. If attribute B is functionally dependent on attribute A, then for each value of A, there is exactly one corresponding value of B. Notation: A โ†’ B (A functionally determines B) Example: In a Student table: - ...

Open this answer on its own page โ†’