DB Chapter2
DB Chapter2
DB Chapter2
Example:
Entity type: STUDENT
Entity instance: Student with ID number AAU021
Entity set: Collection of all students
Attributes in ER diagram
Composite
single-valued
multi-valued
Stored and
Derived attributes
Simple vs composite attributes
Single-Valued VS Multi-Valued attributes
Multi-valued attributes, on the other hand, may have more than one
value for an entity instance
Example
R є E1 x E2
R є E1 x E2 x E3
Questions:
Q1. Can an instance of X be associated with more than one
instance of Y?
Q2. Can an instance of Y be associated with more than one
instance of X?
The 2 questions above have 4 possible answers. Those answers
determine the type of maximum cardinalities
Cont’d…
Question 1 Question 2 Types of maximum cardinality
Yes Yes Many-to-Many
Yes No Many –to-One
No Yes One –to-Many
No No One –to-One
One to One Relationship
An entity in X is associated with at most one entity in Y
and vice-versa.
1.Total participation
2.Partial participation
Total Participation
In total participation , each entity in the entity set occurs in at
least one relationship in the relationship set
The example below shows that the participation of the entity set
Department Manages is total . This is because every department
must have a manager .
Partial participation
In partial participation , some entities (not all entities) in the entity set occurs
in the relationship in the relationship set.
Example : EMPLOYEE in the MANAGES relationship type. we do not expect
every employee to manage a department, so the participation of EMPLOYEE in
the MANAGES relationship type is partial(some or "part of the set of" employee
entities are related to a department entity via MANAGES, but not necessarily
all) .
Cont’d…
A strong entity type exists independent of other entity types. They have their
own primary keys.
A weak entity type is an entity type that doesn’t have a primary key of its own.
It depends on
another entity type called the owner or identifying entity type to be uniquely
identified
It needs Foreign keys in conjunction with its attributes to create a primary key
A weak entity type always has a total participation constraint with respect to
its identifying relationship.
Cont’d…
Cont’d…
From the previous slide we can see that Dependent is a weak
entity type. It is not an object of interest to be stored in the
database but it should be stored because of the existence of
another entity type – the Employee – which it is related with
Employee is the owner or the identifying entity type
Dependent is described by the dependent’s first name , last name and birth
date
It is related with the owner entity type via the identifying relationship type
HAS
Cont’d…
Exercise
A. Construct an E-R diagram for a hospital with a set of patients and a set of
medical doctors.
Associate with each patient a log of the various tests and examinations
conducted.
Assignment
B. Construct appropriate tables for the above ER Diagram
Construct full ER diagram for Company
Enhanced entity relationship(EER)
Introduction
Since the late 1970 there has been an increase in the emergence of
new database applications, such as GIS, Multimedia databases,
Mobile databases ,etc. with more demanding requirements
◦ Attributes inheritance
Example
.
Super class/Subclass relationship example
University Example of Super class/Subclass
Generalization and Specialization
Super class
Specialization
A Specialization is the process of defining a set of subclasses of a super class by
identifying their distinguishing attributes.
The top section gives the class name (similar to entity type name);