• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
May 30, 2022 |25.3K Views

Converting an ER Diagram to a Relational Table | DBMS

Description
Discussion

In this video, we will be studying how we can convert an ER Diagram to Relational Table.
If two entities are related to each other using many one relationships, one to many relationships, one to one relationships, or many to many relationships. To convert these entity relationships into the relational table so that data can be stored in the database efficiently.

ER diagrams cannot be stored in the database directly to store data in the database we need to convert ER diagrams into relational schemas. We can create a collection of relation schemas directly from ER diagram and it totally depends upon the design of the ER diagram, better the ER diagram more efficient the table and database will be. Cardinality, degree, and membership class all impact the structure of the database. To design a redundancy-free and efficient database we need to take care of a few things.

How to convert an ER diagram into a relational table?
There are main three cases while converting an ER diagram into the relational table, which is as follows:

1) When there are many to one cardinality in the ER diagram
2) When there are many to many cardinalities in ER diagram
3) When there is one to one relationship in the ER diagram.

Many to One Cardinality: In many to one cardinality let us assume there are two entities A and B, A is totally participating in the relationship whereas B has partial participation. Here, total participation means all the elements of A are mapped to at least one element of B it is represented using a double line in ER diagram, whereas partial participation means that each entity may or may not map to any other element of the entity B, it is denoted using a single line in the ER diagram.
In a many-one relationship, the key of many sides is the key to the resulting relationship. So, the resulting table would have the primary key of the Many sides.

Many to many cardinalities: Many to many relationships in a database occurs when multiple instances of the first entity are in a relationship with multiple instances of another entity. In simple words, both entities can have multiple relationships with each other.

One to One cardinality: One to one relationships in the database are the relationships between one instance of an entities with only one instance of another entity. One to one cardinality has two cases:
- Total participation at at-least one end
- No total participation

Mapping from ER Model to Relational Model
https://www.geeksforgeeks.org/mapping-from-er-model-to-relational-model/