What is an Entity, Entity Type and Entity Set?

If we have a group of keyboards that are from the same company, same colour, same look, then we can’t differentiate between them just by seeing them. We can differentiate between them only if we know the product number which is unique for every keyboard. So, if we don't know this product number then these keyboards can't be identified from a group and they are just objects. Why are we stressing so much on identifying them uniquely? Also, why are we taking the example of a keyboard in DBMS?

The reason is simple, just like the keyboards, we have to retrieve the data from the database and each of them should have a unique value that can be used to differentiate between two different data. So, when an object becomes uniquely identifiable we can call it an entity. Now, let's see in more depth what is an entity and what are entity types and entity sets.

Entity

An entity is a real-world thing which can be distinctly identified like a person, place or a concept. It is an object which is distinguishable from others. If we cannot distinguish it from others then it is an object but not an entity. An entity can be of two types:

Tangible Entity: Tangible Entities are those entities which exist in the real world physically. Example: Person, car, etc.

Intangible Entity: Intangible Entities are those entities which exist only logically and have no physical existence. Example: Bank Account, etc.

Example: If we have a table of a Student (Roll_no, Student_name, Age, Mobile_no) then each student in that table is an entity and can be uniquely identified by their Roll Number i.e Roll_no.
Note: In E-R model we don't represent the data but we represent the structure or schema. When we convert E-R model to relational model then data can be stored in tuple or row and hence, represented as an entity.

Entity Type

The entity type is a collection of the entity having similar attributes. In the above Student table example, we have each row as an entity and they are having common attributes i.e each row has its own value for attributes Roll_no, Age, Student_name and Mobile_no. So, we can define the above STUDENT table as an entity type because it is a collection of entities having the same attributes. So, an entity type in an ER diagram is defined by a name(here, STUDENT) and a set of attributes(here, Roll_no, Student_name, Age, Mobile_no). The table below shows how the data of different entities( different students) are stored.

The E-R representation of the above Student Entity Type is done below.
Note: We use a rectangle to represent an entity type in the E-R diagram, not entity.

Types of Entity type

  • Strong Entity Type
  • Weak Entity Type

Strong Entity Type: Strong entity are those entity types which has a key attribute. The primary key helps in identifying each entity uniquely. It is represented by a rectangle. In the above example, Roll_no identifies each element of the table uniquely and hence, we can say that STUDENT is a strong entity type.

Weak Entity Type: Weak entity type doesn't have a key attribute. Weak entity type can't be identified on its own. It depends upon some other strong entity for its distinct identity. This can be understood with a real-life example. There can be children only if the parent exits. There can be no independent existence of children. There can be a room only if building exits. There can be no independent existence of a room. A weak entity is represented by a double outlined rectangle. The relationship between a weak entity type and strong entity type is called an identifying relationship and shown with a double outlined diamond instead of a single outlined diamond. This representation can be seen in the diagram below.

Example: If we have two tables of Customer(Customer_id, Name, Mobile_no, Age, Gender) and Address(Locality, Town, State, Customer_id). Here we cannot identify the address uniquely as there can be many customers from the same locality. So, for this, we need an attribute of Strong Entity Type i.e ‘Customer’ here to uniquely identify entities of 'Address' Entity Type.

Entity Set

Entity Set is a collection of entities of the same entity type. In the above example of STUDENT entity type, a collection of entities from the Student entity type would form an entity set. We can say that entity type is a superset of the entity set as all the entities are included in the entity type. Let's try to understand this with the help of an example.

Example 1: In the below example, two entities E1 (2, Angel, 19, 8709054568) and E2(4, Analisa, 21, 9847852156) form an entity set.
Example 2: We can form another entity set by taking three entities from the table. (2, Angel, 19, 8709054568) , (3, Priya, 20, 9864257315) and (4, Analisa, 21, 9847852156) can also form a entity set. Similary, we can form any combination of the entity set using any of the entities from the entity type 'STUDENT'. Also, we can understand that if we take all the records to the entity set we get the entity type 'STUDENT'. So, we can say that the entity type is the superset of the entity set.

This is all about an entity, entity type and entity set. Hope you learned the difference between these terms.

Do share this blog with your friends to spread the knowledge. Visit our YouTube channel for more content. You can read more blogs from here.

Keep Learning :)

Team AfterAcademy!