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 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.
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:
- Tangible Entity: tangible entities represent actual objects from the real world. For example, person, car, dog, etc.
- Intangible Entity: are those entities which exist only theoretically, logically or conceptually and have no physical existence. For example a loan, a subject, etc.
According to their category, there are two types of entities:
-
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.
-
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.
Example
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.
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.
- One-to-one (1:1): A record from entity A can only be linked to a record from entity B.
- 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.
- 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.
- 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.