ERPClimb logoERPClimb
CAP
BTP & Integrationintermediate 5 min read

BTP CAP Part 5: Domain Modeling with Entities, Associations, Compositions and Aspects

Preview · a free account unlocks the full lesson

Key takeaway

Model the domain well in CDS: entities with keys (cuid), reusable aspects (managed, temporal), types and code lists, associations (references) vs compositions (contained children with deep insert/delete), and modeling patterns that keep services and UIs simple.

In this lessonShow sections

Visual overview

DOMAIN MODELINGAssociation or composition?The one question that decides it1Two related entitiese.g. Order and Items / Order and CustomerModel?Child exists without parent?Independent lifecycleNo → Composition (deep insert, cascade delete)Yes2AssociationReference only; no cascadeAssociation3Add aspectscuid, managed, code listsAspectsClean, reusable modelServes many servicesdb/Tip: shared entities like Address must never be compositions.

Explanation

Part 4 covered SaaS and multitenancy; this part returns to the domain model itself — entities, associations, compositions and aspects. The @sap/cds/common library provides reusable aspects such as cuid for a UUID primary key, managed for automatic created/modified fields, and Currency, Country and CodeList for common reference data. Associations reference genuinely independent entities, for example an Order referencing a Customer.

Compositions model contained children, such as an Order containing Items, and come with deep insert, deep update and cascading delete behavior built in. Whatever the model ends up looking like, it should stay independent of any single UI or consumer rather than being shaped around one specific screen.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.