Mastering DBMS: Learn Basics to Advanced Technique
A Quick Guide to Entities in DBMS
What is an Entity in DBMS?
Suppose a company wants to fetch the data of the employees who took more than 15 leaves in a month. One way to do this is to store the data of employees in files and then count the number of employees whose number of leaves is greater than 15. But, this will be a very time-consuming task as you have to manually check the id of each employee.
But, if you do the same task by using a database query, it will be much easier for you as the employees are uniquely identifiable in the database. This is the importance of uniquely defining an object in the database. This uniquely identifiable object is called an Entity in DBMS.
Database Management System provides various ways to logically define the database design using which data semantics, data relationships, and data consistency can be described. This is called a Data Model. There are various types of Data Models such as Relational Models, Object Oriented Models, ER models, etc. Out of these, an ER Model is a very popular data model used in systems that represents the objects as Entities that are characterized by some attributes.
Entity Definition
The entity is an object which can be represented in a database using some attributes and is associated with other Entities using some Relationship. For example, if you use an E-commerce site for purchasing a product, you are represented as an Entity in DBMS, which has attributes such as Customer ID, Name, Country, Phone Number, etc.
An Entity can be a Tangible Entity (real-world object) for example, a car, or a non-real-world object such as a user account.
Entity Type and Entity Set
An Entity Type in DBMS is defined by the name of the Entity. For example, in the above case, you are an Entity that has the type Customer (the name of the entity). On the other hand, Entity Set in DBMS is a collection of similar types of Entities. For example, a set of two Employees is called an Entity Set. Therefore, Entity Type is a Superset of Entity Set because all the Entities of Entity set are included in the Entity Type.
In ER Diagram, the rectangle represents the Entity Type (not the Entity) which is associated with other Entity Types. Thus, an Entity is meant by the type of Entity in the ER Diagram. For example, if you are a customer, then you belong to the ‘Customer’ Entity Type in the ER Diagram.
Types of Entity in DBMS
Entities are of Different Types which are decided by how they are related or dependent on each other. There are the following types of Entities:
Strong Entity
If an Entity has a key attribute (uniquely identifiable feature), then it is called a Strong Entity. A simple example of a Strong Entity is the Employee which has the key attribute ‘Employee ID,’ using which a record of that Entity Type is uniquely identified. In ER Diagram, it is represented using a single rectangle.
Weak Entity
A Weak Entity in DBMS does not have a Key Attribute. It depends on some other Strong Entity to be identified uniquely. For example, if Installment is an Entity, then it can exist only if a Loan exists as an Entity. It is represented by a double rectangle in ER Diagram.
Thus, this is how Entities are used in the ER Model to represent the real-world object in the Database Management System.