Entity Relationship Diagram: Ruben A. Parazo Faculty, Department of Computer Studies
Entity Relationship Diagram: Ruben A. Parazo Faculty, Department of Computer Studies
Entity Relationship Diagram: Ruben A. Parazo Faculty, Department of Computer Studies
Ruben A. Parazo
Faculty, Department of Computer Studies
What is the ER Model?
• ENTITY RELATIONAL (ER) MODEL is a high-level conceptual data
model diagram. The Entity-Relation model represents real-world
entities and the relationship between them.
• It is considered a best practice to complete ER modeling before
implementing database.
• ER modeling helps analyze data requirements systematically to
produce a well-designed database.
What is ER Diagrams?
• ENTITY-RELATIONSHIP DIAGRAM (ERD) displays the relationships of
entity set stored in a database.
• ER diagrams help you to explain the logical structure of databases.
• The purpose of ER Diagram is to represent the entity framework
infrastructure.
Example ERD
About ER Diagram Model
• ER model allows you to draw Database Design
• It is an easy to use graphical tool for modeling data
• Widely used in Database Design
• It is a GUI representation of the logical structure of a Database
• It helps you to identifies the entities which exist in a system and the
relationships between those entities
ER Diagram Notations
• Rectangles: This symbol represent entity types
• Ellipses : Symbol represent attributes
• Diamonds: This symbol represents relationship types
• Lines: It links attributes to entity types and entity types with other
relationship types
• Primary key: attributes are underlined
• Double Ellipses: Represent multi-valued attributes
Symbols used for ER
Components of the ER Diagram
• Entities
• Attributes
• Relationships
ENTITY
• An entity can be place, person, object, event or a concept, which
stores data in the database.
• The characteristics of entities are must have an attribute, and a
unique key.
• Every entity is made up of some 'attributes' which represent that
entity.
Examples of entities
• Person: Employee, Student, Patient
• Place: Store, Building
• Object: Machine, product, and Car
• Event: Sale, Registration, Renewal
• Concept: Account, Course
Entity set
• An entity set is a group of similar kind of entities.
• It may contain entities with attribute sharing similar values.
• Entities are represented by their properties, which also called
attributes.
• All attributes have their separate values.
• For example, a student entity may have a name, age, class, as attributes.
Example of Entity and Entity Set
Weak Entity
• A weak entity is a type of entity which doesn't have its key attribute.
• It can be identified uniquely by considering the primary key of
another entity.
• For that, weak entity sets need to have participation.
Strong Entity Set Weak Entity Set
Strong entity set always has a primary key. It does not have enough attributes to build a primary
key.
It is represented by a rectangle symbol. It is represented by a double rectangle symbol.
It contains a Primary key represented by the underline It contains a Partial Key which is represented by a
symbol. dashed underline symbol.
The member of a strong entity set is called as The member of a weak entity set called as a
dominant entity set. subordinate entity set.
Primary Key is one of its attributes which helps to In a weak entity set, it is a combination of primary key
identify its member. and partial key of the strong entity set.
In the ER diagram the relationship between two strong The relationship between one strong and a weak
entity set shown by using a diamond symbol. entity set shown by using the double diamond symbol.
The connecting line of the strong entity set with the The line connecting the weak entity set for identifying
relationship is single. relationship is double.
Attributes
• It is a single-valued property of either an entity-type or a
relationship-type.
• For example, a lecture might have attributes: time, date, duration,
place, etc.
• An attribute is represented by an Ellipse
Types of Attributes Description
Derived attribute This type of attribute does not include in the physical
database. However, their values are derived from
other attributes present in the database. For example,
age should not be stored directly. Instead, it should be
derived from the DOB of that employee.
Multivalued attribute Multivalued attributes can have more than one values.
For example, a student can have more than one
mobile number, email address, etc.
Cardinality
• Defines the numerical attributes of the relationship between two
entities or entity sets.
• Different types of cardinal relationships are:
• One-to-One Relationships
• One-to-Many Relationships
• May to One Relationships
• Many-to-Many Relationships
Notation
• Crow’s foot Notation- Crow's foot diagrams represent entities as
boxes, and relationships as lines between the boxes. Different shapes
at the ends of these lines represent the relative cardinality of the
relationship.
• Chens Notation- Cardinalities represent the number participating in
the relationship. Three types of relationship cardinalities can exist:
one-to-many (1:M), many-to-many (M:N), and one-to-one (1:1).
Crow’s Foot notation symbols
One to One
Many to
Many
One to Many
Chen’s Notation
One to One
Many to Many
One to Many
Relationship
• Relationship is an association among two or more entities.
• Note:
Entities take part in relationships. We can often identify relationships with verbs or
verb phrases.
One-to-one:
• One entity from entity set X can be associated with at most one entity
of entity set Y and vice versa.
.
One-to-many
• One entity from entity set X can be associated with multiple entities
of entity set Y, but an entity from entity set Y can be associated with
at least one entity.
Many to Many
• One entity from X can be associated with more than one entity from Y
and vice versa.
Example Problem
• In a university, a Student enrolls in Courses. A student must be
assigned to at least one or more Courses. Each course is taught by a
single Professor. To maintain instruction quality, a Professor can
deliver only one course.
Solution:Step 1
• Identify the entity
• Student
• Course
• Professor
Solution: Step 2 Relationship Identification