CSE Roadmap

Common tier · about 3 hours · 5 parts

Part 4 of 5 · 2 min read

Aggregation

Treating a relationship as an entity, so a further relationship can connect to it.

Aggregation

Think of a delivery company tracking which driver handled which specific shipment-and-route combination. "Shipment assigned to route" is itself already a relationship. "Handled by driver" needs to connect to that whole combination, not to either shipment or route alone.

In plain words: aggregation treats a relationship, together with the entities it connects, as a higher-level entity in its own right, so that a further relationship can connect to the combination as a whole. This is needed when a fact depends on the pairing itself, not on either original entity alone.

A worked example. In the bookstore, "Customer places Order" is a relationship. A further fact, "reviewed by support agent," depends on that whole placing-event, not on Customer or Order alone, so the Customer-places-Order relationship is aggregated into its own entity that "reviewed by" can connect to.

The key lines. No new code; this stays at the diagram level.

(Customer --- places ---> Order)  [treated as one aggregated entity]
     |
  reviewed by
     |
  SupportAgent

Aggregation

Aggregation treats a relationship, together with the entities it connects, as a single higher-level entity, allowing a further relationship to connect to that combination as a whole.

Example: treating "Customer places Order" as one entity lets "reviewed by SupportAgent" attach to the whole placing-event, rather than incorrectly attaching only to Customer or only to Order.

For the curious Don't reach for these by default

Specialization, generalization and aggregation add real modeling power, but also real complexity. Most entities and relationships in this subject's running bookstore example are flat, exactly because the extra structure these three ideas provide is not needed for them. Reach for a hierarchy or an aggregated entity only when a real requirement, like the examples above, actually calls for it.

Quick notes

  • Specialization splits a general entity into specific subtypes, each inheriting shared attributes and adding its own.
  • Generalization works in the opposite direction: pulling shared attributes up from already-modeled specific entities.
  • Both produce the same shape of hierarchy; only the design direction differs.
  • Aggregation treats a relationship as an entity, letting a further relationship connect to the combination as a whole.
  • Reach for these three tools only when a real requirement needs the extra structure, not by default.