Sie sind auf Seite 1von 30

Database Systems!

ER Relationship Model

Dr. Seema Jehan
Outline!
•  ER Model basics
•  Entities and Attributes
•  Entity Types and Entity Sets
•  Relationship types
•  Weak Entity Types
Entity Relationship (ER) Model!
•  ER Model is one model that helps us fix the perception of
reality.

•  This model is used for the conceptual design of database


applications.

•  Once the analysis phase is complete, the next phase is to


build a conceptual schema for the database.

•  The conceptual schema includes detailed description of


the entity types, relationships and constraints.

•  Helps in communication with non-technical users


Entity!
•  An entity is a thing or object in the real world with
an independent existence.

•  It may be an object with a physical existence (a car,


a house, or an employee)

•  It may be an object with a conceptual existence( a


company, a job or a university course)
Entity Types!
•  A database usually contains groups of entities that are
similar.

•  For example, a company employing hundreds of


employees may want to store similar information
concerning each of the employees.

•  With in one ER diagram, entity type names must be


unique.

Employee!
Single-valued Attributes !
•  Each entity has attributes/properties.
•  Attribute types are represented by ellipses.
•  For Employee entity type, we have Email, Name as single
value attribute.

•  Property values are


•  Lexical, visible, audible Employee!

•  These are things that name others


Email! Name!
Single-valued Attributes !

ahmad@seecs.edu.pk!
Isra!
Eisha! isra@seecs.edu.pk!
eisha@seecs.edu.pk!
Ahmad!
Key Attributes !
•  Some property types are identifying or key properties.
•  That is shown by underlining these types.
•  The value of a key attribute can be used to identify an
entity uniquely.

Employee!

isra@seecs.edu.pk!

eisha@seecs.edu.pk!

Email! ahmad@seecs.edu.pk!
Composite Attributes!
Composite Properties!
Ahmad!

Eisha!
Isra!

Employee!

FName!
Name!
Khan!
Ali!

LName! Awan!
Multi-value Properties!
•  Most attributes have a single value for a particular entity;
•  These are called single-value attributes such as “Age”.
•  Some attributes have multi-value properties; these are
modelled by double ellipses.

Lahore! Islamabad!
Locations!
Karachi!

Department!
Example!
Relationship Cardinality!
•  The degree of a relationship type is the number of
participating entity types.

•  The WORKS_FOR relationship is of degree two (binary).


•  A relationship type of degree three is called ternary.
•  An example of ternary relationship is of “supply” where
each relationship instance ri associates three entities- a
supplier s, a part p and a project j.
1-1 Relationship type!
•  Each Department has one Manager and each Employee
can manage at most one Department.

•  The manages binary relationship type is of cardinality 1:1.

Employee! Manages! Department!

Partial Function
1-Many Relationship type!
•  Each Department has N number of projects but a project
is controlled by one department.

•  The controls binary relationship type is of cardinality1:N.

Department! controls!
Projects!

Total Function
Many-1 Relationship type!
•  Each Department has N number of employees but an
employee can work for at most one department.

•  The works_for binary relationship type is of cardinalityN:1.

Works- for!
Employee! Department!

Total Function
N-M Relationship type!
•  An employee can work on several projects and a project
can have many employees.

•  The works_on binary relationship type is of cardinality


N:M.

Employee! Works- on! Project!

Total Function
N-ary Relationship Types!

Quantity!

Supplier! Supply! Project!


L N

S_Name! M
Proj_name!
Part!

Part_no!
Instance Diagram!
N-ary Relationship Types!
•  It is not always possible to decompose N-ary relationship
(N>3) into binary relationships.
Quantity!

Supplier! Supply! Project!


L N

S_Name! M
Proj_name!
Part!

Part_no!
Attributes of Relationship Types!
•  Relationship types can also have attributes, similar to
those of entity types.

•  An attribute “Hours” for the “WORKS_ON” relationship


type can record the number of hours per week that a
particular employee works on a particular project.

Employee! Works- on! Project!

Hours!
Weak Entity Types!
•  Entity types that do not have key attributes of
their own are called weak entity types.
CNIC!
•  Two dependents of two distinct employees
may have the same values for name, DoB and
Employee! relation even though they are two distinct
employees.

•  They are identified as distinct entities only after


Dependents_of! determining the distinct employee entity to
which each dependent is related.

•  Each weak entity type has a partial key, which


Dependent! is the attribute that can uniquely identify weak
entities that are related to the same owner
Name!
entity.
ER diagram!
MNam
e!
FNam LNam
e! e!
Location
s!
Name! DoB!
Numbe
CNIC! Name!
r!
N 1
Works- for!
Employee! Department!

1
Gend
er! 1 Controls!
Dependents_of!
1
Manages!

N
Dependent!
Relatio Project!
n!
Name! Works_on! Locatio
Gend Numbe n!
er! DoB! Name!
r!
Exercise!
•  Add a recursive relationship SUPERVISION between
EMPLOYEE in the supervisor role and EMPLOYEE in the
subordinate role.
Recursive Relationship!
•  Same entity type participates more than once in a relationship
type in different roles.

•  Such relationship types are called recursive relationships or


self- referencing relationships.

•  The supervision relationship type relates an employee to a


supervisor.

Supervisee

Employee! Supervision!

CNIC! Supervisor
ER Notations !
ER Notations !
Assignment 1!
•  Construct ER diagram for your term project
•  Due Date: 9th November 2020
Summary!
•  ER basic concepts:
•  Entities or attributes
•  Relationship types
•  Participation roles of entity types
•  Cardinality ratios (1:1, 1:N, M:N for binary relationships)
References!
•  Chapter 3, Fundamentals of Database systems, Ramez
Elmasri and Shamkant Navathe, 7th Edition, 2016

•  Udacity course on “Fundamentals of Databases” by


Georgia Tech:
•  https://classroom.udacity.com/courses/ud150/

Das könnte Ihnen auch gefallen