Strong and Weak Entities
In the context of databases and Entity-Relationship Diagrams (ERDs), entities are classified as either strong or weak. This distinction primarily revolves around how an entity is identified.
Strong Entity: A strong entity is an entity that can exist on its own without needing another entity. In other words, its existence does not depend on any other entity. It has a primary key, which uniquely identifies each instance of the entity. For example, in a university database, 'Student' might be a strong entity, with 'StudentID' as its primary key. Each student can exist independently of any other entities (like a course or department).
Weak Entity: A weak entity, in contrast, cannot exist without an accompanying strong entity; it relies on the strong entity for its identification. It does not have a primary key of its own, but instead uses a foreign key in combination with some of its own attributes to create a composite key, which uniquely identifies each instance. This foreign key links it to the identifying strong entity.
For example, consider an 'Order Item' entity in an e-commerce database. 'Order Item' could be a weak entity, because each order item can't exist without being associated with a specific order. The 'Order' would be the strong entity in this case, with 'OrderID' as its primary key. The 'Order Item' entity might then have a composite key consisting of 'OrderID' (linking it to the 'Order' entity) and 'ItemID' (representing the specific item within the order).
In ER diagrams, weak entities are often displayed in a double-bordered box, and the relationship with the identifying strong entity is represented by a double diamond. The line connecting a strong entity to its dependent weak entity is drawn using a solid line to show this identifying relationship.
These distinctions help to ensure the integrity of the data by establishing necessary dependencies among entities.