Entity Set is a collection or a group of ‘entities’ sharing exactly the ‘same set of attributes’. All entities can be distinctly identified in an entity set. This is because all the entities have a different set of value for some set of attributes. We further classify the entity set into two basic categories Strong and Weak entity set.
The collection of entity sets and their relationship sets together forms a database. In this section, we will discuss the entity set and we will also learn how an entity set is different from an entity? Further, we will discuss the classification of the entity set.
Content: Entity Set in DBMS
What is an Entity?
An entity is an ‘object’ in the ‘actual world’, and that can be identified from the other objects. Here, a question arises that how an entity is different from other entity? For this, we need to know how an entity is expressed.
Well, an entity in a database is represented as a set of attributes. Each entity has a different set of values for some set of attributes and this is how an entity seems to be distinct from other entities. In a relational model, an entity is represented as a row, tuple or a record.
For example, consider a group of students is there, each student in the group is a separate entity. Now, how we can identify a particular student in that group? Simple, each student will have a different name, roll number, or course etc.
If you call for a student among a group no one will come until you specify either his name or another distinguishable attribute.
Observe the table below, suppose we have an entity set Student, which is represented by Student Table in the relational model. The entries in the Student table are the entities.
Student Steive with roll number CS08 and Course Comp. Sci. is a particular entity as is distinguishable among all the students in the table. Likewise, all the students in the Student Table can be uniquely identified from other students. So, each student in the table is an entity.
What is Entity Set?
An entity set is a group of entities that posses the same set of attributes. Each entity in an entity set has its own set of values for the attributes which make it distinct from other entities in a table. No two entities in an entity set will have the same values for the attributes.
In a database, an entity set is represented by the Table. Below you can see the Student Table which as multiple entries i.e. entity. Now, observe that the two students have the name Jhoson but, still they are uniquely identified as both posses different roll number.
Well, in ER diagram an entity set is always represented with the rectangle. But, an entity can never be represented in ER diagram as it is just an instance.
Types of Entity Set
Entity set can be classified into two categories as shown below:
- Strong Entity Set
- Weak Entity Set
Strong Entity Set
An entity set that has a primary key using which, entities in the table can be uniquely identified. This kind of entity set is termed as a strong entity set. Strong entity set is also known as a regular entity set.
In an ER diagram, the strong entity set is represented by the rectangle. Here, the primary key is underlined with the solid line.
Let us discuss one example, to understand strong entity set in a better way. The Student entity set discussed above is the strong entity set. An in ER diagram it would be represented as below.
In the figure above, the Student has attributes as Roll_No, Name and Course. Among these attributes, the Roll_No can form a primary key as it is sufficient to identify each entity in student entity set uniquely.
Look at the figure below, we do have two students named Jhoson but they can be distinctly identified because of their roll number. So, the student entity set has a primary key which makes it a strong entity set.
Weak Entity Sets
A weak entity set doesn’t have any primary key which can identify each entity in a set distinctly. But, for discriminating the entities in a set, the weak entity set is dependent on a particular strong entity set.
A weak entity is also said to be existence dependent as for the existence of its entities it has to be dependent on identifying entity set i.e. a particular ‘strong entity set’. The relation between a weak entity set and a strong entity set is said to be identifying relationship.
The relation amidst a weak entity set to a strong entity set is a many-to-one relationship. So, many weak entity sets can be related to one particular strong entity set. Now, a weak entity set has a partial key which is a ‘set of attributes’ that help in distinguishing the entities.
The weak entity gets its primary key combining the partial key of the ‘weak entity’ plus the primary key of identifying ‘strong entity set’.
Let us understand this with an example, we have an entity set section and course. The section has attributes {Sec-id, year, semester}. Now, there can’t be a section without any course. So, it has to be dependent on the course entity set for its existence.
On the other hand, for the different courses, the attributes of section entity set may share the same value. For example, there can be a section A, of 3rd year and semester 6 for a course Computer Science and at the same time, there can be section A, of 3rd year and semester 6 for Electronics.
So, we can say that the section entity set is a weak entity and it is dependent on strong entity set course. Now, the course entity set has attributes {course_id, name, years}. Here, the course_id is the primary key which distinguishes all the entities in the course entity set.
Here, the primary key of the weak entity set section is course_id + sec-id, year, semester.
The weak entity is shown by a rectangle in an ER diagram. But, the attributes of weak entity set are underlined with the dashed line. The relationship of a weak entity set and strong entity set is shown with the double diamond as shown in the figure below:
Key Takeaways
- An entity set is a collection or a set of all the entities that share the same attributes set but with a different set of values for some attributes.
- An entity is an object in an actual world that can be distinguished from the other entities.
- The entity can be classified into two basic categories, strong entity set and weak entity set.
- An entity set that has a primary key is the strong entity set.
- An entity that doesn’t have a primary key is a weak entity set.
- A weak entity set is dependent on one strong entity set to distinguish its entities.
- Primary key for weak entity set is the primary key of its identifying strong entity set + partial key of weak entity set.
So, this all about the entity set and its classification. While creating the database the entity set, entity attributes must be drawn carefully.
arun says
Nice explanation, thank you
David says
This is the best tutorial I have ever seen on the internet. Kudos to you. Very simplified even for amtuer like me.