Professional Documents
Culture Documents
Module 10 - ER Model-1
Module 10 - ER Model-1
Relationship Diagram
1
TOPIC CONTENT
▪ Define ER Diagram
▪ ERD Notations
▪ Why use entity relationship diagrams
▪ Components of ER Diagram
▫ Entity
▫ Attributes
▫ Relationships
▪ Steps in creating ER Diagram
▪ Sample ERD
2
ENTITY-RELATIONSHIP DIAGRAM (ERD)
▪ The ERD represents the conceptual database as viewed
by the end user.
▪ It is a type of flowchart that illustrates how “entities”
such as people, objects or concepts relate to each
other within a system.
▪ An ERD uses data modeling techniques that can help
define business processes and serve as the foundation
for a relational database.
ENTITY-RELATIONSHIP DIAGRAM (ERD)
▪ ERDs main components: entities, attributes, and relationships.
▫ Entity represents a real-world object, the words entity and object are
often used interchangeably.
▪ Also known as ERDs or ER Models
▪ Symbols:
ENTITY-RELATIONSHIP DIAGRAM (ERD)
ENTITY-RELATIONSHIP DIAGRAM (ERD)
ERD Notations
▪ The Chen notation favors conceptual modeling.
▫ Developed by computer scientist Peter Chen, Chen ERD notation is considered to be a more
detailed method of illustrating entities and their relationships. It is widely used in database and
software design. Chen ERD notation primarily constitutes entities, attributes, relationships, and
cardinality.
▪ The Crow’s Foot notation favors a more implementation-oriented
approach.
▫ A crow's foot represents "many" or "infinite" These symbols are used in pairs to represent the
four types of cardinality that an entity may have in a relationship. The inner element of the
notation represents the minimum, and the outer element (closest to the entity) represents the
maximum.
▪ The UML notation can be used for both conceptual and implementation
modeling.
▫ A UML diagram is a diagram based on the UML (Unified Modeling Language) with the purpose of
visually representing a system along with its main actors, roles, actions, artifacts or classes, in
order to better understand, alter, maintain, or document information about the system.
ENTITY-RELATIONSHIP DIAGRAM (ERD)
composite attribute.
Country
▪ For example, In student entity, Name Age
the student address is a
composite attribute as an
address is composed of other
attributes such as pin code,
state, country.
TYPES OF ATTRIBUTES
Multivalued attribute: Phone Postal
Student
No. Code
▪ An attribute that can hold
multiple values is known as Municipality
Address
multivalued attribute. It is Roll No.
Weak
Relationship
Relationship
CARDINALITY
▪ Defines the numerical attributes of the relationship between two entities or
entity sets.
▪ The three main cardinal relationships are one-to-one, one-to-many, and
many-many.
1. one-to-one example would be one student associated with one mailing
address.
2. one-to-many example (or many-to-one, depending on the relationship
direction). One student registers for multiple courses, but all those
courses have a single line back to that one student.
3. Many-to-many example: Students as a group are associated with
multiple faculty members, and faculty members in turn are associated
with multiple students.
CARDINALITY
▪ Cardinality
views: Cardinality can be
shown as look-across or
same-side, depending on
where the symbols are
shown.
▪ Cardinality
constraints: The minimum
or maximum numbers that
apply to a relationship
CARDINALITY
▪ One-to-one
▪ One entity from entity set X can be associated with at most one entity of
entity set Y and vice versa.
▪ Example: One student can register for numerous courses. However, all
those courses have a single line back to that one student.
CARDINALITY
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.
▪ For example, one class is consisting of multiple students.
CARDINALITY
Many to One
▪ More than one entity from entity set X can be associated with at most
one entity of entity set Y. However, an entity from entity set Y may or
may not be associated with more than one entity from entity set X.
▪ For example, many students belong to the same class.
CARDINALITY
Many to Many:
▪ One entity from X can be associated with more than one entity from Y
and vice versa.
▪ For example, Students as a group are associated with multiple faculty
members, and faculty members can be associated with multiple
students.
ENTITY KEYS (Attribute)
▪ Entity keys:
▫ Key are essential elements of
any relational tables
▫ It identify each tuple in a
relation uniquely
▫ A key is an attribute or set of
attributes which helps us in
uniquely identifying the rows
of a table.
▫ It also helps in establishing
relationship among tables.
ENTITY KEYS
▪ Entity keys can be super, candidate or primary.
▫ Super key: A set of attributes (one or more) that
together define an entity in an entity set.
▫ Candidate key: A minimal super key, meaning it has the
least possible number of attributes to still be a super key.
An entity set may have more than one candidate key.
▫ Primary key: A candidate key chosen by the database
designer to uniquely identify the entity set.
Properties of Primary Key
▪ A relation can only have one primary key
▪ Each value in a primary key must be unique
▪ Primary key cannot contain null values
ENTITY KEYS
ENTITY KEYS – Super Key
▪ Foreign Key of the entity
attribute in the entity
which is the primary key
of the related entity.
Foreign key helps to
establish the mapping
between two or more
entities.
Difference between Super Key and Candidate Key
▪ A single attribute or a set of attributes that
can uniquely identify all attributes of a
particular related is call super key. On the
other hand, a super key that is a proper
subset of another super key is called
candidate key.
▪ The set of super key is verified to find
candidate keys, whereas, the set of the
candidate keys is verified to select a single
primary key
For example, in a University
database, we might have
entities for Students,
Courses, and Lecturers.
Students entity can have
attributes like Rollno, Name,
and DeptID. They might
have relationships with
Courses and Lecturers.
Steps to Create an ERD
Example:
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
Steps to Create an ERD
Step 1) Entity Identification
We have three entities:
1. Student
2. Course
3. Professor
Steps to Create an ERD
Step 2) Relationship Identification
We have the following two relationships
1. The student is assigned a course
2. Professor delivers a course
Steps to Create an ERD
Step 3) Cardinality Identification
For the problem statement we know that,
• A student can be assigned multiple courses
• A Professor can deliver only one course
Steps to Create an ERD
Step 4) Identify Attributes
• You need to study the files, forms, reports, data currently maintained by
the organization to identify attributes. You can also conduct interviews
with various stakeholders to identify entities. Initially, it's important to
identify the attributes without mapping them to a particular entity.
• Once, you have a list of Attributes, you need to map them to the identified
entities. Ensure an attribute is to be paired with exactly one entity. If you
think an attribute should belong to more than one entity, use a modifier
to make it unique.
• Once the mapping is done, identify the primary Keys. If a unique key is not
readily available, create one.
Steps to Create an ERD
For Course Entity, attributes could be Duration, Credits, Assignments, etc. For the sake of ease we
have considered just one attribute.
Steps to Create an ERD