1. Strong Entity
A strong entity (also called an independent entity) is an entity that can exist on its own in the database. It has a primary key—a unique identifier that distinguishes each instance of the entity.
Characteristics:
- Has its own attributes, including a primary key.
- Does not rely on any other entity for identification.
- Represented in ER diagrams using a single rectangle.
In the above image, we have two strong entities namely Employee and Department hence they are represented using a single rectangle. The relationship between them is works in i.e. it gives information about an employee working in a particular department hence it is represented using a single diamond. In the above image, if we remove the relationship between the two entities then also the two entities will exist i.e. Employee as well as Department will exist since they both are independent of each other, this explains the independent nature of strong entities.
Why it's important:
Strong entities are the core building blocks in a database. Most tables in a relational database represent strong entities.
2. Weak Entity
A weak entity is an entity that cannot exist without being related to a strong entity. It does not have a primary key of its own and is identified by using the primary key of another (strong) entity along with some of its own attributes.
Characteristics:
- Lacks a complete primary key.
- Relies on a strong entity for identification.
- Always has a total participation in a relationship with the strong entity.
- Represented using a double rectangle in ER diagrams.
- The relationship with the strong entity is shown with a double diamond, and the dependent attribute is called a partial key.
Example:
Take an OrderItem
entity that stores items for each order in an Order
entity:
OrderItem
attributes:ItemNo
,Quantity
OrderItem
is a weak entity becauseItemNo
alone may not identify a record uniquely. We need to combine it withOrderID
fromOrder
to form a unique identifier like(OrderID, ItemNo)
.
Another example is Dependent
for an Employee
:
- A dependent (like a child or spouse) cannot be identified without linking to an
Employee
.
Why it's important:
Weak entities are used when data cannot be modeled completely on its own. They are essential for modeling real-world situations like items within an invoice or dependents of an employee.
Comparison Table:
Feature | Strong Entity | Weak Entity |
---|---|---|
Existence | Independent | Dependent on a strong entity |
Primary Key | Has a primary key | Lacks full primary key |
ER Diagram Notation | Single rectangle | Double rectangle |
Participation | Can be partial or total | Always total (needs related strong entity) |
Relationship Type | Any | Must have an identifying relationship |
Key Dependency | None | Identified using strong entity + partial key |