You are on page 1of 30

ICTE 242: DBMS

Delali Kwasi Dake


2021

Lesson 2: E-R Diagrams


In This Lecture
 Entity/Relationship models
 Entities and Attributes
 Entity Instances
 Relationships
 Cardinalities
 Crows Foot Notation

Entity Relationship Modelling


Ideal Concept of E-R Diagram
Ideal Concept of E-R Diagram
ERD (Entity Relationship Diagram)

► ERD is a modeling tool used to depict


graphically a database design before it is
actually implemented.
► It has four basic components, namely, an

Entity, Relationship, Cardinality and an


Attribute.
Entity
► is a real-world object distinguishable or unique from
other objects.
► An entity can be a concrete or physical object like

employee, student, faculty, customer etc. Or it could


also be conceptual or abstract like transaction,
order, course, subjects etc.
► It can be thought of as a noun like student, employee

etc.
► It is normally denoted by a rectangular shape.
Weak Entity
► A weak entity is an entity that depends on the
existence of another entity. In more technical terms
it is defined as an entity that cannot be identified by
its own attributes
► It uses a foreign key combined with its attribute to

form the primary key.


Weak Entity
► A companies insurance policy insures an
employee and any dependent, the DEPENDENT
cannot exist without the EMPLOYEE; that is a
person cannot get insurance coverage as a
dependent unless the person is a dependent of an
employee. DEPENDENT is the weak entity in
the relationship "EMPLOYEE has
DEPENDENT"
.
Attribute
► Refers to the characteristic or basic fact or field of an
Entity or Relationship.
► For example a Student entity could have the following
attributes ID Number, Last Name, First Name,
Address, Birth Date etc.
► It is normally represented by oval shape.
Composite Attribute

A composite attribute
has multiple components
Multivalued Attribute

► A multivalued attribute can have more than one value at


a time for an attribute. Skills of a surgeon is a
multivalued attribute since a surgeon can have more
than one skill. A teacher can have more than one value
for subjects
Derived Attribute

► An attribute based on another attribute. For example


area can be derived from radius
► Age from DOB and Todays Date.
Identify All Attribute Types
Relationship
► Relationship describes how entities are related
Relationship Feature
 Cardinality and Ordinality : respectively refer to the
maximum number of times an instance in one entity can be
associated with instances in the related entity, and the
minimum number of times an instance in one entity can be
associated with an instance in the related entity.
 Degree of Relationship : How many entities are involved in
a relationship
Recursive Relationship

► If the same entity participates more than once in a


relationship it is known as a recursive relationship. Eg.
An employee can be a supervisor and be supervised
Maximum and Minimum Cardinality

► Maximum Cardinality describes the maximum number


of entity instances that can participate in a relationship
► One-to-One
► One-to-Many
► Many-to-Many

► Minimum Cardinality (Ordinality) describes the


minimum number of entity instances that must
participate in a relationship. Either 0 or 1
Cardinality & Crows Foot Notation
Cardinality & Crows Foot Notation
Cardinality & Crows Foot Notation
1. A CUSTOMER has 0 to Many Sales Orders
2. A SALES ORDER must have a Customer
3. A SALES ORDER has one to many Products
4. A PRODUCT has 0 to many Sales Orders

5. NB : Entities must be mentioned as Singular


1. A BUILDING contains 1 or many Rooms
2. A ROOM must have a building or must be in a building

3. NB : Entities must be mentioned as Singular


1. A STUDENT can take 1 or many courses
2. A COURSE is read by 0 or many students

3. NB : Entities must be mentioned as Singular


Rules in Drawing E-R Diagrams
► Identify all the relevant entities in a given system and
determine the relationships among these entities.
► An entity should appear only once in a particular
diagram.
► Provide a precise and appropriate name for each entity,
attribute, and relationship in the diagram. Terms that are
simple and familiar always beats vague, technical-
sounding words. In naming entities, remember to use
singular nouns. However, adjectives may be used to
distinguish entities belonging to the same class (part-
time employee and full time employee, for example).
Meanwhile attribute names must be meaningful, unique,
system-independent, and easily understandable.
Rules in Drawing E-R Diagrams
► Remove vague, redundant or unnecessary relationships
between entities.
► Never connect a relationship to another relationship.
Crows Foot with Cardinality
Types of Relationship
Assignment
► Using Crows Foot Notation with Cardinality, draw a
complete E-R Diagram for Online Food Ordering
System.
► NB: Use SmartDraw automated software for the project.

You might also like