In this tutorial, We will study about the ER diagram, components of the ER diagram - entity, attributes, relationships, keys, and cardinality. So let us start.
ER diagram also known as the ER model is used for representing the data logically. It fulfills the requirement of the conceptual design of the database. It is used to represent relationships between different entity sets. The ER diagram looks more like a flowchart. But, ER Diagram contains many specialized symbols and the meanings of the symbols make this model unique. ER-diagrams have meanings that should be thoroughly understood so that we can create correct diagrams.
☆ An entity is an object, a component of data.
☆ An entity set is a collection of similar or like entities. For example, the set of rectangles.
☆ These entities have attributes that are used to define its properties.
☆ By defining the entities and their attributes a relationship is shown between them.
☆ An entity can be seen as an object with physical existence. For example- car, house, city, a person, an employee, etc. Anything that has attributes is an entity.
☆ The entity is represented by a rectangle in the entity-relationship model.
☆ Entities are of two types- strong entity and weak entity.
☆ A strong entity can be uniquely identified by its own attributes. It always has a primary key. It is represented by a rectangle symbol.
☆ But a weak entity is an entity that needs to be defined by a foreign key relationship with a strong entity as it cannot be uniquely identified based upon its own attributes alone. It is represented by a double rectangle symbol.
☆ These are used to describe the entity.
☆ All the entities that are in the set have the same attributes.
☆ An attribute contains a single piece of information not a list of data.
☆ The minimal set of attributes that are needed to uniquely identify an entity is called a key.
There are four types of attributes.
Those attributes that can not be divided any further. Example: mobile phone number.
Those attributes can be further divided. Example: name of a person, it can be divided into first name, middle name, and last name.
Those attributes that are derived from other attributes. Example: experience can be derived from the date of joining.
Those attributes can have multiple values. Example: a person can have multiple mobile numbers and email ids.
In this figure student and course are the entities and studies is the relationship between the entities and attributes are name, roll no., class, course name and course no.
☆ It is a bridge between two or more entities.
☆ Relationship set: The set of similar relationships.
☆ Recursive relationship: when an entity set participates more than once in a relationship.
☆ The entities in a relationship set must be able to identify the relationship.
☆ Attributes can not be used for identification.
It is used to define the maximum number of relationships one entity can have with others. There are different types of cardinality like:
One entity from A is associated with more than one entity from B and one entity from B is associated with more than one entity from A.
For example, Class as a group of students is associated with many faculty members, and many faculty members are associated with the class.
One entity from any entity set can be associated with another entity set B by at most on relation and vice versa.
For example, one employee can work only for one department and each department will have at most one employee.
One entity from entity set A might be associated with multiple entities of the entity set B, but an entity from the entity set B can be associated with at most one entity.
For example, one department might consist of multiple employees.
One entity from the entity set B can be associated with multiple entities of the entity set A but every entity from the entity set A will be associated with one or more than one entity from the entity set B.
For example, many employees might belong to one department.
The total number of various entity sets that are participating in a relationship set is called the degree of a relationship set.
When only one entity set is participating in relation. For example, a person can only marry a person.
When there are two entities that are participating in the relationship. For example, one student can go to only one school.
When there is n number of entities set that are participating in a relation.
Participation Constraint is applied to the entity or entities participating in the relationship set.
Each and every entity in the entity set must participate in the relationship. Total participation is represented by a double line. For example, every student is opting for a course therefore there is total participation from students.
Each and every entity in the relationship set need not participate in the relationship. Partial participation is shown by a single line. For example, every student might not be participating in every game.
ER- Diagram is the representation of data that describes how data is related to each other and defines the relationship between them.
This symbol is used to represent the entity.
This Symbol is used to represent attributes.
This symbol represents the relationship types.
It helps in linking the attributes to entity types and entity types with other relationship types.
These attributes are underlined.
Used to represent multi-valued attributes.