Loading content...
In the previous page, we established that weak entities suffer from an "identity crisis"—they cannot uniquely identify themselves using only their own attributes. The solution to this crisis lies in a special type of relationship that does more than just connect two entities. It fundamentally transforms the nature of the weak entity by providing the missing piece of its identity.
This special relationship is called an identifying relationship (also known as a weak relationship or ID-dependent relationship). Unlike regular relationships that merely associate independent entities, an identifying relationship is essential to the very existence and identification of the weak entity.
Understanding identifying relationships is crucial because they dictate how weak entities are structured in the conceptual model and how they translate to primary keys and foreign keys in the relational model.
By the end of this page, you will understand the formal definition of identifying relationships, how they differ from regular relationships, the constraints they impose, how they transfer identity from owner to weak entity, and the proper notation and modeling techniques for representing them in ER diagrams.
An identifying relationship is a relationship between a weak entity type W and its owner entity type O with the following properties:
Identity Transfer — The primary key of O becomes part of the primary key of W. The relationship is the mechanism by which this identity is transferred.
Existence Implication — The existence of any instance of W implies the existence of a corresponding instance of O. You cannot create a W without first having an O.
Mandatory Participation — W has total (mandatory) participation in the relationship. Every instance of the weak entity must participate in exactly one instance of the identifying relationship.
Single Owner — Each instance of W is associated with exactly one instance of O through the identifying relationship. The relationship has a cardinality constraint of 1 on the O side for each W instance.
Formal Notation:
Let W be a weak entity type with partial key D, and let O be its owner entity type with primary key K_O. The identifying relationship R connects W and O such that:
Think of the identifying relationship as a pipeline that carries identity from the owner to the weak entity. The owner's primary key flows through this relationship and becomes an integral part of the weak entity's identity. Without this pipeline, the weak entity has no source of unique identification.
Understanding the distinction between identifying and regular (non-identifying) relationships is fundamental to accurate database design. These two types of relationships serve different purposes and have different constraints.
| Aspect | Identifying Relationship | Regular Relationship |
|---|---|---|
| Primary Purpose | Provides identity to weak entity | Associates independent entities |
| Participation (Weak/Child Side) | Always total (mandatory) | Can be partial or total |
| Cardinality (Owner/Parent Side) | Always 1 (exactly one owner) | Can be 1:1, 1:N, or M:N |
| Key Contribution | Owner's PK becomes part of child's PK | Foreign key references parent's PK |
| Foreign Key Nullable? | Never (part of primary key) | May be nullable (partial participation) |
| Deletion Behavior | Must cascade (existence dependency) | May cascade, restrict, or set null |
| Entity Independence | Child cannot exist without parent | Both entities can exist independently |
| ER Notation (Chen) | Double diamond | Single diamond |
| ER Notation (Crow's Foot) | Solid line, identifying symbol | Regular line with cardinality markers |
| Creation Order | Parent must exist before child | No strict ordering required |
Example: Identifying Relationship
Employee ═══╗═══ Dependent
║
SUPPORTS
Example: Regular Relationship
Customer ───┬─── Order
│
PLACES
The fundamental difference is whether the parent's primary key becomes part of the child's primary key. In an identifying relationship, it does—creating a composite key. In a regular relationship, the parent's key is referenced via a foreign key but doesn't contribute to the child's identity.
Identifying relationships impose strict structural constraints that must be understood and enforced during database design and implementation.
Referential Integrity Constraints:
The identifying relationship enforces specific referential integrity rules:
Insert Rule: Cannot insert a weak entity without an existing owner. The foreign key (owner's PK) must reference an existing row in the owner table.
Delete Rule: Deleting an owner must cascade to delete all associated weak entities. This is not optional—it's inherent to the existence dependency.
Update Rule: If the owner's primary key is updated, the change must cascade to all associated weak entities to maintain the composite key integrity.
These constraints are typically implemented using ON DELETE CASCADE and ON UPDATE CASCADE in SQL foreign key definitions.
The identifying relationship plays a critical role in forming the primary key of the weak entity. This is the mechanism by which identity is actually transferred from owner to weak entity.
12345678910111213141516171819202122232425262728293031323334353637383940
-- Owner Entity TableCREATE TABLE Employee ( employee_id VARCHAR(10) PRIMARY KEY, name VARCHAR(100) NOT NULL, department VARCHAR(50), hire_date DATE); -- Weak Entity Table with Composite Primary KeyCREATE TABLE Dependent ( -- Foreign key from identifying relationship (also part of PK) employee_id VARCHAR(10) NOT NULL, -- Partial key (discriminator) dependent_name VARCHAR(100) NOT NULL, -- Other attributes birth_date DATE, relationship VARCHAR(20), -- Composite Primary Key: Owner's PK + Partial Key PRIMARY KEY (employee_id, dependent_name), -- Foreign Key with Cascade Rules FOREIGN KEY (employee_id) REFERENCES Employee(employee_id) ON DELETE CASCADE ON UPDATE CASCADE); -- Insert examplesINSERT INTO Employee VALUES ('E001', 'John Smith', 'Engineering', '2020-01-15');INSERT INTO Dependent VALUES ('E001', 'Sarah', '2015-03-20', 'Daughter');INSERT INTO Dependent VALUES ('E001', 'Michael', '2018-07-10', 'Son'); -- The composite key ensures uniqueness:-- ('E001', 'Sarah') is unique-- ('E001', 'Michael') is unique-- If another employee E002 has a child named Sarah:-- ('E002', 'Sarah') is also unique and distinct from ('E001', 'Sarah')A weak entity can itself be the owner of another weak entity, creating a chain. For example: Building → Room → Outlet (power outlet). The key cascades: Outlet's PK = (BuildingID, RoomNumber, OutletNumber). Each level adds its partial key to the growing composite.
In complex scenarios, a weak entity may require identity from multiple owner entities. This occurs when the weak entity represents a relationship or intersection between multiple strong entities, and that relationship cannot exist without all its participating entities.
Scenario: Course-Section-TimeSlot
Consider a university scheduling system:
A Section is a specific offering of a Course in a Semester. It cannot exist without both:
SectionNumber (like "001", "002") is only unique within a specific Course-Semester combination.
Primary Key of Section: (CourseCode, SemesterCode, SectionNumber)
The Section has two identifying relationships:
Multiple identifying relationships increase key complexity significantly. A Section's primary key has three components. If Section were owner to another weak entity (say, ClassMeeting), that entity's key would have four components. Consider whether this complexity is justified or if surrogate keys would simplify the design.
Implementation Considerations:
Join Complexity — Queries involving multi-owner weak entities require joining multiple tables. This can impact performance.
Composite Foreign Keys — References to the weak entity from other tables must include ALL key components.
Data Integrity — All owners must exist before the weak entity can be created. Deletion of ANY owner cascades to the weak entity.
Surrogate Key Alternative — For very complex keys, consider adding a surrogate key (SectionID) while maintaining the natural key as a unique constraint. This provides the benefits of both approaches.
Properly representing identifying relationships in ER diagrams requires careful attention to notation. Different notation systems have evolved, and understanding them all ensures you can read and create diagrams across various tools and standards.
Peter Chen's Original ER Notation:
In Chen notation, the identifying relationship has distinct visual markers:
Double Diamond — The relationship is enclosed in a double-bordered diamond, immediately distinguishing it from regular relationships (single diamond).
Double Rectangle — The weak entity is enclosed in a double-bordered rectangle.
Double Lines — A double line connects the weak entity to the identifying relationship, indicating total participation.
Dashed Underline — The partial key attribute in the weak entity is underlined with a dashed line (as opposed to the solid underline for regular primary keys).
1:N Cardinality — The relationship shows 1 on the owner side and N on the weak entity side.
Reading the Diagram: When you see a double-bordered rectangle connected by double lines to a double-bordered diamond, which in turn connects to a single-bordered rectangle, you're looking at a weak entity (double rectangle) in an identifying relationship (double diamond) with its owner (single rectangle).
Choosing to model a relationship as identifying versus regular has significant implications for your database design. These decisions should be made deliberately, considering the trade-offs.
Use identifying relationships when: (1) The weak entity truly has no independent identity, (2) Cascade delete is always the correct behavior, (3) The composite key has natural business meaning, (4) The depth of weak entity nesting is limited (2-3 levels max). Consider alternatives when keys become too complex or when flexibility is needed.
Alternative: Surrogate Key with Constraints
If composite keys become unwieldy, consider this alternative pattern:
CREATE TABLE Dependent (
dependent_id INT PRIMARY KEY AUTO_INCREMENT, -- Surrogate key
employee_id VARCHAR(10) NOT NULL,
dependent_name VARCHAR(100) NOT NULL,
birth_date DATE,
relationship VARCHAR(20),
UNIQUE (employee_id, dependent_name), -- Enforce natural uniqueness
FOREIGN KEY (employee_id) REFERENCES Employee(employee_id)
ON DELETE CASCADE
);
This provides:
The trade-off is slightly weaker semantic modeling in exchange for practical simplicity.
We've explored the identifying relationship—the bridge that provides identity to weak entities. Let's consolidate the essential concepts:
What's Next:
Now that we understand how identifying relationships provide identity to weak entities, we'll examine the partial key (discriminator) in detail—the attribute(s) within the weak entity that, when combined with the owner's key, create a unique identifier. We'll explore how to select appropriate partial keys and handle complex scenarios.
You now understand identifying relationships—their definition, constraints, role in key formation, notation, and design trade-offs. Next, we'll examine partial keys: the weak entity's contribution to its composite identity.