The main difference between entity and relationship in DBMS is that the entity is a real-world object while the relationship is an association between the entities. Also, in the ER diagram, a rectangle represents an entity while a rhombus or diamond represents a relationship.
A Database Management System (DBMS) is a software program that stores, retrieves and manipulates data in the databases. A DBMS contains multiple databases, and each database consists of multiple tables. The tables are related to each other using relationships. DBMS provides multiple advantages. The user can change and retrieve data in DBMS using Structured Query Language (SQL). Furthermore, it helps to organize data, increase data consistency and to protect data. MySQL, Oracle, DB2, MSSQL are some examples of DBMSs. An entity is a table in DBMS, and it represents a real-world object. These entities are connected to each other using relationships.
Key Areas Covered
1. What is an Entity
– Definition, Functionality
2. What is a Relationship
– Definition, Functionality
3. Difference Between Entity and Relationship in DBMS
– Comparison of Key Differences
Entity, Relationship, DBMS
What is an Entity in DBMS
An entity is a real-world object. A university database can have entities such as Student, Lecturer, Course, Project, etc. In a DBMS, these entities are the tables. The attributes describe the entities. The student entity can have attributes such as id and name. The course entity can have attributes such as course_code and course_name. The Lecturer can have attributes such as id, name and speciality.
A database must be designed before creating the actual database. An ER diagram helps to get a conceptual view of a database. A rectangle represents an entity in the ER diagram. A double rectangle represents a weak entity while n oval represents the attributes of an entity. Refer the below diagram.
In the above diagram, Lecturer, Course, Student are entities. They are also called strong entities as they do not depend on other entities. The Lecturer entity has attributes id, name, and specialty. The Course entity has the attributes course_id and course name. The Student entity has the id and name attribute. The Exam entity depends on the Course Entity. Therefore, Exam is a weak entity. It has the attributes name, date, starting_time and duration.
What is a Relationship in DBMS
A relationship signifies an association among the entities. There are three types of relationships that can exist between the entities. They are the binary, recursive and the ternary relationship.
A binary relationship represents the association between two entities. It is further classified into three types. They are one to one relationship (1:1), one to many relationship (1: m) and many to many relationship (m: n).
When one instance of an entity is associated with one instance of another type of entity, it is called one to one (1:1) relationship. There is one Head of the Department to manage the department. So, it is a one to one relationship.
When one instance of an entity is associated with many instances of another type of entity, it is called one to many (1: m) relationship. In a faculty, there can be multiple students, but a single student is in one faculty. Therefore, it is a one to many (1: m) relationship.
When many instances of an entity are associated with many instances of another type of entity, it is called many to many (m : n) relationship. A student can participate in multiple courses, and a single course can have multiple students. So, it is a many to many relationship (m: n).
Furthermore, when an entity is related to itself, it is called a recursive relationship. When there are three entities connected, that relationship is known as a ternary relationship.
In the above ER diagram, the Lecture conducts Course. The Lecturer and Course entities connect with the “conducts” relationship. A single Lecturer can conduct multiple Courses, but one Course is conducted by one Lecturer. So, it is a one to many (1: m) relationship. Similarly, the Student and Course entities are connected by “follows” relationship. A Student can follow multiple Courses, and a single Course can have multiple Students. Therefore, it is a many to many (m:n) relationship. The Course has an Exam. The Exam is a weak entity, and it depends on the Course. So, that relationship is a weak relationship. It is denoted by a double diamond symbol.
Difference Between Entity and Relationship in DBMS
An entity can be a real-world object, either animate or inanimate, that can be easily identifiable. A relationship is an association among entities.
Representation in the ER diagram
A rectangle represents an entity in the ER diagram. A double rectangle represents a weak entity. A rhombus or diamond represents a relationship in an ER diagram. A double rhombus denotes a weak relationship.
The entities help to represent real-world objects. They are the tables. A relationship represents the association between entities.
An entity is a table in DBMS, and it represents a real-world object. Entities are connected to each other using relationships. Thus, the difference between entity and relationship in DBMS is that the entity is a real-world object while the relationship is an association between the entities.
1. “ER Model Basic Concepts.” Www.tutorialspoint.com, Tutorials Point, 8 Jan. 2018, Available here.
Leave a Reply