Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Difference between Join and Association in CDS View

Gaku
Explorer
40,828

Hello.

Please tell me the difference between Join and Association.

Association is higher than Join?

That's all benefit?

Thanks.

1 ACCEPTED SOLUTION
Read only

Jeansy
Active Contributor
34,166

Hi,

technically, both options are similar. Main difference is that the tables joined via association are only selected in case that the caller (e.g. the SELECT-statement in ABAP) wants to have at least one field of the related table. That's why the association is often called as "JOIN on demand". So if you have a CDS-view with many relations using assocations you do not have a performance issue if you use the CDS-view just for getting some fields of the main table as the associated tables are not selected (as there are no fields requested in the SELECT-statement). But if you use a field of an associated table, then technically SAP builds also a JOIN-statement to this table in order to get the related fields.

Some more details can be found here:
Blog: Association vs. JOIN
https://abapskill.com/cds/what-is-join-association-in-cds-view-sap-abap-pa...

Kind regards
Jens

Hello.

Please tell me the difference between Join and Association.

Association is higher than Join?

That's all benefit?

Thanks.

4 REPLIES 4
Read only

FredericGirod
Active Contributor
0 Likes
34,166

I am not an expert, but for me association is a possible link, as in logical database.

I don't see benefit of association on join when you hare only using ABAP code. But for the FIORI dev, there are differences

Read only

Jeansy
Active Contributor
34,167

Hi,

technically, both options are similar. Main difference is that the tables joined via association are only selected in case that the caller (e.g. the SELECT-statement in ABAP) wants to have at least one field of the related table. That's why the association is often called as "JOIN on demand". So if you have a CDS-view with many relations using assocations you do not have a performance issue if you use the CDS-view just for getting some fields of the main table as the associated tables are not selected (as there are no fields requested in the SELECT-statement). But if you use a field of an associated table, then technically SAP builds also a JOIN-statement to this table in order to get the related fields.

Some more details can be found here:
Blog: Association vs. JOIN
https://abapskill.com/cds/what-is-join-association-in-cds-view-sap-abap-pa...

Kind regards
Jens

Read only

Sandra_Rossi
Active Contributor
0 Likes
34,166

Association is very useful in ADT (didn't check in SE80), while you type SELECT with CDS view, it proposes all related associations. No need to search related tables, CDS view is like a database model.

If associations didn't exist, we should invent them.

Read only

alexis_scotts
Explorer
0 Likes
34,166

If you place the association name in the output then prerequisite to include the join condition fields in the output field list(in the above case it is employee_id). If you execute the CDS view then you get the result of zemployee table only. You get the zmanagers table data on demand. That’s why it is called Join on Demand(which is always an outer join).

Read More: CDS Views – Joins and Associations