EE - DBMS - Unit 1 With Normalization
EE - DBMS - Unit 1 With Normalization
1. Understand and successfully apply logical database design principles, including E-R diagrams and database normalization.
4. Learn database architectures, DBMS advancements and its usage in advance applications.
Course Outcomes: Upon completion of the course, the students will be able to:
1. Design ER-models to represent simple database application scenarios and Improve the database design by normalization.
2. Design Database Relational Model and apply SQL , PLSQL concepts for database programming.
4. Identify appropriate database architecture for the real world database applications.
Important Components of
Database System :
Database Users
Query Processing
Storage Management
Transaction Management
Naive Users
Application Programmers
Sophisticated Users
Database Administrators
Roles
Entity sets of a relationship need not be distinct.
Each occurrence of an entity set plays a “role” in the relationship.
The labels “course_id” and “prereq_id” are called roles.
1. One-to-One Relationship
one-to-one relationship between an
instructor and a student
◦ an instructor is associated with at
most one student via advisor
◦ and a student is associated with at
most one instructor via advisor
An entity set that does not have a primary key is referred to as a weak
entity set.
The existence of a weak entity set depends on the existence of a
identifying entity set
◦ It must relate to the identifying entity set via a total, one-to-many
relationship set from the identifying to the weak entity set
◦ Identifying relationship depicted using a double diamond
The discriminator (or partial key) of a weak entity set is the We underline the discriminator of a
set of attributes that distinguishes among all the entities of a weak entity set with a dashed line.
weak entity set. We put the identifying relationship
of a weak entity in a double
The primary key of a weak entity set is formed by the primary
key of the strong entity set on which the weak entity set is diamond.
existence dependent, plus the weak entity set’s discriminator. Primary key for section –
(course_id, sec_id, semester, year)
Question : Design a ER Diagram for University Database based on scenario given below :
A university includes information about the course timetable of an academic institution. For each
Course the following information is recorded an identification number, name of the course, name
of the teacher assigned to teach the course, the number of periods each week it will be taught, the
number of
For each teacher the following information is recorded: SSN, name, name of the department
he/she works with, skills, the yearly salary. For each class period the following information is
recorded: period number, starting time, ending time. For each room the following information is
recorded: room number, room type (classroom, office, auditorium, and computer lab), capacity.
The above information is used in order to make the right assignment of a teacher that teaches a
particular course to a time period and a classroom.
Example: Instead of creating a schema for relationship set inst_dept, add an attribute
dept_name to the schema arising from entity set instructor
ID First_nam Middle_initial Last_name Street_ Street_ Apt_num city state zip Date_of
e number name ber _birth
attributes
(or columns)
customer_name customer_street customer_city
Customer
Foreign Key(branch-name)
branch (branch-name, branch-city, asset )
Perryridge Brooklyn 500,000
The subset of R2 is a foreign key referencing K1 in relation r1, if for every t2 in r2 there must be a tuple t1 in
r1 such that t1[K1]=t2[].
R1 ( K1, …, … ) R2 ( K2, …, , … )
t2
x
t1
x
The following tests must be made in order to preserve the following referential integrity constraint:
Insert. If a tuple t2 is inserted into r2. The system must ensure that there is a tuple t1 in r1 such that
t1[K] = t2[]. That is
t2[] K(r1)
Delete. If a tuple t1 is deleted from r1, the system must compute the set of tuples in r2 that reference
t1:
=t1[K](r2)
if this set is not empty, either the delete command is rejected as an error, or the tuples that reference
t1 must themselves be deleted (cascading deletions are possible)
if a tuple t2 is updated in relation r2 and the update modifies values for the foreign key , then a test
similar to the insert case is made. Let t2’ denote the new value of tuple t2. The system must ensure
that
new foreign key value must
t2’[] K(r1)
exist
if a tuple t1 is updated in r1, and the update modifies values for primary key(K), then a test similar to
the delete case is made. The system must compute
=t1[K](r2)
no foreign keys contain the old
primary key
using the old value of t1 (the value before the update is applied). If this set is not empty, the update
may be rejected as an error, or the update may be applied to the tuples in the set (cascade update), or
the tuples in the set may be deleted.
Key Constraints :
Consider Works_in Relationship: An
employee can work in many departments ; a
department can have many employees.
In contrast, each department has at most one
manager ,according to the key constraint on
Manages Relationship
Example :
A trigger is a statement that is executed Suppose that instead of allowing negative
automatically by the system as a side account balances, the bank deals with
effect of a modification to the database. overdrafts by
setting the account balance to zero
To design a trigger mechanism, we must: creating a loan in the amount of the overdraft
◦ Specify the conditions under which the giving this loan a loan number which is identical to
trigger is to be executed. the account number of the overdrawn account.
◦ Specify the actions to be taken when the
trigger executes. The condition for executing the trigger is an
update to the account relation that results in
a negative balance value.
M M 1 M
Course Staff Student
Course
CourseCode Name Duration
Reflection Spot 2
Q. Based on the relationship between Staff and Course can we add foreign
key in any of above relations in the translation process?
Team CourseCode Staff-ID Answer : We can’t add a Foreign Key; as Both Relations
have a ‘M’ end.
Rule : We must create an ‘artificial’ linking Relation.
Course CourseCode Name Duration
Staff
Staff-ID Name Address ScalePoint DOB
Relation r
Notation : r x s A B C D E
C D E
1 10 a
10 a
Assume that attributes of r(R) and s(S) are disjoint. 1 10 a
(That is, R S = ). 10 a
If attributes of r(R) and s(S) are not disjoint, then
A B rⅹs 1 20 b
renaming must be used. 1 20 b
1 10 b
2 10 b
2 10 a
2 10 a
Relation r Relation s 2 20 b
2 10 b
Question. Consider the database given below. Suppose we have built a new
room B112 but it has not been added to the time-table what can be the
problem for inserting room information?
Normal Forms :
1 NF (Atomicity)
2 NF (Remove Partial Dependency)
3NF (Remove Transitive Dependency)
Boyce Codd NF (Super key)
4 NF (Multi-valued Dependencies)
5 NF (Join Dependency)
A method to remove all these anomalies and bring the Conversion to 1NF
database to a consistent state.
Consider the relation Course_info
Rules :
All the attributes in a relation must have atomic
domains. Each attribute must contain only a single
The values in an atomic domain must be value from its pre-defined domain.
indivisible units.
2 NF Conversion to 2 NF
Prime attribute − An attribute, which is a part From example , we find that Stu_Name can be identified
of the prime-key, is known as a prime attribute. by Stu_ID and Proj_Name can be identified by Proj_ID
independently. This is called partial dependency, which
Non-prime attribute − An attribute, which is is not allowed in Second Normal Form.
not a part of the prime-key, is said to be a non-
prime attribute. Therefore, we can convert the relation into as shown
below
Consider the relation student_project
Student {Stud_id,Stud-name} and
{Stud_id, Proj_id, Stud_name, Project_Title} Stud_id Stud_name
Rule : Every non-prime attribute should be Project {Proj_id,Project_Title}
fully functionally dependent on prime key
attribute. That is, if X → A holds, then there Prod_id Project_Title
should not be any proper subset Y of X, for
which Y → A also holds true.
DATABASE MANAGEMENT SYSTEMS 95
3 NF : Third Normal Form
Rules :
For a relation to be in Third Normal Form, it must be in Second Normal form and the
following must satisfy −
No non-prime attribute is transitively dependent on prime key attribute.
For any non-trivial functional dependency, X → A, then either
◦ X is a super key or,
◦ A is prime attribute.
Consider relation Stud_info
Stud_info {rno,name,marks,zip,city,dob}
rno name marks zip city dob
Reflection Spot 3
Question. Does the above relation satisfy the 3 NF criteria??If no convert it to 3 NF.
Ans : No. The given relation does not satisfy the 3NF as it contains following transitive
dependency:
We have : Rno->zip but zip->city
Therefore Rno->city (Transitive Dependency)
Conversion to 3NF :
Stud_info {rno,name,marks,dob,zip}
Zip_city {zip,city}
zip city