0% found this document useful (0 votes)
8 views4 pages

Database Normalization: 1NF to 3NF Guide

Normalization is the process of organizing database data to reduce redundancy and improve integrity, involving decomposing tables into smaller relations. The document outlines the rules and examples for the first three normal forms (1NF, 2NF, and 3NF), emphasizing the importance of atomic values, full dependency on primary keys, and the elimination of transitive dependencies. It concludes with a summary of key requirements for each normal form and tips for effective normalization.

Uploaded by

tazvirrahat12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Database Normalization: 1NF to 3NF Guide

Normalization is the process of organizing database data to reduce redundancy and improve integrity, involving decomposing tables into smaller relations. The document outlines the rules and examples for the first three normal forms (1NF, 2NF, and 3NF), emphasizing the importance of atomic values, full dependency on primary keys, and the elimination of transitive dependencies. It concludes with a summary of key requirements for each normal form and tips for effective normalization.

Uploaded by

tazvirrahat12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Normalization Tutorial: 1NF to 3NF

Database Systems Handout

What is Normalization?

Normalization is the process of organizing data in a database to reduce redundancy and


improve data integrity. It involves decomposing tables into smaller, well-structured relations.

First Normal Form (1NF)

Rule: A table is in 1NF if:

• All values are atomic (indivisible),

• No repeating groups or arrays.

Example (Unnormalized):

StudentID Name Courses


1001 Alice Math, Physics
1002 Bob Chemistry

Converted to 1NF:

StudentID Name Course


1001 Alice Math
1001 Alice Physics
1002 Bob Chemistry

1
Second Normal Form (2NF)

Rule: A table is in 2NF if:

• It is in 1NF,

• All non-prime attributes are fully dependent on the whole primary key (no partial
dependency).

Example (1NF but not 2NF):

StudentID CourseID Grade StudentName CourseName


1001 CS101 A Alice Data Structures
1002 MA102 B Bob Calculus

Issues:
• StudentName depends only on StudentID,

• CourseName depends only on CourseID.

2NF Decomposition:
• Students(StudentID, StudentName)

• Courses(CourseID, CourseName)

• Enrollment(StudentID, CourseID, Grade)

Third Normal Form (3NF)

Rule: A table is in 3NF if:

• It is in 2NF,

• No transitive dependency (non-prime attribute should not depend on another non-


prime attribute).

2
Example (2NF but not 3NF):

Given Relation:

OrderID CustomerID ProductID Quantity CustomerName


O01 C001 P101 2 Alice
O02 C002 P102 1 Bob
O01 C001 P102 3 Alice

Functional Dependencies:

• (OrderID, ProductID) → Quantity

• CustomerID → CustomerName

• OrderID → CustomerID

Candidate Key: (OrderID, ProductID)

Check for 2NF:

- The composite key is (OrderID, ProductID). - All non-key attributes depend on the
entire key or non-key attributes. - No partial dependency exists since:

• Quantity depends on full key (OrderID, ProductID).

• CustomerName depends on CustomerID (non-key attribute), so it does not violate


2NF (which focuses on partial dependencies on keys).

Thus, the relation is in 2NF.

However, transitive dependency exists:

- CustomerName depends on CustomerID, which depends on OrderID. - This violates


3NF because CustomerName is transitively dependent on the candidate key via CustomerID.

Decompose to achieve 3NF:

Separate into two relations:

3
• Orders(OrderID, CustomerID)
• Customer(CustomerID, CustomerName)
• OrderDetails(OrderID, ProductID, Quantity)

Final Relations:

Orders Table:

OrderID CustomerID
O01 C001
O02 C002

Customer Table:

CustomerID CustomerName
C001 Alice
C002 Bob

OrderDetails Table:

OrderID ProductID Quantity


O01 P101 2
O02 P102 1
O01 P102 3

Summary of Normal Forms

Normal Form Key Requirement


1NF Atomic attributes, no repeating groups
2NF No partial dependency on composite keys
3NF No transitive dependency

Tips
• Always identify candidate keys and functional dependencies.
• Normalize only until needed: 3NF is usually sufficient for practical purposes.

Common questions

Powered by AI

The primary structural change from 2NF to 3NF is the removal of transitive dependencies, ensuring that non-prime attributes depend only on super keys. The document’s example illustrates this with `CustomerName` being dependent on `CustomerID`, which in turn depends on `OrderID`. By decomposing into separate tables such as `Customer(CustomerID, CustomerName)` and `Orders(OrderID, CustomerID)`, each non-prime attribute directly relates to the primary key of its table, optimizing structural organization and data integrity .

Transitive dependency in the context of 3NF occurs when a non-prime attribute is dependent on another non-prime attribute instead of directly on the primary key. An example from the document involves `CustomerName` being dependent on `CustomerID`, which is dependent on `OrderID`. This creates a transitive dependency of `CustomerName` on the primary key, `OrderID`, through `CustomerID`. Decomposition is needed to eliminate this dependency, splitting into `Orders(OrderID, CustomerID)` and `Customer(CustomerID, CustomerName)` .

Repeating groups in a table compromise its integrity by allowing the possibility of inconsistent or duplicate data entries across multiple rows. This is rectified through normalization to 1NF, which requires the restructuring of tables to have each value be atomic, meaning every attribute in a record holds only a single piece of data. The document exemplifies this by decomposing a table with courses listed as `Math, Physics` into discrete records for each course, thus eliminating repeating groups and ensuring consistent data organization .

To conform to 2NF, a database table must first satisfy 1NF's requirement of having atomic values and no repeating groups. It must then also ensure that all non-prime attributes are fully dependent on the entire primary key, eliminating any partial dependency on only part of a composite key. This differs from 1NF, which focuses solely on the atomicity of values and the lack of repeating groups, without considering the dependency relationships between attributes and keys .

Candidate keys are critical in database normalization because they determine the uniqueness of rows within a table, forming the basis upon which normalization decisions are made. Each candidate key should provide a unique identifier for each record without redundancy. In the document’s example, `(OrderID, ProductID)` is a candidate key for table entries, ensuring that the combination of order and product uniquely identifies each detail in the `OrderDetails` table, thus aiding in structured database design and efficient querying .

Normalization in database systems aims to organize the data to reduce redundancy and improve data integrity. By decomposing tables into smaller, well-structured relations, normalization ensures that each piece of data is stored only once, thus eliminating redundancy. This process also enforces data integrity by ensuring that changes in data occur consistently across the system .

Normalizing a database to 3NF is usually sufficient because it eliminates most redundancy by addressing both partial and transitive dependencies. This level of normalization ensures data integrity without the complexity and potential performance issues associated with higher normal forms, which might not offer significant additional benefits for most applications. 3NF typically strikes a balance between optimal structure and practical efficiency, making it the most commonly used level in practice .

A table may not satisfy 2NF if it has partial dependencies, meaning some non-prime attributes depend only on part of a composite primary key rather than the whole key. To address this, we decompose the table into smaller tables where non-prime attributes are fully dependent on the entire primary key. For instance, separating `Students(StudentID, StudentName)` and `Courses(CourseID, CourseName)` resolves partial dependency issues .

To identify candidate keys and functional dependencies in the normalization process, one typically analyzes the data requirements and the relationships between attributes. Candidate keys are determined based on the minimal set of attributes necessary to uniquely identify each tuple in a relation. Functional dependencies are established by identifying relationships where one attribute uniquely determines another. This understanding allows for decomposing tables to eliminate anomalies and achieve normalization, typically balancing data integrity and redundancy .

1NF ensures atomicity by requiring that all values in a database table be indivisible. This means that each field should contain only atomic values, with no repeating groups or arrays. For example, a table with student data that initially has courses listed in a single field (e.g., "Math, Physics") is split into separate records for each course, ensuring each field contains only one atomic value. This transformation involves changing data like `StudentID, Name, Courses` into separate entries such as `StudentID, Name, Course` for each course .

You might also like