Introduction
Entity and attributes are crucial aspects of RDBMS's ER model. If we have a collection of laptops that all belong to the same firm, are the same color, and have the exact specifications, we cannot distinguish them apart just on their looks.
And this is the reason why we are going to study Entity and Attributes because we must retrieve data from the database, and each of them must have a distinct value that may be used to distinguish between two sets of data. As a result, we can refer to an item as an entity when it becomes uniquely identifiable from the rest of the records in the database. So let's take a closer look at what an entity is, as well as entity sets and types.
Must Recommended Topic, Generalization in DBMS
Entity
What is an Entity?
An entity is a distinct real-world thing, such as a person, a place, or a concept, that can be uniquely identified. It's an object that stands out from the crowd.
Before we move further, it is worth noting that an entity cannot be represented in an ER diagram since it is an instance/data. However, an entity-set can be represented as a rectangle in an ER diagram. An entity set is nothing but a set of similar attributes or properties. For example: Student Entity-set, Employee Entity-set, and so forth.
Let us take an example to understand more:
In the ER diagram below, we have two entity sets: Student and College, which have a many-to-one relationship since many students attend a single college. We'll go over relationships in more detail later; for now, let's concentrate on entities.
Also Read, Super Keys in DBMS
Types of Entity:
An entity can be of two types :
- Tangible Entity: The term tangible entities refer to the physical entities that exist in the real world.
Example: a student, a keyboard, a bank locker, car, etc.
- Intangible Entity: Entities with solely a cognitive existence and no physical existence.
Example: a Google Account, a bank account etc.
To better understand an Entity, let’s take some examples:
- A college student having a unique roll number is an entity.
-
An organization with a specific GST number can be considered an entity.
Example:
In this particular example given below, we have a table named “Professor,” which contains multiple entities having attributes(Professor_ID, Professor_Name, Professor_City, Professor_Salary) by which we can understand that every entity contains a unique Professor_ID, which is the key attribute of the table which helps to distinguish between the entities.
<Professor>
Professor_ID | Professor_Name | Professor_City | Professor_Salary |
P01 | Tom | Sydney | $7000 |
P02 | David | Brisbane | $4500 |
P03 | Mark | Perth | $5000 |
Note: We don't represent the data in the E-R model. Instead, we represent the organization or schema. Data can be stored in tuples or rows and so represented as an entity when the E-R model is converted to a relational model.
Entity Type
With the Entity Data Model, the entity type is the essential building block for expressing the structure of data (EDM). An entity type in a conceptual model represents the structure of top-level notions like customers or orders. A template for entity type instances is an entity type.
An entity type is a group of the entity having similar attributes, which puts them in an entity type.
In the above Professor table example, each row was an entity and simultaneously had similar attributes. So, we can define the above “Professor” table as an entity type because it is a collection of entities having the same attributes.
Example: <Professor> is the Entity type in the example we used.
E-R representation of an Entity type:
Note: A rectangle outline is used to represent an entity type
Types of Entity type
- Strong Entity Type
- Weak Entity Type
Strong Entity type
A strong entity is one that is not reliant on other entities in the schema. A primary key is always present in a strong entity. A single rectangle represents a strong entity. A single diamond represents the bond between two powerful creatures.
When various strong entities are united, they form a strong entity set.
How to represent Strong Entity type:
For example:
Source: AfterAcademy
Weak Entity type
There is no key attribute for a weak entity type. It is unlikely to identify a weak entity type on its own. Its distinct identity is reliant on the presence of another strong entity. A real-life example can help you understand this:
There can be children only if the parent exists. There can't be a separate existence for children. There can be a room only if the building exits. There can't be a room that exists on its own.
A double-outlined rectangle represents a weak entity. An identifying connection is a relationship between a weak entity type and a strong entity type that is represented by a double outlined diamond rather than a single outlined diamond. The diagram below depicts this representation.
How to represent Weak Entity type:
For example: Here, we can see that “Address” is a weak entity as the whole entity can not be identified on its own just by using address entity type because it does not have any key attribute to identify the entity uniquely.
Source: AfterAcademy
Entity Set
A group of entities with the same set of properties is referred to as an entity set. Each entity in an entity set has its own set of attribute values that distinguishes it from the other entities in the table. The characteristics of no two entities in an entity set will have identical values.
The Table in a database represents an entity set. The Student Table, which has numerous entities, is shown below. Even though both kids have the name Jhoson, they are uniquely identified since they have separate roll numbers.
Source: Binaryterms
Note: We can say that entity type is a superset of the entity set as all the entities are included in the entity type.
Example: Using three entities from the table, we may create a new entity set. An entity set can also consist of Angel, Priya, and Analisa. Similarly, any entity from the entity type 'STUDENT' can be used to create any combination of the entity set. Also, we can see that if we add all of the records to the entity set, the entity type 'STUDENT' is created. As a result, the entity type can be considered the superset of the entity set.
Source: AfterAcademy
Now that you have understood what exactly is an Entity in DBMS let us now have a look at the next subject, i.e, Attributes.