Week4 EDM ERD
Week4 EDM ERD
Week4 EDM ERD
Fundamentals
ER Diagrams contain different symbols that use rectangles to represent entities, ovals to define
attributes and diamond shapes to represent relationships.
ER Diagram Example
Entities
Attributes
Relationships
ER Diagram Examples
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.
ER Diagram Examples
WHAT IS ENTITY?
A real-world thing either living or non-living that is easily recognizable and nonrecognizable. It is anything in
the enterprise that is to be represented in our database. It may be a physical thing or simply a fact about the
enterprise or an event that happens in the real world.
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.
SQL ENTITY
Examples of entities:
Entity set:
Student
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.
SQL ENTITY
Example of Entities:
A university may have some departments. All these departments employ various lecturers and offer several
programs.
Some courses make up each program. Students register in a particular program and enroll in various courses.
A lecturer from the specific department takes each course, and each lecturer teaches a various group of
students.
SQL ENTITY
Example of Entities:
A university may have some departments. All these departments employ various lecturers and offer several
programs.
Some courses make up each program. Students register in a particular program and enroll in various courses.
A lecturer from the specific department takes each course, and each lecturer teaches a various group of
students.
SQL Relationship
Relationship is nothing but an association among two or more entities. E.g., Tom works in the
Chemistry department.
Entities take part in relationships. We can often identify relationships with verbs or verb
phrases.
Weak Entities
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.
Let’s learn more about a weak entity by comparing it with a Strong Entity
Weak Entities
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.
In the ER diagram the relationship between two strong The relationship between one strong and a weak entity set
entity set shown by using a diamond symbol. 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.
SQL ENTITY
Example of Entities:
A university may have some departments. All these departments employ various lecturers and offer several
programs.
Some courses make up each program. Students register in a particular program and enroll in various courses.
A lecturer from the specific department takes each course, and each lecturer teaches a various group of
students.
Attributes
It is a single-valued property of either an entity-type or a
relationship-type.
One-to-One Relationships
One-to-Many Relationships
May to One Relationships
Many-to-Many Relationships
Cardinality
Cardinality
1.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
2.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.
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.
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.