0% found this document useful (0 votes)
3 views

Normalization

Uploaded by

prince deno
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Normalization

Uploaded by

prince deno
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Entity Relation Models

- Entity: An object or concept that is distinguishable from other objects. Entities


can be physical objects like Students or conceptual like Courses.

- Attributes: Describes properties or characteristics of an entity. E.g., a Student


entity may have attributes like StudentID, Name, DOB.

- Relationship: An association between two or more entities. For example, a


Student can be enrolled in a Course (relationship between Student and Course
entities).

- Cardinality: Defines how many instances of an entity relate to the number of


instances in another entity. Common cardinalities:
- One-to-One (1:1)
- One-to-Many (1:N)
- Many-to-Many (M:N)

- ER Diagrams (ERD): A visual representation of the entities, attributes, and


relationships. Symbols:
- Rectangles represent entities.
- Ellipses represent attributes.
- Diamonds represent relationships.
- Lines connect entities to their relationships and attributes.

Normalization in a Relational Model


- Normalization: The process of organizing data in a database to minimize
redundancy and improve data integrity.
- Normal Forms: Rules that a relational database must follow. Key normal forms
include:
- First Normal Form (1NF): Ensures that the values in a table are atomic
(indivisible), i.e., each column contains unique and individual values.
- Second Normal Form (2NF): Builds on 1NF by ensuring that all non-key
attributes are fully functionally dependent on the primary key.
- Third Normal Form (3NF): Ensures that no transitive dependencies exist, i.e.,
non-key attributes do not depend on other non-key attributes.

Importance of Normalization
- Prevents data anomalies like:
- Insertion anomalies: Problems with adding new data.
- Deletion anomalies: Problems with deleting data that results in unintended
data loss.
- Update anomalies: Changes in data cause inconsistencies.
- Reduces storage space
- Improves query performance

Below is an example demonstrating how a database can be normalized:

Scenario:

We have a table that stores information about students, courses, and their
respective instructors. Initially, the table might look like this:

Unnormalized Table:

Step 1: First Normal Form (1NF)

1NF requires that each table cell contains atomic (indivisible) values and that
there are no repeating groups. In our table, the data is already atomic, so we
are in 1NF. However, the table still has redundancies (like repeating instructor
names and course names).

1NF Table:
Step 2: Second Normal Form (2NF)

2NF eliminates partial dependencies. To achieve this, we need to ensure that


non-key attributes depend on the whole primary key, not just part of it. Here,
StudentName, CourseName, and InstructorName depend only on part of the primary
key (CourseID or StudentID), so we break the table into two tables: one for students
and their courses, and another for courses and instructors.

2NF Tables:

Students Table:

StudentCourses Table:

Courses Table:

Step 3: Third Normal Form (3NF)

In 3NF, we remove transitive dependencies, where non-key attributes depend


on other non-key attributes. In this case, InstructorName depends on CourseID, not
on the primary key. So, we split the Courses table to eliminate this dependency.
3NF Tables:

Students Table:

StudentCourses Table:

Courses Table:

Instructors Table:
Final Result:

The database is now normalized to 3NF, with all data dependencies properly
organized. This removes redundancy (e.g., instructor names only appear once
per course) and ensures data integrity.

 Students Table contains student details.


 StudentCourses Table links students to courses.
 Courses Table stores course information.
 Instructors Table links courses to instructors.

This structure makes it easier to update or query data without risking


inconsistencies.

You might also like