Database Management System-Unit-5 Notes
Database Management System-Unit-5 Notes
1. Eliminate Redundancy
o Data duplication increases storage cost and maintenance effort.
o Solution: Normalize tables using First Normal Form (1NF), Second Normal
Form (2NF), and Third Normal Form (3NF).
2. Ensure Data Integrity
o Use Primary Keys to uniquely identify records.
o Apply constraints like NOT NULL, UNIQUE, and CHECK to ensure data validity.
3. Normalize Data
o Organize data into multiple related tables to avoid update anomalies.
Each column contains atomic values (no multiple values in one cell).
Each row is unique (identified by a primary key).
No repeating groups of columns.
Conversion to 1NF
A functional dependency (FD) is a relationship where the value of one attribute uniquely
determines another.
Why Decomposition?
Decomposition is done to remove redundancy and ensure normalization (2NF, 3NF, BCNF).
This table violates 2NF because Customer_Name depends only on Customer_ID, not Order_ID.
Customer_ID Customer_Name
1001 John
1002 Sarah
SQL Implementation
CREATE TABLE Customers (
Customer_ID INT PRIMARY KEY,
Customer_Name VARCHAR(50)
);
Benefits of Decomposition
This decomposition ensures the database is in Third Normal Form (3NF) and follows good
relational design
Functional Dependency (FD) defines a relationship between attributes in a table where the value
of one attribute uniquely determines another.
Example:
FDs are crucial for database normalization, helping remove redundancy and ensuring data
integrity.
🔹 Example:
A → A (Always true).
{Student_ID, Name} → Name (Since Name is already part of {Student_ID, Name}, it is
trivial).
🔹 Example:
3. Transitive Dependency
🔹 Example:
Courses and phone numbers are independent of each other, leading to an MVD.
📌 Notation: If A →→ B, then for each value of A, there exist multiple values of B, independent of
other attributes.
Student_ID Course
101 Math
101 Science
👉 Now, courses and phone numbers are stored independently, preventing redundancy and
anomalies.
✔ Customers Table:
Customer_ID Customer_Name
1001 John
1002 Sarah
Employee_ID → Department_ID
Department_ID → Department_Name
Employee_ID Department_ID
101 D1
102 D2
✔ Departments Table:
Department_ID Department_Name
D1 HR
D2 Finance
🔴 Issue:
✔ Course_Instructor Table:
Course Instructor
Math Prof. A
Science Prof. B
🔴 Issue:
Student_ID →→ Course
Student_ID →→ Phone Number
✔ Student_Courses Table:
Student_I Course
D
101 Math
101 Science
✔ Student_Contacts Table:
Student_I Phone Number
D
101 12345
101 67890
101 55555
🔴 Issue: If new roles or assignments exist, the table can become hard to maintain.
✔ Projects Table:
Project_ID Employee_ID
P1 E1
P1 E2
P2 E1
✔ Roles Table:
Employee_ID Role
E1 Developer
E2 Tester
E1 Manager
Database-Design Process
The database design process consists of several steps to create an efficient and well-structured
database. It ensures data integrity, minimizes redundancy, and optimizes performance. The key
steps are:
1. Requirements Analysis
💡 Example:
A university database requires details about students, courses, and enrollments.
💡 Example ER Diagram:
4. Physical Design
💡 Example:
Creating an index for faster lookup on Student_ID:
5. Implementation
INSERT INTO Student (Student_ID, Name, Age) VALUES (101, 'Alice', 20);
INSERT INTO Course (Course_ID, Course_Name, Credits) VALUES (C1, 'Database
Systems', 3);
INSERT INTO Enrollment (Student_ID, Course_ID, Semester) VALUES (101, C1,
'Spring 2025');
SELECT Student.Name
FROM Student
JOIN Enrollment ON Student.Student_ID = Enrollment.Student_ID
JOIN Course ON Enrollment.Course_ID = Course.Course_ID
WHERE Course.Course_Name = 'Database Systems';