SAP / SAP Mid Level (3 to 8 yrs) Interview questions
What is the difference between an association and a JOIN in CDS Views?
A plain JOIN written directly in a CDS View's FROM clause is evaluated
unconditionally every time the view is queried — the join always happens, whether or not the query
actually needs any fields from the joined entity. An association is declared but not automatically executed;
it only triggers a join if a query's field selection or filter path actually follows it.
| JOIN | Association |
| Always executed when the view is queried. | Only executed (lazily) if a query path actually follows it. |
| Fixed as part of the view's core query. | Reusable, can be followed differently by different consumers. |
| Simpler for a truly always-needed relationship. | Better for optional, conditionally-needed relationships. |
This makes associations the better default for optional or "might be needed" relationships, since they
avoid the performance cost of an unnecessary join for consumers that don't need that related data, something a
hardcoded JOIN can't offer.
More Related questions...
