Introduction to Entity-Relationship Model
Entity-Relationship Model is the diagrammatical representation of a database structure which is called an ER diagram. The ER diagram is considered a blueprint of a database which has mainly two components i.e. relationship set and entity set. The ER diagram is used to represent the relationship exists among the entity set. The entity set is considered as a group of entities of similar type which contains attributes.
According to the database system management system the entity is considered as a table and attributes are columns of a table. So the ER diagram shows the relationship among tables in the database. The entity is considered a real-world object which is stored physically in the database. The entities have attributes that help to uniquely identify the entity. The entity set can be considered as a collection of similar types of entities.
Why do we use Entity Diagram?
- The entity diagram is used to represent the database in the diagram form.
- It helps to properly understand the database.
- All the necessary details of the database can be represented in the form of the ER diagram.
- The entities represent all the tables of the database, attributes are the columns of tables and the relationship represented the association among the tables of a database.
Diagram of ER Model
Given below is the diagram of ER Model:
The above figure represents the ER diagram of the college student database. The student, college, mechanical, electronics and computer science are entities and the enrolls in and specialized in are the relationship. The attributes are name, age, gender, DOB, affiliation, address.
Components of Entity-Relationship Model
The ER model is used as a conceptual view of the database. The ER model consist of real-world entities and the related associations exist between them. The ER model gives the complete idea of a database used for any application and it is very easy to understand.
The below section contains information about the components of the ER diagram:
The entity is considered as a real-world object which can be anything like any object which can be identified easily. For example, in an employee database, employee details, location, contact details can be considered as entities of an employee database. All type of entities has some attributes or the properties which will help to give the proper idea of the entity. The entity set can be considered as a collection of similar types of entities. In the entity set, there can be some entities exist which can contain similar type of values. For example, the employee set will contain information from all employees. The entity set does not require to be disjoint.
- Weak entity: The weak entity is considered an entity that can’t be easily chosen by its attribute and which required some relationship with some other entity. This type of entity is known as a weak entity. In the ER diagram, the double rectangle is used for representing a weak entity. For example if there is only a bank account then it is considered as a weak entity as the bank account cannot be identified which bank the bank account belongs to.
The entities are represented using some properties and these properties are known as attributes. All the attributes have some value. For example the employee entity can have the following attributes employee name, employee age, employee contact details. For the attributes, there can be considered as a domain of values that can be allocated to the attribute. For example, the employee name cannot be assigned some numeric value. The employee name should always be alphabetic. The employee age cannot be in a negative number it should always be positive.
Types of attribute:
- Simple attribute: The simple attribute can be considered as atomic values that can’t be further segregated. For example, the employee phone number cannot be further segregate to some other attribute.
- Composite attribute: The composite attribute contains more than one attribute in the group. For example, the employee name attribute can be considered as a composite attribute as the employee name can be further segregated to a first name and last name.
- Derived attribute: The derived attribute is the type of attribute which does not exist in the database physically, however, the values derived are from the other database which is present in the database physically. For example, the average salary of an employee is derived attribute as it is directly not stored in the database. The value can e derived from other attributes present in the database physically.
- Single value attribute: The single attribute contains a single value. For example, the security number.
- Multi value attribute: The multi value attribute means the attribute which contains more than value. For example, the employee can have more than one email id and phone number.
The relationship is another type of component of the ER diagram which is used to show the dependency among the entities of the database. In the ER diagram, the relationship is represented by a diamond-shaped box. All the relationship which exist between the entities is connected by a line which shows in the ER diagram.
There are different types of relationship which are given below:
- One-to-one: In this relationship, the one entity is related to some other entity is a one-to-one relationship. For eg, an individual has a passport and the passport is allocated to one individual.
- Many-to-one: In this relationship, when many instances of an entity are linked to one entity. For eg, many students can read in one college.
- One-to-many: When one entity is linked to more than one entity is a one-to-many relationship. For eg, one customer placed multiple orders.
- Many-to-many: When many entities are linked to many entities is known as many-to-many relationships. For eg, students can have multiple projects and the project is allocated to multiple students.
As seen, the ER diagram is considered as a blueprint of the database it contains all the necessary details of the database. The entities are considered as tables of a database, attributes are considered as columns of tables, and tuples are considered as rows of tables. And in between entities there is some relationship that exists which makes a complete relational database.
This is a guide to Entity-Relationship Model. Here we discuss the introduction, why we use the entity diagram and components of the Entity-Relationship Model. You can also go through our other related articles to learn more–