Home/Tutorials/Database Management Systems/Basic Concepts of ER Model

0 of 2 saved

Database Management Systems6 min read

Basic Concepts of ER Model

Read this chapter, then pass a short check to open the next one.

ER Model or Entity-relationship model is a database model based on entity, attributes and relationships between entities. In this tutorial, we will cover the basic concepts about the ER Model to explain how it is useful.

Introduction to ER Model

The Entity-Relationship Model is a model used for the design and logical representation of relationships between data. This is a high-level conceptual data model and was developed by Peter Chen in 1976. It is the visual representation of data that describes how data is related to each other with symbols and text. It helps to identify entities and relationships and allows us to draw database design.

The main data objects are termed as Entities, with their details defined as Attributes. Some of these attributes are important and are used to identify the entity, and different entities are related to using relationships.

ER Diagram

ER Diagram is a visual representation of data that describes how data is related to each other. In the ER Model, we disintegrate data into entities, attributes and set up relationships between entities. All this can be represented visually using the ER diagram.

Components of the ER Diagram

In order to understand the ER Model, we must know about the below terms.

Components of the ER Diagram

1. Entity

An Entity is generally a real-world object which has characteristics and holds relationships in a DBMS. An entity contains attributes that describe that entity. Let's take an example of a School Management Software, where we will store student details, teacher details, classes, subjects, etc. In this example, a student is an entity, a teacher is an entity, similarly, class, subject, etc are also entities.

What is an Entity Set?

Entity Set is the collection of similar types of entities that share the same attributes. If a student is an entity, then the complete dataset of all the students will be the Entity Set.

Types of Entity

We have two types of entities:

1. Strong Entity: An entity set having attributes, which can be used as a candidate key or primary key is called a strong entity set. It is independent of any other entity in the schema. In the case of student details, the student itself is a strong entity. It is denoted by a rectangle.

strong-entity

2. Weak Entity: A weak entity set means it does not have any required or sufficient attributes to form the Primary Key. It is dependent on the Strong Entity. It is denoted by a double rectangle.

weak-entity

2. Attributes

Attributes are the characteristics or properties of an entity. In the Entity-Relationship diagram, the attributes are directly connected to the entity. For example, if a student is an entity, then student's roll no., student's name, student's age, student's gender, etc will be its attributes.

Types of Attributes

An attribute can be of many types, here are different types of attributes defined in the ER database model:

1. Key Attributes: An attribute that is used to uniquely identify each instance or row of an entity type. It represents a primary key. The key attribute is represented by an ellipse with the text underlined. For Example, student roll number. The below representation shows roll no as a key attribute while others are Simple Attributes.

key attribute

2. Composite Attributes: A Composite Attribute is an attribute that is made up of more than one simple attribute. It can be subdivided into other attributes. For Example, A student's address will contain house no., street name, city, state, etc.

Composite Attribute

ย 

3. Multivalued Attributes: Multi-valued attributes can have multiple values. The double oval is used to represent a Multivalued Attribute. For Example, a student can have more than one phone number.

Multivalued Attribute

4. Derived Attributes: Derived attributes are the attributes that are not present in the whole database management system but are derived using other attributes while the attributes that are physically stored in the database are known as Stored Attributes. It can be represented by a dashed ellipse. For Example, The average age of students in a class because is calculated with the help of the date of birth.

ย 

3. Relationships

When an Entity is related to another Entity, they are said to have a relationship. For example, A Class Entity is related to a Student Entity, because students study in classes, hence this is a relationship. Depending upon the number of entities involved, a degree is assigned to relationships. If 2 entities are involved, it is said to be a Binary Relationship, if 3 entities are involved, it is said to be a Ternary relationship, and so on.

Binary Relationship

It is a relationship set where two different entity sets participate in a relationship set. There are three types of Binary Relationships that are called Cardinalities.

1. One-to-One: This type of relationship is rarely seen in the real world. The below figure describes that one student can enroll only for one course and a course will also have only one student. This is not what you will usually see in real-world relationships.

2. One-to-Many: The below diagram showcases this relationship, which means that 1 student can opt for many courses, but a course can only have 1 student.

3. Many-to-Many: The below diagram represents that 1 student can enroll for more than 1 course and a course can have more than 1 student enrolled in it.

4. Many-to-One: It reflects the business rule that many entities can be associated with just one entity. For example, a Student enrolls for only one Course but a Course can have many Students.

one-to-many example

Ternary Relationship

The relationship of degree three is called the Ternary Relationship. A Ternary Relationship involves three entities. In such relationships, we always consider two entities together and then look upon the third to form a relationship set.

For example, in the diagram below, we have three related entities, Company, Product and Sector. To understand the relationship better or to define rules around the model, we should relate two entities and then derive the third one. A Company produces many Products/ each product is produced by exactly one company. A Company operates in only one Sector / each sector has many companies operating in it. Considering the above two rules or relationships, we see that although the complete relationship involves three entities, we are looking at two entities at a time.

Recursive Relationship

When an Entity is related to itself it is known as a Recursive Relationship.

Conclusion

In this article, we discussed the overview of the ER model from the entities, attributes, keys, and relationships, these properties help to create the ER diagram. In the next tutorial, we will learn how to design databases using ER diagrams.