Entity-Relationship model is a conceptual model by which you can conceive the structure of the database, maintain the relationship between different components, and identify the constraints that occur in the integrated design of the database system. The entity-relationship model or the E-R model describes data as entities, attributes and relationships.
History of ER Models
The Entity Relationship (ER) Diagram was introduced by Peter Chen in 1976 as a method to model data systematically in database systems. Chen proposed the ER Diagram in DBMS to represent the logical structure of databases, providing a visual means to define entities, their attributes, and relationships. Over time, ER models became an essential tool in database design, evolving with variations like extended ER models to include more complex database requirements.
Uses of Entity Relationship Diagram
Database Design: Helps in creating a clear structure of the database by identifying entities, their attributes, and relationships.
Data Organization: Ensures data is properly organized and easy to manage.
Requirement Analysis: Captures business needs and translates them into a database model.
Communication Tool: Provides a simple way to communicate database design to developers and stakeholders.
System Documentation: Acts as a reference for maintaining and upgrading the database system.
Components of Entity Relationship Diagram - ER Diagram
There are three main components:
Entity
Attributes
Relationship
Entity
Entity is a real-world object with an independent existence; it is a thing or an object with its own identity. It can be an object with a physical existence like a house, person, an employee, etc., or it can be objects with a conceptual existence like course, course, job, etc.
Graphical depiction of an Entity-Relationship model:
Attributes
An attribute is a specific part of an entity structure. It is a mapping from an entity set to its domain value. Attributes are properties that describe the entities.
For example, If we have a person as an entity, the properties that would describe this particular entity would be name, age, address, phone number, etc. So, these are called attributes of this entity.
Let's look into the several types of attributes in the E-R model; first let us see what composite attributes and simple attributes are:
Composite attributes
Simple attributes
Composite attributes are attributes that can be divided into further parts.
Simple attributes are attributes that cannot be divided further.
An example of a composite attribute name can be divided into further parts: first name, middle name, and last name.
An example of a simple attribute is weight. This attribute cannot be further divided, and other examples could be the salary of a person, age, etc.
Next, we have the single-valued and multi-valued attributes.
Single-valued attributes
Multi-valued attributes
Single-valued attributes are attributes that have a single value or just one value for a particular entity.
Multi-valued attributes are attributes that can have a set of values for a particular entity.
An example of a single-valued attribute is age. A particular person can have only a single value for this particular attribute, so age is a single-valued attribute of a person.
Examples of multi-valued attributes are a college degree, languages known, etc.
A particular person can have more than one college degree and can also know more than one language. Since these attributes can have a set of
values for a particular entity, it is called a person's multi-valued attribute.
Derived-attributes are attributes that can be derived from other attributes, whereas Store-attributes are attributes from which the value of other attributes are derived.
An example of a derived attribute is an age since age can be derived from the date of birth. Whereas date of birth or birth date of a person is a stored attribute because, from this attribute, we can derive the age of a person, so this is a stored attribute from which the value of other attributes is derived.
Complex Attributes
• Has multivalued & composite components in it.
• Multivalued attributes → represented within { }. '
• Composite attributes → represented within * ( ).
• Ex : {College Degrees(College, Year, Degree, Field)}
Key Attribute
A key attribute of a particular entity type is that attribute that is capable of identifying each entity uniquely. For Example, Student_Id of a student.
STUDENT_ID
NAME
AGE
1
PRIYANKA
20
2
JEREMY
21
3
PRIYANKA
20
In this table, two students are having the same name and the same age. Now, if I have to identify any particular student then I will be using Student_Id because no two students can share the same Student_Id in a particular class.
So, the attribute Student_Id is a key attribute to uniquely identify a student.
Relationship
It is defined as an association among several entities.
A relationship is an association or a connection, or a link among two or more entities.
For example- "The teacher teaches students" here, we have two entities or objects; one is the teacher, and the other is the student, and teaching is a relationship between these two entities or objects; this relationship connects or links these two entities.
Degree of relationship
Degree of relationship denotes the number of entity types that participate in a relationship that is, it tells how many entities are associated or linked together.
I. The relationship type of degree 1 is called a unary relationship. A unary relationship exists when there is an association with only one entity.
II. The relationship type of degree 2 is called Binary relationship. A binary relationship exists when there is an association between two entities.
III. The relationship type of degree 3 is called the Ternary relationship. A ternary relationship exists when there is an association among three entities.
Mapping Cardinalities
It expresses the total number of entities to which other entities can be associated via a relationship set.
Most useful in describing binary relationship sets.
For a binary-relationship set, the mapping cardinality must be among one of the following types:
Many to one
Many to many
One to one
One to many
Many to One
An entity in A is associated with "at-most" one entity in B. However, an entity in B can be associated with any number (Zero of More) of entities in A.
Many to Many
An entity in A is associated with any number (zero or more) of entities in B. However, an entity in B is associated with any number (zero or more) of entities in A.
One to One
An entity in A is associated with "at-most" one entity in B. However, an entity in B is associated with at most one entity in A.
One to many
An entity in A is associated with any (Zero-More) of entities in B. However, an entity in B can be associated with at most one entity in A.
Attributes of Relationship Types
Attributes of the 1: N or 1: 1, relationship types can be migrated to one of the participating entity types.
→ In 1: 1 relationship type, attributes can be migrated to either of the entity types.
→ In 1: N or N: 1 relationship type, attributes are migrated only to the entity type on the N-side of the relationship.
FAQs
What are the three entity-relationship models? Entity Relationship Diagram Symbols & Notations mainly contains three basic symbols: rectangle, oval, and diamond, to represent relationships between elements, entities, and attributes.
What is a Degree? The degree Number of entities participating in a relationship is known as a degree.
What is physical data independence? Physical data independence is the ability to modify the physical schema without changing the logical schema.
What is participation in a relationship? Minimum number of times an entity can participate in a relationship. → Whenever the participation is non-zero, this is called total participation. → If the participation is non-zero, this is called as partial participation.
Key takeaways
In this blog, we have discussed Entity-Relationship Diagrams with their components like entity, attributes, and relationships in detail. Along with a few more important terminologies about the Entity-Relationship model.
We hope that this blog has helped you enhance your knowledge regarding E-R Diagrams in Software Engineering and if you would like to learn more, check out our articles on link. Do upvote our blog to help other ninjas grow.