ER Diagram in DBMS

An Entity Relationship model (ER model) shows the structure of a database with the help of a diagram, called as Entity Relationship Diagram or ER Diagram. An ER model is considered as a design or blueprint of a database that can be implemented later as a functioning database. The major components of E-R model are: entity, attribute, entity set and relationship set.

Entity Relationship Diagram or ER Diagram

An ER diagram shows the relationship among the entity sets.

An entity set is considered as a group of similar entities and these entities can have attributes. In terms of DBMS, an entity is a table or attribute of a table in database. An ER diagram shows the complete logical structure of the database.

Now let’s build an Entity relationship diagram for a student in a college or a university step by step by understanding all the components of the ER diagram.

Components of a ER Diagram

The main and basic components of a ER diagram are:

  1. Entity
  2. Attribute
  3. Relationship

Entity

An Entity can be an object with a physical existence – a person, bike, house, or an employee. It can also be an object with a conceptual existence – a company, a job, or a course in a college.

An entity is denoted by a Rectangle.

Entity Set

An entity set is a set of all the entities. For example, let S be an entity with entity type Student, then set of all students is known as Entity set.

Weak Entity

An entity that cannot be uniquely identified by its own attributes and depends on the relationship with other entity is known as a weak entity.

A weak entity is denoted by double Rectangle.

Attribute

An attribute is simply a property of the entity. For example, Name of a student is an attribute for the entity Student.

An attribute is denoted by an ellipse.

There are four types of attributes.

  1. Key Attribute
  2. Composite Attribute
  3. Multi valued Attribute
  4. Derived Attribute

Key Attribute

A key attribute uniquely identifies an entity in a entity set. For example, roll_no of a student uniquely identifies a student among all the students in a college, So roll_no of a student can be a key attribute for a entity set Student.

Key attributes are denoted by ellipses with an underline to the attribute.

Composite Attribute

An attribute from which other attributes can be derived is known as a composite attribute. For example, Address of a student has other attributes like door_no, Street, City, State. So address of a student can be considered as a composite attribute for entity set Student.

Composite attributes are also denoted by ellipses but have other attributes derived from them.

Multi valued Attribute

A multi valued attribute is an attribute that has more than one values. For example, a student can have more than one phone numbers. So, phone number of a student can be considered as a multi valued attribute for the entity set Student.

A multi valued attribute is denoted by double ellipses.

Derived Attribute

Derived attributes are the attributes that can be derived from other attributes. For example, age of a student can be derived from the date of birth of a student. Hence age can be considered as a derived attribute of the student entity set.

A derived attribute is denoted by a dotted ellipse.

Relationship

A relationship is considered as the relation between two or more entities. For example, “enrolled in” is the relationship between the entities student and course.

A relationship is denoted by diamond or rhombus shape.

Relationship set

Relationship set is a set of relationships of same type. For example, student A is enrolled in course Java, student B is enrolled in course DBMS, student C is enrolled in course C++. The following diagram represents relationship set.

Degree of Relationship

Degree of a relationship is the number of different entity sets participating in a relationship. There are different types of relationship sets.

  1. Unary
  2. Binary
  3. n-ary

Unary relationship

If only a single entity set is participating in a relationship then it is known as a unary relationship. For example, student A does friendship with student B.

Binary Relationship

If two entity sets are participating in a relationship then it is known as a binary relationship. For example a student is enrolled in a course.

N-ary Relationship

If more than two entity sets are participating in a relationship then it is called as n-ary relationship.

Cardinality

The number of entities of an entity set participating in a relationship is known as cardinality. There are different types of cardinalities.

  1. one to one
  2. many to one
  3. many to many

One to One

If only one entity of each entity set participates in a relationship then it is called one to one cardinality. For example, student A is enrolled in course A.

Many to One

If in a relationship, more than one entities of an entity set and only one entity of another entity set is participating in a relationship then it is called as many to one relationship. For example, Both students A&B are enrolled in course java and student C is enrolled in course DBMS.

Many to Many

If in a relationship, more than one entities of each entity set are participating then the relationship is known as many to many relationship. For example, student A is enrolled in courses java and DBMS and student B is enrolled in courses java and DBMS.

Also read: Data Models in DBMS

Leave a comment