Entity relationship diagram is the graphical representation associated with the entity relationship model. ER diagram helps in representing the logical structure of the overall database. It represents the relationship between the entity sets stored in the database. The ER diagram illustrate the concepts in a way that is easy for many users to understand how the information system will produce the information.
Content: Entity Relationship Diagram
- What is ER Diagram?
- Uses of ER Diagram
- Components of ER Diagram
- Symbols and Notations
- Mapping Cardinality
- ER Diagram Example
What is ER Diagram?
ER diagram is designed on the concept of ER model. It provides a graphical representation of entities, attributes and relationships. The ER diagram helps many users even non-technical users to understand the logical structure of the overall database.
Uses of Entity Relationship Diagram
ER Diagram in DBMS
- The primary use of ER diagrams is to design a database by graphically defining the components of entity relationship model.
- ER diagram helps you in identifying the entities, attributes associated with them and the relationship between those entities that are required to design a particular database.
- ER diagram also helps you in debugging if there is any flaw or error in the logical structure of the database or if there occurs an error in its deployment.
ER Diagram in Software Engineering
In software engineering, the ER diagram is used at the initial stages of the planning of software. It helps in identifying the requirements of the information system, the system elements involved and the relationship among them. The ER diagram can also be referred to create a data flow diagram i.e. DFD that explains the workflow of a software.
Components of ER Diagram
The three main components of every ER diagram are entities, attributes and relations. These are the building blocks of the ER diagram. Let us talk about each of them:
1. Entity
An entity can be described as an object existing in the real world and can be distinguished uniquely from the other objects of the real world. Each entity has a set of properties or attributes for which it has a set of values.
The values of the attributes define the characteristics of that entity that helps in identifying the object uniquely. The entities sharing the same set of attributes are collectively stored in the same entity set.
The entity set can be further classified into two types:
- Strong Entity Set: The entity set that is defined by using its own set of attributes can be referred to as a strong entity set.
- Weak Entity Set: The entity set that cannot be defined by using its own set of attributes that’s why it’s always associated with another entity set which we refer as an identifier entity set or the owner entity set.
2. Attribute
Each entity set in the database is defined with some set of attributes that describes the characteristics of each entity of that entity set. The attributes can be further classified into:
- Simple and Composite Attributes
Simple attributes cannot be further classified such as the id attribute of a student entity set cannot be further divided into subparts. However, the composite attribute can be classified into sub-parts such as the name attribute can be divided into first_name and last_name. - Single-valued and Multivalued Attributes
A single-valued attribute accepts a single value such as the id attribute of a student entity set will accept only one integer value. The multivalued attribute can accept multiple values such as the phone_number attribute of a student can have multiple values as a student may have zero, one or many phone numbers. - Derived Attributes
The derived attribute is the attribute whose attribute value can be derived or computed using another attribute’s value. For example, using the date_of_birth attribute of the student entity set we can compute the value for the age attribute. Although the value of the derived attribute is not stored in the database as it is computed whenever required.
3. Relationship
Relationship describes the link between the entities to be modelled. For example, the relation between the instructor and course entity is ‘teaches’ i.e. the instructor teaches a particular course.
Symbols and Notations
As in the ER diagram we have to represent each component of Er model graphically so there must be some symbols or notation to represent each component. The table below displays some symbols to represent the components of the ER model.
- Rectangles illustrate the entity set.
- Diamond illustrates the relationship between the entity set.
- Ellipse illustrates the attributes of an entity set.
- Lines illustrate the association of attributes to the entity set and the association of entity set to the relationship set.
Mapping Cardinality
Mapping cardinality or the cardinality ratio indicates the number of entities of an entity set associated with entities of another entity set by means of a relationship. Consider that we have two participating entity sets A and B then the relationship between the two entity sets can be
- One-to-one relationship between two entity sets expresses that one entity from entity set A must be associated to at most one entity of entity set B and vice versa.
- One-to-many relationship expresses that one entity from entity set A can be associated with many entities of entity set B and one entity of entity set B can be associated to at most one entity of entity set A.
- Many-to-one relationship expresses that one entity from entity set A is associated with one entity of entity set b. But one entity from entity set B may be associated with many entities of the entity set A.
- Many-to-many relationship express that one entity from entity set A can be associated with many entities of entity set B. One entity of entity set B can be associated with many entities of entity set A.
Entity Relationship Diagram Example
Now learning about the building blocks or components of ER diagram let us draw an ER diagram. Before you initiate drawing the ER diagram you must focus on some basics.
- Define the motive and purview of what you are going to model.
- Recognize the entity sets that must be considered to model certain databases or information systems. As soon as you identify an entity label it as a noun.
- Once you identify the entities involved try to identify the relationship among those entities and label them as verbs.
- Next, identify the attributes which will be describing the characteristics of the entities of the entity set.
- Map the cardinality between the entities and complete the ER diagram.
Now consider a scenario of a bank where a customer comes to withdraw or deposit some amount or to take a loan. So here spontaneously we figure out two basic entity sets involved in the system are the customer and the bank. However, the relationship between the entities customer and bank could be withdrawal, deposit, loan.
The attributes that can describe more about the entity set bank are bank_name, address, branch, affiliation_no. The attributes of the entity set customer are customer_name, account_number, address. The figure below shows you the basic ER diagram of a bank transaction system.
So, this is how you can produce an ER diagram. We have learned about the basic components of an ER diagram, we have learned to associate these components with each other to form an ER diagram. We have also studied how these ER diagrams are useful for producing a database.
Leave a Reply