Home »
DBMS
Conversion of ER Diagram to Relational Model
In this tutorial, we will learn about the types of relations, the basics of the relational model, and how to convert an ER Diagram into a Relational model?
By Prerana Jain Last updated : May 27, 2023
Before moving to conversions of an ER diagram to a Relational Model, learn about the relations and relational model.
What are Relations?
Relations specify that how a entity of a entity set is related to the entity of other set.
Types of Relations
There are following types of relations:
1. One to One
Every element of the first set is related to almost element of the entity set & Vice versa.
2. One to Many
A relationship is said to be one to many if every entity of the first entity set can relate to any number of entity of other entity set. But every entity of the other entity set can relate to almost One entity of the first entity set.
3. Many to Many
A relationship is said to be Many to many if any entity of the first entity set may relate to any one of the entities of other entity set and vice versa.
What is Relational Model?
In the Relational model relationship records is represented by a relation that contains a key for each record involved in the relations. It is useful for representing most of the real world objects and relationships most of real world objects and relationships among them. The relational model does not maintain physical connection among records. It is organized logically in the form of rows and columns and stored in the table. In the relational model, many-to-many relationships can be easily implemented.
Advantages of Relational model
- Structural independence: Relational database model are structural independent because any changes made in the database does not affect the original database.
- Simplicity: The relational model is the simplest model at the conceptual level.
- Ease of designing: The relational model makes it easy to design, implement, maintain and use the database.
- Query capability: One of the main reason for the huge popularity of the relational database model is the presence of powerful, flexible and easy to use query capability.
Conversion of an ER Diagram to a Relational Model
The following are the steps to convert of an ER diagram to a relational model:
- Mapping regular/strong entity: For each strong entity set create a new relational independent table that includes all attributes as column. For composite attribute include only component attributes.
- Mapping weak entity: Convert every weak entity set into a table where we take the discrimination attribute of the weak entity set and takes the primary key of the strong entity set as a foreign key and then declared the combination of discriminator attribute and foreign key as a primary key.
- Mapping 1:1 Relationship: For a 1:1 Relationship between two entities S and T. Choose one of the relations, Example - S and include as foreign key in S the primary key of T. It is better to choose on entity total participation on S and include descriptive attribute.
- Mapping 1:N Relationship: For 1:N relationship identify the entity S on N side of the relationship. Include a foreign key in S the Primary key of relation T also include Discipline attributes of 1:N attribute of S.
- Mapping N:N Relationship: For each M:N relationship create a new relational table include in the new relation ,the primary key of the participating entities as a well as descriptive attributes. The primary key of the table will be the combination of primary keys of participating entities.
- Mapping Multi-valued attribute: For every multi-valued attribute will make a new table where we will take primary key of main table as a foreign key and multi-valued attribute as a primary key.