Entity-Relationship Model: E-R Diagrams

Introduction and Basics

Entity-Relationship Diagrams is a visual tool which is helpful to represent the Entity-Relationship model. It was proposed by Dr. Peter Chen in 1971. It was designed to use E-R model as a conceptual designing approach. It is a collection of basic real-world objects called entities and relationship among entities. The basic reason of using E-R diagrams is that they are translatable into relational tables which allows you to build databases quickly.

The model is based on three basic components

  1. Entity
  2. Attributes
  3. Relationship

Each of these components are represented by different symbols in an E-R diagram.

Symbols used to represent different components

Entity and Entity Set

An entity is a thing or an object in the real world that is distinguishable from other objects based on the values of the attributes it possesses. For example, if we have three pens, all of them are of same brand, company, type and of same color. These pens will not be considered as entity because we cannot identify any one pen, or we cannot distinguish among all the pens. These pens in this case will be considered as objects but not entity. Moreover, whether to consider any object as an entity also depends on the observer. If the observer is able to identify any object in a group, it is considered as an entity.

Types of entities

Tangible or Concrete Entity: Entities which physically exists in real world. For example, pen, car, bank locker etc.

Intangible or Abstract Entity: Entities which exists logically. For example, Bank account.

Entity set is a collection or a set of same type of entities i.e. they share same properties or attributes. For example, persons having an account in a bank.

Representation of an entity and an entity set in an E-R diagram.

Interestingly, we cannot represent an entity in an E-R diagram. Entity set is represented by a rectangle in an E-R diagram. It is a table in a relational model. On the other hand, an entity can be represented by a row or a tuple in a relational model.

Entity and Entity set in a relation
Representation of an entity in an E-R Diagram

Attributes

Attributes are used to describe the characteristics of entities. For each attribute there is a set of permissible values called domains. In an E-R diagram, attribute is represented by an eclipse or an oval and in relational model, it is represented as a column. For example, every student will have its name, roll_no, age etc. which describes the student.

Types of attributes
  1. Simple attribute: Simple attributes cannot be further divided. For example, contact number of any person. It is an atomic value.
  2. Composite attribute: Composite attributes can be further divided. For example, person’s name can be further divided into first name, middle name and last name.
  3. Single-valued attribute: It can have only one value at a particular instant of time. For example, date of birth of a person
  4. Multi-valued attribute: It can possess more than one value at an instant of time. For example, a person may have multiple email address, multiple address.
  5. Stored attribute:  Some attributes have values which are stored in the database. Their value never changes with time. For example, Date of birth of a person.
  6. Derived attribute: There are some attributes in the database whose value is computed at run time using stored attribute. For example, age of a person is derived from his date of birth.
Types of attributes

Relationship and Relationship Set

It is an association between two or more entities of same or different entity set. There is no representation of relationship in an E-R diagram as it is an instance or data. In relational model, a relationship is represented with a row or a tuple.We can identify relationships with verbs or verb phrases. For example, Jack works in Computer Science Department.

Association between two different entity set
Association between different entities of different entity sets

We can also have a relationship between two entities of same entity set.

Relationship set is a set of similar type of relationship. In an E-R diagram, relationship set is represented using a diamond and in a relationship model, it is represented either by a table or a column(foreign key). Every relationship type has three components:

  1. Name
  2. Degree
  3. Cardinality Ratio/ Participation Constraint.

Leave a Reply

Your email address will not be published. Required fields are marked *