DBMS Unit-4
DBMS Unit-4
SYLLABUS
1. Schema Refinement (Normalization):
web-D Page 1
SEM :- 2-2 (R20) DBMS UNIT-4
Purpose of Normalization:
1. Minimizing Redundancy:
o Redundancy refers to the repetition of the same data or duplicate copies stored in
different places.
o Normalization eliminates redundancy by breaking down large tables into smaller,
related tables.
2. Avoiding Anomalies:
o Normalization helps avoid insertion, update, and deletion anomalies:
Insertion Anomaly: Difficulty in inserting data due to missing related
information.
Update Anomaly: Inconsistencies when updating data (e.g., changing an
employee’s salary in one place but not everywhere).
Deletion Anomaly: Unintended loss of information when deleting data (e.g.,
deleting an employee also removes their department information).
3. Improving Consistency:
o Normalized schemas ensure that data is consistent and accurate across the entire
database.
web-D Page 2
SEM :- 2-2 (R20) DBMS UNIT-4
Suppose we want to refine this schema to minimize redundancy and avoid anomalies.
We’ll follow the normalization process:
o department_name VARCHAR(50)
o );
Certainly! Let’s explore SQL programs for each of the First Normal Form (1NF),
Second Normal Form (2NF), and Third Normal Form (3NF):
web-D Page 3
SEM :- 2-2 (R20) DBMS UNIT-4
web-D Page 4
SEM :- 2-2 (R20) DBMS UNIT-4
Certainly! Let’s explore the concept of functional dependency and provide an example
using SQL.
Functional Dependency:
Suppose we have a table called Employees with the following columns: emp_id,
emp_name, and salary.
web-D Page 5
SEM :- 2-2 (R20) DBMS UNIT-4
);
In this example:
The table is in 1NF because each attribute contains only one value (atomicity).
There is a primary key (emp_id) for identification.
The salary attribute is directly dependent on the primary key (emp_id).
Certainly! Let’s explore the concepts of surrogate keys and the Boyce-Codd Normal
Form (BCNF) in the context of database design.
Surrogate Key:
Example:
web-D Page 6
SEM :- 2-2 (R20) DBMS UNIT-4
Now, suppose we want to merge the details of both schools into a single table. We can
create a surrogate key (surr_no) to uniquely identify each row:
web-D Page 7
SEM :- 2-2 (R20) DBMS UNIT-4
In this example, the registration_no cannot be the primary key because it does not
match all records in the table. Therefore, we create a surrogate key (surr_no) to uniquely
identify each row.
Suppose we have a table called Students with the following columns: student_id,
student_name, and courses_enrolled.
In this example:
The table is in 1NF because each attribute contains only one value (atomicity).
There is a primary key (student_id) for identification.
The courses_enrolled attribute may contain multiple courses, but it’s stored as a
single value (not a repeating group).
BCNF is a stronger normal form than the Third Normal Form (3NF).
It ensures that every determinant (attribute determining another attribute) is a
superkey (a candidate key).
BCNF eliminates redundancy caused by dependencies that violate one or more
candidate keys.
web-D Page 8
SEM :- 2-2 (R20) DBMS UNIT-4
Certainly! Let’s explore SQL programs for the concepts of surrogate keys and the
Boyce-Codd Normal Form (BCNF).
BCNF Example:
In this example:
web-D Page 9
SEM :- 2-2 (R20) DBMS UNIT-4
Examples:
o Suppose we have two tables representing student data from different schools:
Table A (School A):
web-D Page 10
SEM :- 2-2 (R20) DBMS UNIT-4
o We want to merge the details of both schools into a single table. The resulting
table will have a surrogate key (surr_no) to uniquely identify each row.
2. Fourth Normal Form (4NF):
o emp_id INT,
o project_name VARCHAR(100),
o skills_required VARCHAR(200),
o );
web-D Page 11
SEM :- 2-2 (R20) DBMS UNIT-4
web-D Page 12