Introduction to ER-Diagram Model

Reading Time: 5 minutes

As we know that a database can be modeled as a collection of entities and relationships among entities.

ER Diagram stands for entity relationship diagram which helps us to explain the logical structure of databases.

An ER diagram looks like the flow chart but it consists of many more specializations like symbols and meaning of those symbols etc, which makes this model very unique.

In simple words, Entity Relationship Diagram(ERD) is a Graphical representation of the database structure.

The ER Diagram is also alternately known as Er models.

ER diagrams are created based on three basic concepts: entities, attributes, and relationships.

Components of ER-Diagram

Entity

An entity is an object that exists and is distinguishable from other objects. Entities are usually expressed by nouns

For Example:

Specific person, company, event, plant, etc.

An entity set is a set of entities of the same type that share the same properties. Every entity is made up of some ‘attributes’ which represent that entity.

Example:

Set of persons, companies, trees, loansGroup pf person.

Strong Entity:

An entity is said to be a strong entity when it has a key attribute that can uniquely identify each instance of an entity.

The Strong Entity is not dependent upon any other entity for its existence in the database schema rather it has its own prime attribute. Strong Entity represented by a single rectangle.

For Example:

Student_Id of student
Emp_Id of employee

Weak Entity:

An entity does not have a primary key attribute and depends on another strong entity via a foreign key attribute. Weak Entity represented by a double rectangle.

For Example:

A Room can only exist in a building.

Attributes

An attribute describes the property of an entity. Attributes represented as Oval in an ER diagram. There are four types of attributes:

1. Key attribute
2. Composite attribute
3. Multivalued attribute
4. Derived attribute

For Example:

Student = Student_id,Student_Name,Student_email

Course = Course_name,Course_id

Key Attributes:

The key attribute is also known as the prime attribute or primary key. A key attribute can uniquely identify an entity from an entity set.

Key attribute represented by oval same as other attributes however the text of key attribute is underlined.

The given diagram shows that student id is a key attribute.

Composite Attribute

An attribute that is a combination of other attributes is known as a composite attribute.

It is possible to break down composite attributes.

For example,

 In a student entity, the student name is a composite attribute.

Student name divided into three parts i.e. first name, middle name, and last name.

Multivalued Attribute

As the name suggested this attribute has more than one single value.

It is represented with double ovals in an ER Diagram.

For example

A student can have more than one phone number so the phone number attribute is multivalued.

Derived Attribute

Derived attributes are attributes whose value can be calculated from related attribute values and represented by a dashed oval in an ER Diagram.

The value of the derived attribute is not stored into the database since its values keep on changing and depend upon another attribute.

For example

Student age is a derived attribute as it changes over time and can be derived from another attribute (Date of birth).

Relationship

Relationships are associations between or among entities. Relationships are often expressed by verb phrases.

In ER-Diagram,

The relationship between the two entities is indicated by a diamond shape connected to the entities by a straight line.

There are four types of relationship:

  1. One to One.
  2. One to Many.
  3. Many to One.
  4. Many to Many.

One to One Relationship

When only one instance of an entity is associated with the relationship, then it is known as one to one relationship

For example, in a college database, each student has only one student ID, and each student ID is assigned to only one person.

One to Many Relationship

When one instance of entity of A can be associated with more than one instance of entity B known as the one to many relationships.

For example,

A student can study only in one department. But many students can study in one department.

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 a many to one relationship.

For example

Many students can study in a single college but a student cannot study in many colleges at the same time.

Many to Many Relationship

In many to many relationship many instance of entity A is associated with given instance of entity B. Similarly, many instance of entity B can be associated with a given instance of entity A.

For example

A student can be assigned to many projects and a project can be assigned to many students.

Conclusion

ER modeling helps you to analyze data requirements systematically to produce a well-designed database. It’s considered best practice to complete ER modeling before implementing your database.


Written by 

Pratibha Yadav is a Software consultant at Knoldus and started her beautiful journey of a career in an environment where she able to sharp - up her skills day by day by learning and earning new opportunities. She completed her Post-graduation from Sharda University, Greater Noida. She is passionate about her work and has knowledge of various programming languages. She is recognized as a quick learner, problem solver, public speaker, dedicated and responsible professional employee. Her hobbies are Writing, Reading, and spending some time with nature.

1 thought on “Introduction to ER-Diagram Model7 min read

Comments are closed.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading