Normalization Is The Process of Organizing Data in A Database To Minimize Redundancy and Enhance Data Integrity
Normalization Is The Process of Organizing Data in A Database To Minimize Redundancy and Enhance Data Integrity
enhance data integrity. This is achieved by breaking data into tables and defining relationships
between them based on specific rules called normal forms.
Examples:
1st Normal Form (1NF) - Each column should hold only one value per entry, ensuring no
repeating groups.
ID Name Subject
ID Name Subject
2nd Normal Form (2NF) - All non-key attributes must depend on the entire primary key, not just
part of it.
1 Michaela Bates
Subject Table:
ID Subject
1 Science
3rd Normal Form (3NF) - Non-key attributes should not depend on other non-key attributes.
1 BSIT
Teacher Table:
Teacher Department
Joining is a method used in databases to combine rows from two or more tables based on a
related column. It allows you to retrieve data that is distributed across multiple tables, which is
common in normalized databases.
INNER JOIN: Retrieves only the rows that have matching values in both tables.
SELECT
department.department_id,
department.department_name,
course.course_id,
course.course_name
FROM
department
INNER JOIN
course
ON
department.department_id = course.department_id;
LEFT JOIN (LEFT OUTER JOIN): Retrieves all rows from the left table, and the matching rows
from the right table. If there’s no match, it fills with NULL.
SELECT
department.department_id,
department.department_name,
course.course_id,
course.course_name
FROM
department
LEFT JOIN
course
ON
department.department_id = course.department_id;
RIGHT JOIN (RIGHT OUTER JOIN): Retrieves all rows from the right table, and the matching
rows from the left table. If there’s no match, it fills with NULL.
SELECT
department.department_id,
department.department_name,
course.course_id,
course.course_name
FROM
department
RIGHT JOIN
course
ON
department.department_id = course.department_id;
FULL JOIN (FULL OUTER JOIN): Combines results from both LEFT and RIGHT joins,
returning all rows from both tables, with NULL where there’s no match.
SELECT
department.department_id,
department.department_name,
course.course_id,
course.course_name
FROM
department
FULL JOIN
course
ON
department.department_id = course.department_id;