What is the definition of weak entity in database?
In database design, a weak entity is an entity that cannot be uniquely identified by its own attributes alone. Instead, it relies on a "strong" or "owner" entity to provide part of its identification. Weak entities are typically used in situations where the existence of the weak entity is dependent on the strong entity.
Partial Key: A weak entity has a partial key, which is an attribute or a set of attributes that can uniquely identify the weak entity only when combined with the primary key of the strong entity.
Existence Dependency: A weak entity cannot exist without its associated strong entity. If the strong entity is deleted, the weak entity is also deleted.
Identifying Relationship: The relationship between a weak entity and its strong entity is called an identifying relationship. This relationship is typically represented with a double line in an Entity-Relationship (ER) diagram.
No Primary Key: Weak entities do not have a primary key of their own; instead, they use a combination of their partial key and the primary key of the strong entity to form a composite key.
Consider a scenario with two entities: Order (strong entity) and OrderItem (weak entity).
OrderID
.ItemNumber
, but it cannot be uniquely identified without the OrderID
. Therefore, the combination of OrderID
and ItemNumber
serves as the composite key for OrderItem
.In this case, OrderItem
is a weak entity because it depends on Order
for its identification and existence.