ER vs Relational Model
There are some phases in designing a database. ER model and Relational model are crucial for these phases. For the conceptual design phase of a database, ER model is used and for the logical design of the database, data is represented in the form of the relational model. ER model used in conceptual design is used to convert data to Relational model. So, these two concepts are non separable from each other. Here we will be mainly focusing on how we can differentiate these two concepts.
ER model or Entity-Relationship model is a collection of entities and where relationships between these entities are shown. This model was developed by Peter Chen in 1976. This model shows a conceptual view of a database.
ER model is made of three major components. These are entity set, relationship set, and attributes.
Entity may be a physical object like a car, student or it can be a conceptual object like company, course. These entities are collectively known as entity sets.
Relations between these entities form relationship sets and attributes are the properties of these entities.
In the above ER model, Employee and Project form an entity set based on the ‘Works-IN’ relationship.
Data and relationships among those data are represented as Relational models in a relational database. It is a logical model of the possible database implementation. Relational model was developed by E.F. Codd in 1970. In a relational model, data is represented in the form of tables that are known as relations.
In a table, there are three major components.
Tuple: Each row in a table or relation is known as tuple.
Attribute: Properties of a relation or table are known as attributes. It is actually columns of the table.
Relation Schema: it represents the relation name along with its attributes.
Relational schema for the above E-R model as follows:
STUDENT (roll-no, sname, bdate, hno, dept)
Key : roll-no
COURSE (crs-no, cr-title, credit)
Key : crs-no
STUDY (roll-no, crs-no, grade)
Key : (roll-no, crs-no)
* attributes of the corresponding relation are enclosed in the braces.
Tabular representation of their differences
|E-R model represents the data as entity set, relationship set, and attributes||The relational Model describes data in a table as attributes and tuples or records.|
|Entity-Relationship Model shows mapping cardinalities between entities.||This model does not describe mapping cardinalities.|
|Entity-Relationship model is easier to understand the relationship between entities.||But to find the relationship between tables is not easier in the Relational model.|
|It is a conceptual model.||This model is the logical representation of the data model.|
|This model is mostly used by those who don’t have a better understanding of how a database is implemented.||Relational model is popular among programmers for implementing a database.|
- What is key in the Relational model?
In a relation or table, key is an attribute that uniquely identifies a row or tuple from other rows in the table.
- How many types of keys are available in the Relational model?
Mainly 5 types of keys are well known in the Relational model.
i) Candidate key
ii) Super key
iii) Primary key
iv) Alternate key
v) Foreign key
This article covered the difference between ER model and the Relational model. A good grasp of DBMS is always preferred in any technical interview.
Check out the CodeStudio Guided Path for getting a better hold on DBMS like CS fundamentals.
Don't stop here, Ninja; check out the Top 100 SQL Problems to get hands-on experience with frequently asked interview questions and land your dream job.
Side by side, you can also practice a wide variety of coding questions commonly asked in interviews in CodeStudio. Along with improving your problem-solving skills, you can also go through the interview experiences of scholars working in renowned product-based companies here.