Week1 (5)
Week1 (5)
The process of normalization is guided by a set of normal forms (NF), which are rules
that ensure the database adheres to specific standards.
1. First Normal Form (1NF): Ensures that each column contains atomic (indivisible)
values and eliminates repeating groups.
2. Second Normal Form (2NF): Removes partial dependencies, meaning that every
non-key attribute must be fully functionally dependent on the primary key.
3. Third Normal Form (3NF): Eliminates transitive dependencies, ensuring that non-
key attributes are not dependent on other non-key attributes.
6. Fifth Normal Form (5NF): Resolves join dependencies, ensuring the database is
free from redundancy caused by join operations.
Benefits of Normalization
1. Reduces Redundancy:
4. Easier Maintenance:
Example:
Without Normalization:
Issues:
o Repeating columns (Course1, Course2, Course3) make the table hard to
scale.
1 Alice Math
1 Alice Physics
2 Bob Chemistry
2 Bob Biology
2 Bob Math
Benefits:
The First Normal Form (1NF) is the most basic level of database normalization. It ensures
that a table is structured properly to reduce redundancy and eliminate anomalies in the
data.
1. Atomic Values:
o Every column in the table should have a unique name for clarity.
3. Uniqueness of Rows:
o Each row (record) in the table must be unique and identifiable using a
primary key.
Example of 1NF
2 Bob Chemistry
Violations of 1NF:
To bring the table into 1NF, split the non-atomic values into separate rows:
1 Alice Math
1 Alice Physics
2 Bob Chemistry
3 Carol Math
3 Carol Biology
Advantages of 1NF
Real-Life Scenario
Imagine you are storing a list of employees and their skills in a table. Without 1NF, you
might use a single row for an employee and list all their skills in one column. For
example:
To convert it to 1NF:
The Second Normal Form (2NF) is a step in the database normalization process. It builds
upon the First Normal Form (1NF) and ensures that the data in a relational database is
organized to reduce redundancy and dependency issues.
o Rows should be unique, and columns must have a single value (no
multivalued or composite attributes).
2. No Partial Dependency:
o A table is in 2NF if all non-prime attributes (attributes that are not part of
any candidate key) are fully functionally dependent on the entire primary
key.
Example of 2NF
The table is in 1NF because all values are atomic and there are no repeating
groups.
CourseID CourseName
1 Mathematics
2 Physics
2. Instructor Table:
InstructorID InstructorName
101 Alice
102 Bob
103 Carol
3. Course-Instructor Table:
CourseID InstructorID
1 101
1 103
2 102
Now, every non-prime attribute depends on the entire primary key (or a single
primary key, in the case of non-composite tables).
The Third Normal Form (3NF) is the next step after 2NF in database normalization. It
aims to further reduce redundancy by eliminating transitive dependencies.
2. No Transitive Dependency:
o In simpler terms:
If A→BA \to BA→B and B→CB \to CB→C, then A→CA \to CA→C is a
transitive dependency.
Example of 3NF
1. Student Table:
StudentID StudentName
1 Alice
2 Bob
3 Carol
2. Course Table:
3. Instructor Table:
InstructorID InstructorName
4. Enrollment Table:
StudentID CourseID
1 101
2 102
3 101
No Transitive Dependencies:
Improved Integrity:
required.