ER Model in DBMS

ER Model in DBMS

Β·

4 min read

Introduction

  • An Entity-relationship model (ER model) describes the structure of a database with the help of a diagram, which is known as Entity Relationship Diagram (ER Diagram). The data which we ought to store can be done by presenting the ER model. ER Diagrams contain different symbols that use rectangles to represent entities, ovals to define attributes and diamond shapes to represent relationships

  • An ER model is a design or blueprint of a database that can later be implemented as a database The building blocks of ER model are:

    1. Entity
    2. Attribute
    3. Relationship

1.png

Entity

It is anything in the enterprise that is to be represented in our database. It may be a physical thing or simply a fact about the enterprise or an event that happens in the real world. An entity can be a place, person, object, event, or concept, that stores data in the database. It is an object that exists in real world and is distinguishable from other objects by having its own set of properties. For example,

Student {
Reg no;
Name;
Course;
 }

The values of property is an entity of 'student'

An entity that cannot be uniquely identified by its own attributes and relies on the relationship with other entity is called weak entity. The weak entity is represented by a double rectangle.

Entity Set

An entity set is a group of similar kind of entities. It may contain entities with attribute sharing similar values. Entities are represented by their properties, which also called attributes. All attributes have their separate values

Attributes

An entity is represented by a set of attributes which are descriptive properties possessed by all the members of an entity set. These single-valued properties of either an entity-type or a relationship type are called attributes.

An attribute in ER Diagram examples is represented by an Ellipse

Following are the types of attributes:

2.png

Relationship Sets

We have this model which represents the relationship between superiors and employees.

3.png

'Relationship' is nothing but an association among two or more entities. E.g., Tom works in the Chemistry department.

Ex:

(6969,Michael) superior (5324,Ryan)

  • Collection of such relationship are relationship sets, as shown in the picture above.

Every instance is an entity set is distinguishable from other entities using primary key Primary key of relationship will be in our example:

(6969,5342) ∈ superior

Association between entity set is referred as participation.

Relationship Instance is an ER schema that represents an association between named entities

Descriptive Attributes:

A relationship may also have attributes that show association with both the entity set. Suppose now we want to store the information about the date when a superior was allotted.

4.png

Relationship Sets with Attributes:

5.png

ER Diagrams

Following is the diagrammatic representation of Relationships in ER models:

6.png

Recursive Relationship Set

If the same entity sets participate in relationship set more than once in different roles are known as recursive relationship sets. This means that the relationship is between different instances of the same entity type

7.png

Role Name is not required to be specified in a non recursive relationship.

8.png

9.png

Degree of a Relationship

In DBMS, a degree of relationship represents the number of entity types that associate in a relationship. For example, we have two entities, one is a student and the other is a bag and they are connected with the primary key and foreign key. So, here we can see that the degree of relationship is 2 as 2 entities are associated in a relationship.

In other words, we can define 'degree' as the number of participating entities sets in a relationship

10.png

Mapping Cardinality Constraints

In terms of data models, cardinality refers to the relationship between two tables. By mapping them, we express the number of entities to which another entity can be associated via a relationship set

For usually binary relationships, there are four types of cardinality ratios:

11.png

1. One to one Mapping (1:1):

In one-to-one mapping, an entity in E1 is associated with at most one entity in E2, and an entity in E2 is associated with at most one entity in E1.

2. One-to-many

In one-to-many mapping, an entity in E1 is associated with any number of entities in E2, and an entity in E2 is associated with at most one entity in E1.

3. Many-to-One

In many to one mapping, an entity in E1 is associated with at most one entity in E2, and an entity in E2 is associated with any number of entities in E1.

4. Many-to-Many

In many-to-many mapping, an entity in E1 is associated with any number of entities in E2, and an entity in E2 is associated with any number of entities in E1.


Thank you for reading the blog.πŸ™ŒπŸ»πŸ“ƒ

πŸ”° Keep Learning !! Keep Sharing !! πŸ”° More blogs are on the way!! πŸš€ Feel free to connect with me :

Keep Growing and don't forget to have fun :) 🍻

Β