Data modelling

Defining the shape of the data before anything serves it — entities and types, aspects that carry cross-cutting concerns, associations and compositions, and the projections a service exposes. The question every CAP project answers first, and the one the rest of the corpus assumes has been answered.

Overview

SAP SHIPS
Node.js →

@sap/cds-compiler Compiles CDS models to CSN, EDMX and database schemas.

@sap/cds Compiles CDL from files or in-memory sources to CSN with cds.compile, and every generic handler reads the model through that CSN at runtime.

Java →

com.sap.cds:cds-services-bom Exposes the CDS model to the application through the Model Reflection API: services, types, entities and their elements, from the event context or injected.

Not covered: It stops at the model itself. Turning CSN into something else — types for a compiler, a picture, a migration against a database that already holds data — is a different capability each time, and each has its own entry here. The guide's own performance advice is part of the answer: avoid UNION in views, model polymorphism as normalised or denormalised entities rather than unions, and keep view chains and joins short, because the compiler translates what the model says and does not optimise it away.

THE COMMUNITY ADDS

CDS plugins that add reusable model parts to a project: cap-user-info ships an aspect and an entity that resolve createdBy and modifiedBy to a user record, and cds-numberrange-plugin adds a counter entity behind an annotated element.

Artifacts6

6 of 6 artifacts
ArtifactSignals
Build tools1
@sap/cds-compilerCompiler from CDS models to CSN, EDMX and database schemas
Signals
none
CDS plugins2
cap-user-infoUser details and quickview links for createdBy and modifiedBy
Signals
none
cds-numberrange-pluginFills a CDS element from a database-backed number range
Signals
none
Packages3
@sap/cdsCAP Node.js runtime
Signals
none
@sap/cds-common-contentISO content for CAP's countries, languages, currencies and timezones
Signals
none
com.sap.cds:cds-services-bomMaven bill of materials pinning CAP Java module versions
Signals
none

Content18

Group by18 of 18 pieces
Piece, what it offers
Deep Insert in SAP CAPM Using Composition and Fiori Elements
SAP Community, Talari Hari Kumar, BlogThe reasoningA recipeRunnable code
Building an Enterprise Application Using Fiori Elements and CAP - Part 1
SAP Community, Farooq, part 1 of 3, BlogThe reasoning
Create CDS Views and expose through OData service in CAPM
SAP Community, VenkateshMundru, Blog
Show 15 more
A CAP Plugin for Flexible Number Range Management: cds-numberrange-plugin
SAP Community, abdulbasit, BlogThe reasoningRunnable code
Understanding Projections in CAPM: Select Only What You Need!
SAP Community, Avisek_, BlogThe reasoning
CAP, CDS, CDL, CSN and jq - finding associations
SAP Community, DJ Adams, BlogThe reasoning
SAP CAP(Cloud Application Programming)开发框架概述
SAP Community, ArthurYang, Blog
#CAP-TechBytes Input Validation
SAP Community, Thajunniza, BlogThe reasoning
SAP CAP Recent Enhancements the HANA Dev Should Know About
SAP Community, Thomas Jung, Blog
SAP CAP Adapter to expose OData as custom REST Service
SAP Community, Former Member, Blog
Creating structured types, enums and named aspects using the CDS Graphical Modeler
SAP Community, Xiao-fei_Song, BlogThe reasoning
Importing @sap/cds common.cds to your CAP project using the CDS Graphical Modeler
SAP Community, Xiao-fei_Song, Blog
First Java Cap Application
SAP Community, bruce_wang3, Blog
Computed field example in CAP
SAP Community, DJ Adams, BlogThe reasoningA recipeRunnable code
Core changed
SAP Cloud Platform Backend service: Tutorial [11]: CDS : magic: key: generation
SAP Community, CarlosRoggan, Blog
Develop a full stack Business application with SAP Cloud Application Programming Model
SAP Community, former_member584731, Blog
Learn how to define constraints declaratively in your CDS model
SAP Developer Center, SAP, TutorialThe reasoningA recipe
Analyze and optimize ABAP Cloud model apps built on core data services
SAP TechEd — session catalogue, TalkThe reasoning
A CAP Plugin for Flexible Number Range Management: cds-numberrange-plugin
SAP Community, abdulbasit, BlogThe reasoningRunnable code

Seen working5

ArtifactSignals
Samples5
capire/bookshopCAP's getting-started bookshop sample
none
SAP-samples/cap-cds-hands-onFive-part workshop on CDS, from a first service to constraints
none
SAP-samples/cloud-cap-hana-swapiCAP data model of many-to-many relationships on a Star Wars dataset
none
xflightsCAP reuse package serving Airlines, Airports and Flights data
none
xflights-javaCAP Java reuse package for Airlines, Airports and Flights data
none

Details

What changed — and what it makes stale3
@sap/cds 9.9.0, CAP, Node.js

Declarative constraints (@assert) moved from Gamma to General Availability, and a bug in error reporting was fixed alongside it: every violation used to return the generic error code ASSERT regardless of which constraint failed; now the code returned is the one named in the constraint itself.

Makes stale:

Error-handling code or tests written against declarative constraints before April 2026 that match on a literal 'ASSERT' error code — they now see the constraint's own code instead.

@sap/cds 9.6.0, CAP, Node.js

The compiler gained a declarative validation annotation, at Gamma status. Before it, a check like 'reject if this field is missing or out of range' meant a custom before-handler in application code; after it, @assert: (<CXL expression>) on an element states the condition in the model itself and the runtime validates it on write.

Makes stale:

Advice that any conditional validation beyond @mandatory or @assert.range needs a handwritten handler. Since December 2025 a CXL expression in @assert covers much of that ground, model-side.

@sap/cds 8.0.3, CAP, Node.js

cds.compile.to.hana generates the hdbtable and hdbview artifacts and replaces cds.compile.to.hdbtable. Dated from the first 8.0 release published on npm.

Makes stale:

Build scripts and posts that call cds.compile.to.hdbtable.

Coverage
statecore and community, CAP
assessed
relationshipunassessed
also inABAP
For your agent
Ref
capability:data-modelling
JSON
/capabilities/data-modelling.json
MCP
Connecting an agent