DEV Community

loading...
Cover image for Entity-Relationship Diagram

Entity-Relationship Diagram

hebaShakeel
A Computer Science Student
・3 min read

It is a high level data model diagram which defines the conceptual view of the database. It indicates the relation among entities.
Before making the actual database, first the ER-diagram is drawn to show the relations and many more things.

Components of ER Diagram:

1) Entity
i) It is a real-world object.
ii) It can be physical.
iii) It can be logical.

Entity Set - It is a set (or collection) of entities of the same type which share the similar properties or attributes.

An entity can be characterized into two types:

i) Strong Entity -
-> It has a Primary Key.
-> It is not dependent.
-> They are shown in single rectangle
ii) Weak Entity -
-> It doesn't have the sufficient attributes to form Primary Key.
-> It is dependent on the Strong Entity.
-> They are shown in double Rectangle.

Example
Alt Text

Total Participation - Weak Entity always has total participation with the Relationship. This means that each entity in the entity set must compulsorily participate in at least one relationship instance in that relationship set.

2) Attributes - They are the properties that describe the entity.

An attribute can be characterized into:

1) Simple Attributes: They are represented by oval.

Example

Alt Text

2) Multi-valued Attributes: Multiple values for a single attribute. They are represented by double oval.

Example

Alt Text

3) Single-Valued Attributes: Each and every entity will have only one value.
Example - ID

4) Composite Attributes: Those attributes that can be divided further.

Example
Alt Text

5) Derived Attributes: Those attributes whose values are derived from another attribute. They are represented by dotted oval.

Example

Alt Text

Age is a derived attribute since age can be derived from the Date of Birth.

6) Key Attribute: Attribute which can uniquely define the whole tuple is called a Key Attribute.

Example- ID
Alt Text

3) Relationship
It indicates how each and every entity is related with every other entity.

Degree of Relationship: A relationship where a number of different entity set participate is called as degree of a relationship.

Degree of relationship can be categorized into the following types:

1) Unary - Only one Entity set participates in a relationship.

Example
Alt Text

2) Binary - Two Entity Sets participate in a relationship.

Example
Alt Text

It is further divided into four types:
i) One-to-One:
Alt Text

ii) One-to-Many:
Alt Text

iii) Many-to-One:
Alt Text

iv) Many-to-Many:
Alt Text

3) Ternary - When three entity sets participate in a relationship.
Alt Text

4) n-ary - When more than three entity set involves in a relationship, it is called n-ary relationship.

Summary of ER-Diagram Symbols
1) Entity or Strong Entity:
Alt Text

2) Weak Entity:
Alt Text

3) Attribute:
Alt Text

4) Multi-valued Attribute:
Alt Text

5) Relationship:
Alt Text

6) Weak Relationship:
Alt Text

That's all for today.
Thank You.
Hope to see you in my next article...

Discussion (0)