SAP RAP / CDS / OData CDS Associations Interview Questions

Interviewers use cds associations to test depth rather than coverage: the follow-up question is almost always "why does the system behave that way?", and that is where prepared answers usually run out.

Learn ABAP CDS associations as semantic relationships between entities, including ON conditions, cardinality, path expressions, exposed associations and their effect on generated SQL and consumers. Use this topic to model reusable relationships without confusing associations with free performance gains.

This page carries 10 reviewed SAP RAP / CDS / OData cds associations interview questions, each with a complete written answer and no sign-in required. The set breaks down into 1 foundational, 7 mid-level and 2 advanced questions, so you can start at the top for a first interview or skip ahead to the scenario-based items for a senior round.

If you can handle every question here without hesitating, cds associations is unlikely to be what costs you an SAP RAP / CDS / OData interview — and the same reasoning pattern transfers to the neighbouring topics linked at the bottom of this page.

10 CDS Associations questions with answers

easyCDS Associations

1. What is a CDS association, how is it declared, and how does it differ from a join?

An association is a declared relationship: association [cardinality] to Target as _Alias on <condition>, using $projection (or the source alias) for source fields, which must be in the element list. It is exposed by listing _Alias in the element list. Unlike a join, which is always executed, an association becomes a join (LEFT OUTER by default) only when used — by a path expression in a view or ABAP SQL, or by OData $expand. This lets consumers pay only for relationships they need and makes views reusable.
mediumCDS Associations

2. A status text association returns duplicate rows in a list. The ON condition is only on the status code. What is wrong and how do you fix it?

The text table has one row per status and language, so the association is effectively to-many; any path to the text multiplies rows. Fix: add the language condition to the ON clause (and _Text.Language = $session.system_language) so it becomes to-one, or model it as a text association on a #TEXT view with @Semantics.language, which Fiori/OData resolve by logon language. Verify cardinality with GROUP BY … HAVING COUNT(*) > 1 and declare [0..1] only once it is true.
mediumCDS Associations

3. Explain path expressions: what SQL do they generate, how do filtered paths work, and how are they written in ABAP SQL?

A path expression follows an association (_Customer.CustomerName) and generates a join — LEFT OUTER by default — once per distinct path, even if several fields are read. Chained paths join once per step. Filters in square brackets restrict the target (_Item[ ItemCategory = 'TAN' ]); adding "1:" declares the filtered result to-one. The join type can be changed with an attribute such as [inner], which removes rows without target. In ABAP SQL the syntax is \_Customer-CustomerName, chained \_Customer\_Country-Name. To-many paths in the select list or WHERE multiply rows.
mediumCDS Associations

4. A list of orders must show the number of items and total item value per order. How do you model this in CDS without duplicates?

Items are to-many; putting item paths in the order list multiplies rows. Create an aggregation view on the items grouped by order and currency: count(*) as NumberOfItems, sum(NetAmount) as TotalNetAmount (with @Semantics.amount.currencyCode). Associate it from the order view as to-one (on order and currency) and read its fields in the list. Keep the to-many _Item association for $expand on the object page. Never sum across currencies and never use DISTINCT to hide multiplication.
mediumCDS Associations

5. How are compositions declared in CDS for a RAP business object, and what must projections do with them?

The root ("define root view entity") declares composition [0..*] of Child as _Item — without an ON condition. The child declares association to parent Root as _Request on $projection.ParentKey = _Request.Key, so it must contain the parent key. Root and child are activated together. In projections, the composition is redirected (_Item : redirected to composition child ZC_Item) and the parent (_Request : redirected to parent ZC_Root); normal associations can be redirected to projected targets or kept. Compositions are only for parts of the same BO; references to other BOs stay associations.
mediumCDS Associations

6. What design rules do you follow for associations in an interface view layer?

Model relationships as associations rather than joins; always declare cardinality explicitly and verify it against data; make texts and time-dependent relations to-one with language or date conditions; point associations to CDS entities (released views in clean core), not tables; use underscore-prefixed business names; expose associations consumers need; keep to-many associations for navigation and aggregation, not for list fields; avoid functions in ON conditions; aggregate to-many data in separate views.
mediumCDS Associations

7. A universal sales order view uses inner joins to customer, material and plant, and some orders disappear. How would you redesign it?

Inner joins drop orders without a matching customer, material or plant, and every consumer pays for all joins. Redesign as an interface view with only header fields plus associations (to-one for customer, plant; to-many for items), exposed for consumers. Each consumer follows only what it needs; paths are LEFT OUTER by default, so orders without targets remain. Check orders without targets with a query (WHERE \_Customer-Customer IS NULL) and fix master data separately.
mediumCDS Associations

8. An OData list returns 2,400 rows where the business expects 800. How do you analyze it?

Reproduce with the exact request ($select, $filter, $expand). Compare row counts of the base view and the consumption view to find a multiplying path; remove suspicious paths one by one. Check each to-one association's real cardinality with GROUP BY … HAVING COUNT(*) > 1, and text/time associations for missing language/date conditions. Inspect the generated SQL (Show SQL CREATE Statement) and an ST05 trace. Fix with filtered paths ("1:"), aggregation views or added conditions — not DISTINCT. Re-count after the fix.
hardCDS Associations

9. Users say a CDS-based report 'lost' some records. What are the possible causes related to associations, and how do you tell them apart?

1. An [inner] path drops rows without a target — find them with WHERE \_Assoc-Key IS NULL. 2. A WHERE condition on a target field excludes rows without a target (NULL is not equal to any value). 3. A too-strict ON condition (wrong key, type or leading-zero mismatch, language) finds no target. 4. Not association-related: CDS access control filters rows for this user — compare with WITH PRIVILEGED ACCESS or another user. Distinguish by counting at each layer and with/without the suspicious path; fix the model or the data, then re-count.
hardCDS Associations

10. You inherit a CDS model with many associations. What do you review before extending it?

Check: declared cardinalities against real data; to-many paths used in list views or WHERE; missing language/date conditions on text and validity associations; associations to tables instead of CDS entities; [inner] paths and target-field filters that drop rows; functions in ON conditions; compositions used for references to other BOs; missing redirects in projections; unnecessary hard joins. Use the dependency analyzer, generated SQL, row-count comparisons and ST05 on key consumers. Document findings and fix high-impact issues before adding features.

Related lesson

CDS Associations Part 2: Path Expressions and How Associations Become Joins

Related topics

Next practice step

Go deeper on this topic