1. Entity:
An entity is a real-world object or concept that has an independent existence and can be uniquely identified. In the context of a database, an entity is typically represented by a table.
Example:
| EmployeeID | Name | Department |
|------------|-----------|-----------------|
| 101 | Alice | HR |
| 102 | Bob | Engineering |
| 103 | Carol | Marketing |
In this example, each row represents an entity (an employee) with attributes like EmployeeID, Name, and Department.
2. Entity Set:
An entity set is a collection of similar entities. It represents all instances of a particular entity type.
Example (Employee Set):
| EmployeeID | Name | Department |
|------------|-----------|-----------------|
| 101 | Alice | HR |
| 102 | Bob | Engineering |
| 103 | Carol | Marketing |
In this case, the entire table is the entity set representing all employees in the organization.
3. Entity Type:
An entity type is a category or class of entities that share common attributes. It defines a set of entities that have similar characteristics.
Example (Employee Type):
| EmployeeID | Name | Department |
|------------|-----------|-----------------|
| | | |
The table above represents the entity type “Employee,” and it serves as a template for creating instances of employees. The actual data, as seen in the entity set table, populates this template.
In summary:
- An entity is a single instance of a real-world object.
- An entity set is a collection of similar entities.
- An entity type is a category of entities that share common attributes.
The entity type provides the structure (attributes) that entities in the entity set will have. The entity set is the actual collection of instances or records in a database table, and each row in the entity set table represents a distinct entity.
Difference Between Entity, Entity Set and Entity Type:
Criteria | Entity | Entity Set | Entity Type |
---|---|---|---|
Definition | A single instance of a real-world object or concept. | A collection of similar entities. | A category or class of entities that share common attributes. |
Representation | Typically represented by a row in a database table. | Represented by the entire table containing multiple rows, each representing an individual entity. | Represented by the structure of a table, defining the attributes that entities in the set will have. |
Example | A specific employee with a unique EmployeeID, Name, and Department. | All employees in an organization, represented by the entire “Employees” table. | The “Employee” type with attributes like EmployeeID, Name, and Department, serving as a template for creating instances. |
Instance | A single row in the table, e.g., one employee’s data. | Multiple rows in the table, e.g., all employees in the organization. | Not applicable; it’s a template or blueprint for creating entities. |
Cardinality | Singular. There is only one instance in a specific row. | Plural. It encompasses multiple instances represented by rows. | Singular. It represents the category or class shared by all instances in the set. |
Usage | Refers to a specific occurrence or record. | Refers to the entire collection of similar occurrences. | Refers to the common structure defining a category of occurrences. |