ER Diagram Examples – Entity Relationship Diagram
Here we describe the ER Diagram Examples – The entity-relationship diagram and examples.
ER Diagram Examples
An entity-relationship model( ER space model ) describes the structure of a database with the help of a diagram which is known as the Entity-relationship diagram ( ER diagram ). An ER diagram shows the relationship between the entity sets. So that an ER diagram can express the overall logical structure of a database graphically. These are simple and clear.
Components of the ER Diagram
There are three main components for an ER diagram. They are:
An entity represented by a set of properties called attributes. Attributes are descriptive properties possessed by each member of an entity set. For each attribute, there is a set of, permitted values, called the domain, or value set, of that attribute.
There are several types of attributes that occur in the ER diagram. These are:
- Simple and Composite attributes: Attributes that are not divisible are called simple or atomic attributes. Composite attributes can be divided into smaller subparts, which represent more basic attributes with independent meanings. Composite attributes can form a hierarchy. Composite attributes are attached to their component attributes by straight lines.
- Single-valued and Multi-valued attributes: Most attributes have a single value for a particular entity. Such attributes are called single-valued attributes. In some cases, an attribute can have a set of values for the same entity. Such attributes are called multi-valued attributes. In an E-R diagram, multi-valued attributes are displayed in double ovals.
- Derived attributes: Derived attributes are the attributes whose values can be derived from the values of the other related attributes or entities. In an E-R diagram, derived attributes are displayed in dashed ovals.
A relation is an association between two or more entities. A relationship may also have a set of attributes called descriptive attributes. A relationship set is a set of relationships of the same types.
There are four types of relationships:
- one to one relationship: when a single instance of an entity is associated with a single instance of another entity, then it is called one to one relationship.
- one to many relationships: when a single instance of an entity is associated with more than one instance of another entity, then it is called one to many relationships.
- many to one relationship: when more than one instance of an entity is associated with a single instance of another entity, then it is called many to one relationship.
- many to many relationships: when more than one instance of an entity is associated with more than one instance of another entity, then it is called many to many relationships.
Here are the geometrical shapes and their meaning in the ER diagram:
- Rectangle: entity sets
- Ellipsis (oval): attributes
- Diamonds: relationship sets
- Lines: they link attributes to entity sets and entities set to relationship sets
- Double ellipsis: multivalued attributes
- Dashed ellipsis: derived attributes
- Double rectangle: weak entity sets
- Double lines: total participation of an entity in a relationship sets
Entity Relationship Diagram – Examples
Here are the ER Diagram Examples with figures and their descriptions.
ER Diagram Example – 1
This ER diagram shows the relationship named Study In between two entities, Student and College. This is a many to many relationship. Student entity has three attributes, Stud_id, Stud name, Stud addr, which are represents its corresponding properties of Studen entity.
Similarly, College entity has Col_id for college id and Col name for the name of the college. Stud_id is the key attribute of Student entity and Col_id is the key attribute of College entity.
ER Diagram Example – 2
In this ER diagram, Products, trainers are the strong entities and the Parts entity is a weak entity. Because Parts entity depends on Products entity on a relationship of Belongs to for its existence.
And also parts entity related with trainer entity through a relationship named maintained by part_id and part name are two attributes of parts entity and its key attributes are part_id. Part_id and part name are the attributes of the products entity and its key attribute is part-id.
Similarly, trainer_id and trainer name are the attributes of a trainer and its key attribute is trainer_id.
ER Diagram Example – 3
In this ER diagram example, some important types of attributes are specified. Reads are the relationship between two entities namely student and book.
The student entity has a key attribute of stud_id, a composite attribute of stud_name with the components such as first name, middle name, and last name., multivalued attribute f phone and derived attribute of age with its base attribute of DOB.
Similarly, the book entity has a key attribute of book_id, a multivalued attribute of authors, and other two attributes such as book_name and price.
ER Diagram Example – 4
This relationship has two roles such as employee and manager with the employee entity. And also employee entity holds the attribute such as role, salary, emp_id, and emp_name with the key attribute of emp_id.
ER Diagram Example – 5
In this example of the ER diagram, the employee entity has three attributes of emp_name, emp_no, and salary with key attributes of emp_no. The Department entity has two attributes of dept_name and dept_id with key attributes of dept_id.
Work_in is the relationship between these two entities with its descriptive attribute, called since.