2022 May 23 6:55 AM
Hello.
Please tell me the difference between Join and Association.
Association is higher than Join?
That's all benefit?
Thanks.
2022 May 23 8:14 AM
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.
2022 May 23 7:21 AM
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
2022 May 23 8:14 AM
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
2022 May 23 9:45 AM
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.
2022 May 23 10:09 AM
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