Weak Entity in DBMS
A weak entity set is an entity set that does not have attributes to uniquely identify its entities. It contains a partial key (discriminator) to represent a group of entities.
Introduction to Weak Entity in DBMS
A weak entity is an entity that has no primary key attribute to uniquely identify the records existing in it. Therefore, it has to be dependent on the strong entity set for its unique identification. In general, an entity set is supposed to have a primary key attribute that helps to uniquely identify any record or tuple in the entity set. However, there might be an entity set that doesn't have an attribute to differentiate all of its tuples and provide them with a unique identity. On the other hand, if any entity set contains a primary key, then it is known to be a strong entity set. For example, a University Serial Number (USN) is what makes the identification of any student unique, be it a current undergrad or an alumni. So, irrespective of two students having the same name, branch, and/ or batch, the only way to differentiate them is their USN. Therefore, this USN becomes the primary key for the record of any student. However, without a primary key in any record (like USN in this case), we'll have a weak entity set that has no unique identity. Another example would be online shopping. Whether you purchase one item or several, there's no way for these items to uniquely justify your purchase because you are not the only one buying it. So, it is better to go with assigning an order id to your order so that while saving your purchase history as a record, it contains a primary key attribute that uniquely identifies it. In addition, all these product items you purchased must have a product name, product category, and also product id. But is it still enough to know that you bought these items at any time? No. So, it should be better associated with the order details like order id, order date, etc. So, the product items will be a weak entity type and order details will be a strong entity type because it has an order_id attribute that makes a record unique. Therefore, there will be a parent-child relationship between the strong and weak entities.
- To represent a weak entity set, a double rectangle will be used and for a strong entity set, a single rectangle is used.
- The attributes of both the entity set will be represented with an oval. Moreover, a primary key will also be underlined with a single line whereas a partial key, also known as a discriminator, will be underlined with a dashed line.
- To establish and indicate the relationship of a weak entity set with a strong entity set, the double diamond symbol is used to represent the relationship set (relationship connection).
- Since the weak entity has total participation, its connection with the relationship set is shown by a double line. On the contrary, a strong entity set may or may not have total participation, so its connection is shown by a single line only. Also, the arrow mark will be towards the strong entity set because we are discussing the weak entity set in our case.
|Single Rectangle||Represents a strong entity set|
|Double Rectangle||Represents a weak entity set|
|Oval||Used for attributes|
|Underline||Represents primary key|
|Dashed Line||Represents partial key|
|Single Line||Represents relation between the relationship set and a strong entity set|
|Double Line||Represents relation between the relationship set and a weak entity set|
|Single Diamond||Represents relationship connection between two strong entities|
|Double Diamond||Represents relationship connection between two weak entities|
Examples of Weak Entity
We'll now look at the ER model of the previously discussed example of product details and order details. The symbols for the representation of the different components will be applied here. The details of the product and the order will be included in two separate entities.
Comparison Between Strong and Weak Entity
|Strong entity set||Weak entity set|
|Representation||To represent a strong entity set, a single rectangle is used.||To represent a weak entity set, a double rectangle is used.|
|Key attributes||A strong entity set always has attributes enough to select one as a primary key.||A weak entity set doesn't have a primary key. Instead, it has a partial key.|
|Dependence||The presence of a primary key makes a strong entity set independent.||As a weak entity set contains only a partial key, it is always dependent on a strong entity for its unique identification.|
|Relationship representation||A single diamond symbol is used to depict the relationship between two strong entities.||A double diamond symbol is used to represent the relationship between a strong and a weak entity set.|
|Participation constraint||Total participation may or may not be there by a strong entity set.||A weak entity set, being dependent on a strong entity set, always has its total participation in the relationship between the entities.|
|Relationship connection||A single line is used to establish connection with the relationship set.||A double line is used to establish connection with the relationship set.|
- A weak entity is an entity that has no primary key attribute to uniquely identify the records existing in it. Therefore, it has to be dependent on the strong entity set for its unique identification.
- A weak entity comprises a partial key (discriminator). However, it is not enough to uniquely identify the record in the entity. It has to be dependent on the strong entity set for its identification because a strong entity has primary key.
- A weak entity has its total participation in the relationship set whereas for the strong entity set, total participation may or may not be there.