Professional Documents
Culture Documents
CS8492 - Database Management Systems: II Year / IV Semester
CS8492 - Database Management Systems: II Year / IV Semester
Systems
II Year / IV Semester
UNIT II DATABASE DESIGN
An entity has set of properties, and the values for some set of
properties may uniquely identify an entity.
An entity set is a collection of entities having the same properties
ER Model - Concepts
Attributes:
The properties that describe an entity are called
attributes.
In the customer entity customer id, name, street
are the attributes
ER Model - Concepts
Attributes – Types:
Simple attribute:
An attribute that cannot be divided into further
subparts (atomic).
Example: Customer-id of customer entity
ER Model - Concepts
Attributes – Types:
Composite attribute:
An attribute that can be divided into a set of
Employee
subparts.
Salary
Name Address
Attributes – Types:
Attributes – Types:
Multi-valued attribute:
An attribute having more than one value for a
Employee
particular entity.
Degrees
Name Address
Attributes – Types:
Derived attribute:
An attribute that is derived from other related
Employee
attributes or entities.
Age
Birthdate Address
Relationship set:
an association among several entities.
a set of relationships of the same type.
Mapping Cardinality:
the number of entities to which another entity can
be associated via a relationship set.
For a binary relationship set R between entity sets
A and B
ER Model
Mapping Cardinality - One-to-one (1 : 1)
An entity in A is associated with at most one entity in B, and
an entity in B is associated with at most one entity in A.
One-to-many (1 : M)
An entity in A is associated with any number of entities in
B. An entity in B can be associated with at most one entity in
A.
ER Model
Mapping Cardinality - Many-to-Many (M : N)
An entity in A is associated with any number of entities in B,
and an entity in B is associated with any number of entities in
A.
Many to one (M : 1)
An entity in A is associated with at most one entity in B. An
entity in B can be associated with any number of entities in A.
ER Model
Ternary relation:
If a relationship connects three entities.
Entities: Product, Supplier and customer
Relationship: buy
ER Model
Entity Rectangle
Relationship Diamond
Attributes for
any Entity Ellipse
the attribute
Key Attribute
name inside
for any Entity
the Ellipse is
underlined.
Components of ER Diagram
dotted
Derived
ellipse is
Attribute for
created
any Entity
inside the
main ellipse
Multivalued
Attribute for Double
any Entity Ellipse
ER Diagram - Entity
Employee,
Entity Manager,
Department
depends on
Weak Entity
another
entity
ER Diagram - Attribute
Component Description Symbol
Attribute
property or
(Name, Age,
characteristic
Address)
of an entity
main
Key Attribute
characterstic
of an Entity
Composite
have their
Attribute
own attributes
ER Diagram - Relationship
Component Description Symbol
One to Many
1 student can opt for
Relationship
many courses
“Good Database”
Normalization
Modification Anomalies
Ex: (Empid,Empname,Projectid,Projectname)
Update Anomalies: If any changes in Projectname , it
changes to empid,empname in the relation.
Insertion Anomalies: If Projectid is NULL.
Deletion Anomalies: If delete projectid,projecctname
is deleted, then it has NULL values
Normalization
Decomposition
the process of breaking down one table into
multiple tables. ID Name Age
1 A 20
2 A 21
Decomposition – Lossy:
ID Name Name Age
1 A A 20
2 A A 21
ID Name Age
1 A 20
1 A 21
2 A 20
2 A 21
Concept of Relational Database Design
XY
Armstrong’s Axioms:
Reflection: if X ⸧ Y, then X Y
Closure Dependencies:
F – Functional Dependencies
F+ - Closure Functional Dependencies
X – Attributes of F
X+ - Attributes of F +
F covers G, if G+ ⸦ F+
F and G are equivalent if F+ = G+
FUNCTIONAL DEPENDENCY
Types:
Full functional dependency
Partial functional dependency
Transitive functional dependency
FUNCTIONAL DEPENDENCY
Types - Full functional dependency
Uses:
Forms:
111 Maths 38
111 Physics 38
222 Biology 38
333 Physics 40
333 Chemistry 40
The table is in first normal form and all the columns depend on the
table’s primary key.
teacher_id subject
111 Maths
teacher_id teacher_age
111 Physics
111 38
222 Biology
222 38
333 Physics
333 40
333 Chemistry
NORMALIZATION
Third normal form 3NF:
A table design is said to be in 3NF if both the following
conditions hold:
Table must be in 2NF
Transitive functional dependency of non-prime attribute on any
super key should be removed.
OR
Every non prime attribute
fully FD on every key, and
non transitively FD on every key
NORMALIZATION
sid sname zipcode cityname state
Student zip
sid sname zipcode zipcode cityname state
1 C Aruna
2 Java Kani
3 C Aruna
4 C++ Anjana
5 C Vani
(sid,course)->teacher
teacher->course
Student Course
1 Aruna Aruna C
2 Kani Kani Java
3 Aruna Aruna C
5 Vani Vani C
ER to Relational Mapping
Example:
Sid Course Skill
C English
1
C++ German
English
2 Java
French
Example:
Sid Course Skill
1 C English
1 C++ German
1 C German
1 C++ English
2 Java English
2 Java French
Fourth Normal Form
Conditions:
It should be in the Boyce-Codd normal Form.
the table should not have any multi-valued
dependency.
Fourth Normal Form
Student Table:
Sid Course Skill
1 C English
1 C++ German
1 C German
1 C++ English
2 Java English
2 Java French
Fourth Normal Form
Sid Course
Student_Course Table: 1 C
1 C++
2 Java