Skip to Content
0

What exactly is associations in CDS view? And its benefit over JOIN?

Jul 18, 2017 at 08:55 AM

1.5k

avatar image

Hi,

What exactly is the benefit of using associations in CDS view instead JOIN?

I read Associations are metadatas about joining connections. Actual join is created when the association is used in a path expression. Refer to https://blogs.sap.com/2017/03/07/inner-join-with-cds-associations-abap-on-hana/

But what is path expressions? Can anybody help me with this?

Also I Googles for associations cardinality information but did not found a proper documentation.

Can anybody please help me?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Jocelyn Dart
Jan 05 at 03:42 AM
2

Thanks James.

Hey Ankur,

You use a Join when you want to combine data in the same read from the database. For example, if I am displaying a list of Sales Orders I might want to get the vendor name along with the vendor id in the one read which I use to display a list of Sales Order headers, because that's information I always need to show.

You use an association when you want to NAVIGATE from one entity to another in a UI. I don't always need to drill down to every sales order. I can delay reading the Sales Order Items unless and until the user drills down to them. So I want an association from my Sales Order header joined view to my Sales Order Item view. That sets up an easy navigation but also that navigation won't be used unless the user needs it. So the overall UI will perform better because it only reads the data it needs to.

SAP uses the standard and recommended OData approach for path expressions.

The path expressions are used when navigating from one entity to another. You can see this explained in more detail in http://www.odata.org/documentation/odata-version-2-0/uri-conventions/ where they talk about addressing entities. In other words the path expression defines how you move from e.g. the Sales Order header to the Sales Order items using the OData association.

Rgds,

Jocelyn

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Jocelyn,

Thanks for this excellent answer.

I still have a doubt how associations are useful in analytic scenarios (its benefits over join).

If you include an association in select list in analytic cds views, the association cannot be accessed in reporting tool (unlike OData). Element list of association needs to be explicitly specified so that reporting tools like Bex are able to access the association elements.

The moment you include explicit list of elements in the view - you are no longer requesting fields "on demand". In that case, how would association benefit over join?

Thanks,

Anup

0
avatar image
Former Member Jan 03 at 04:57 PM
0

A bit late but it may help someone's search.

I am no expert on CDS yet but learning. I had been just using joins in my CDS views but I am getting ready to use associations because they let me set up navigation between two CDS views so that in my Fiori App, I can go from header table to detail item table.

I will create One CDS view as the HEADER table with association to the ITEM table.

I will create another CDS view as the ITEM table with association to the HEADER table.

I will create a third table known as a "consumption view", It will expose the fields from both the HEADER and the ITEM and will be used to publish an OData Service that I can then use in a Fiori app.

There is a great blog about this here: My CDS view self study tutorial – Part 5

Share
10 |10000 characters needed characters left characters exceeded