Entity Relationship Model (ERM)

The Entity Relationship Model also known as Entity Relationship Diagram (ERD), is a type of diagram for data modeling, which graphically illustrates the interrelationships of the entities of a database system. Said model, was proposed by the American-Taiwanese theoretical computer scientist, Peter Pin-Shan Chen in 1976.

Among the main functions and objectives of the use of the Entity-Relationship Model, the graphic design and debugging of relational databases stand out. Generally, the Entity Relationship Model is the step prior to the final implementation of a database, where the requirements and business processes are determined first to subsequently model and graphically design the structure of the system to be implemented.

The use of the EntityRelationship Model facilitates the final implementation of a database, since we will have a structured and modifiable diagram where we can visualize the system as a whole, before its final implementation.

The Entity Relationship Model is also very useful for detecting and solving problems and deficiencies in databases that have already been implemented, because on many occasions, as the diagram is generated, previous design and logic errors are revealed.

Using the Entity Relationship Model in the initial design phase of a database is highly recommended , as it will facilitate the database implementation and help us to detect errors from the initial stage, reducing the probability of future corrections, which in many cases can become overly complicated with an already implemented system.

Entity Relationship Model elements

There are three basic elements we must understand to apply them correctly in the Entity Relationship Model:

Entity

Graphic representation of a concrete or abstract object that is distinguishable from the rest. They constitute the basic foundation of the Entity Relationship Model and are usually represented graphically through a rectangle with the name of the entity inside it, which will generally be a noun. Entities may have stored data that facilitates their definition and represents their characteristics. These data are known as attributes.

Based on their nature, there are two main types of entities:

  1. Tangible Entity: tangible entities represent actual objects from the real world. For example, person, car, dog, etc.

Tangible Entity

  1. Intangible Entity: are those entities which exist only theoretically, logically or conceptually and have no physical existence. For example a loan, a subject, etc.

Intangible Entity

According to their category, there are two types of entities:

  1. Strong Entity Type: also known as regular entities, are those entities wich are complete by themselves, and are not dependent on any other entity type.

  2. Weak Entity Type: they are entities that can’t be identified on its own. They need some other entity for its distinct identity. This type of entity is represented by a double outlined rectangle.

Weak Entity

Let’s suppose that in a high school we have two related entities: building and classroom. In this case building would be a strong entity definable through its own attributes while classroom would be a weak entity, since it depends on the existence and relationship with the entity building in order to be defined. The classroom exists within the building

Example icon

Attributes

Attributes are describing characteristics or properties that define an entity. An entity can have several attributes that are represented by a circle or oval with the name of the attribute inside, which most times will be an adjective. Among the attributes of an entity we have the key attribute or primary attribute, which is the one that allows us to unequivocally differentiate one instance of the entity from a different one. We can recognize this attribute because its identifying name is underlined.

Attributes

Relationship

A relationship represents a bond of dependency or association between entities. It is graphically represented as a diamond with a name inside it, which will usually be a verb.

We can not understand relationship without the concept of cardinality that establishes and defines the type of relationship between the entities. It can be represented in several ways, the simplest being to graphically represent a line joining the entities through the relationship, showing the cardinality at each end. Having said that, there are four types of cardinality:

To better understand the relationships and their cardinality, in addition to the subsequent graphical examples we will consider the entity on the left as entity A and the one on the right as entity B.

  1. One-to-one (1:1): A record from entity A can only be linked to a record from entity B.

cardinality 1:1

A flag belongs to a country and each country has a flag

  1. One-to-many (1: N): A record from entity A is related to one or many records from entity B, but a record from entity B is only related to one record from entity A.

cardinality 1:N

One customer may make several purchases but each purchase is made by a single customer.

  1. Many-to-one (N:1) :A record from entity A can only be related to one record from entity B, but a record from entity B can be related to one or many records from entity A.

cardinality N:1

One department employs many employees but many employees work in one department.

  1. Many-to-many (N:M): A record from entity A can be related to one or many from entity B and a record from entity B can be related to one or more from entity A.

cardinality N:M

A student can enroll in one or more courses and one or more students can be enrolled in each course.