Chapter 3
Chapter 3
Systems
ENTITY RELATIONSHIP MODEL
ENTITY RELATIONSHIP MODEL
▪ ER Model is a logical representation of data in an organization.
▪ It views the entire system as a collection of entities related to one another.
▪ It is used to describe the elements of a system and their relationships.
▪ It was introduced by Peter Chen in 1976.
▪ Conceptual Simplicity to represent database, its
entities and relationship.
▪ Visual Representation of data and relationships
among data for easy understanding of system by
designers, programmers and end users.
▪ Effective Communication Tool to get different views
of data from designers, programmers and end users.
▪ Integrated with Relational database Model.
ELEMENTS OF ER MODEL
▪ Entities
▪ Entity Type
▪ Entity Instance
▪ Entity Set
▪ Attributes
▪ Attribute Domain
▪ Relationships
▪ Person, place, thing or event for which data is collected and maintained.
▪ Person: TEACHER, PLAYER, DOCTOR
▪ Place: CPUNTRY, CITY
▪ Object: VEHICLE, TOY, FURNITURE
▪ Event: PURCHASE, ADMISSION, REGISTRATION
▪ Concept: ACCONT, PROGRAMMING
▪ Example:
▪ Library System may contain data about different entities like BOOK and MEMBER.
▪ In ER Model, entity is represented by a rectangle. The name of entity is written
inside the rectangle.
▪ The entity is used in three different meanings:
▪ Entity Type or entity class : Set of entities with same attributes. E.g.
▪ STUDENT entity class is set of all students.
▪ BOOK entity class is set of all books.
▪ Entity Instance or entity occurrence: Member of an entity class having its own
value for each instance. E.g.
▪ Abdullah is an entity instance of entity type STUDENT.
▪ Entity Set: Set of all entities of a particular type in the database at a given point of
time. e.g.
▪ Entity set TEACHER may consist of all teachers in the university.
▪ Same name is used for both Entity Type and ENTITY SET.
▪ The characteristics of an entity are called attributes or properties.
▪ Example: The attributes of Entity STUDENT are Name, class, email, address etc.
▪ All instances of a particular entity class have same attributes.
▪ Attributes are represented as oval.
▪ Attribute Domain: Set of possible values for an attribute.
▪ All attributes have domain, consisting of range of values or some discrete values.
▪ Domain is defined in form of data type (Integer, char) and some other constraints like range constraint (A-D,
F).
▪ Logical connection between different entities.
▪ The entities that participate in a relationship are called participants.
▪ The relationship may be between different entities or between and entity and
itself.
▪ A relationship is established on the basis of interaction among these entities.
▪ Example: a relationship exists between a STUDENT and TEACHER because the
teacher teaches the student.
▪ Relationship is represented using Diamond symbol.
▪ A relationship is called Total if all the entity set may be participant in the
relationship.
▪ A relationship is called partial if some of the entities of that entity set may be
participant in the relationship.
▪ Example
Relationship between SUPPLIER and PART will
be total if all parts are supplied by that
SUPPLIER, Otherwise partial.
▪ ER Diagram is a graphical representation of ER model using a set of standard
symbols.
▪ Weak Entities & Strong Entities
▪ An entity that can exist only if another entity exists is known as weak entity.
▪ It is represented by double-line square.
▪ The entity on which the weak entity depends is called owner or identifying
owner.
▪ An entity that can exist without depending upon the existence of another entity is
known as strong entity.
▪ It is also called as parent, owner or dominant entity.
Example
Gender is single
valued attributes.
Employ may have
more than one skills.
Multi-valued attributes
is represented by
double-line oval.
▪ Stored attributes and Derived Attributes
▪ An attribute that is stored in a database is called stored attributes.
▪ Most of the attributes are stored attributes. These are stored and accessed from
database.
▪ An attribute that is not stored in database but derived from another value is called
derived attributes.
▪ The other value can be stored in the database or obtained in some other way.
▪ Example
▪ Stored Attribute: Name, DOB
▪ Derived Attribute: Age
▪ Derived attribute is indicated by using
an ellipse with a dashed line.
▪ Identifier
▪ An attribute that identifies an entity instance among other instances in entity class.
▪ Example
▪ Each instance of STUDENT entity class is identified by his Reg. No.
▪ Employee ID for EMPLOYEE entity class.
▪ NIC # of a PERSON entity class.
▪ Identifier can be unique or non-unique. E.g. Student ID is unique for every student
but Department is non-unique identifier as it identifies all students studying in a
particular dept.
▪ Identifier can also be simple or composite identifier.
▪ Identifier
▪ Identifier can also be simple or composite identifier.
▪ A relationship may consist of many entities.
▪ The number of entities in a relationship is called degree of relationship.
▪ The relationship of degree 2 are most common and are also called binary
relationships.
▪ The types of relationships with respect to degrees are as follows:
▪ Unary Relationship.
▪ Binary Relationship
▪ Ternary Relationship
▪ Unary relationship is a type of relationship that is established between the
instances of same entity type.
▪ This is also known as recursive relationship.
▪ Binary relationship exists between the instances of two entity types.
▪ One-to-one Relationship
▪ This type of relationship is used when “ for each entity instance in first entity class,
there is only one instance in the second entity class and for each instance in
second entity class, there is only one instance in the first entity class”.
▪ One-to-Many Relationship
▪ This type of relationship is used when “ for each entity instance in first entity class,
there can be many instances in the second entity class and for each instance in
second entity class, there is only one instance in the first entity class”.
▪ Many-to-Many Relationship
▪ This type of relationship is used when “ for each entity instance in first entity class,
there can be many instances in the second entity class and for each instance in
second entity class, there can be many instances in the first entity class”.
▪ Relationship among the instances of three entity types.
▪ Relationship among the instances of three entity types.
▪ The maximum number of relationships is called cardinality.
▪ The cardinality constraints specifies the number of instances in one entity that can
be associated with each instance of the other entity.
▪ There are three symbols used to show degree.
▪ A circle means Zero (optional relationship) means that the minimum number of
relationships between each instance of the first entity and instance of the related entity is
Zero.
▪ A line means one (Mandatory Relationship) means that the minimum number of
relationships between each instance of the first entity and instance of the related entity is
one.
▪ Crow’s foot means many
▪ The second symbol represents the cardinality.
▪ A stoke indicates that maximum number of relationships is one.
▪ Crows foot indicates that the many relationships between instances of the related
entities may exist.
▪ These symbols are as follows:
▪ The minimum number of instances of one entity may be associated with each
instance of another entity is known as minimum cardinality.
▪ If it is zero, participation is optional. If it one, participation is mandatory.
▪ The maximum number of instances of one entity that may be associated with each
instance of another entity is known as maximum cardinality.
A user may have a locker a locker must belong to an employee
Minimum
cardinality is
closer to the
middle
Maximum
cardinality is
closer to the
entity
Example