Skip to Content
0

Benefit of using Association over JOIN in CDS view ?

Oct 26, 2016 at 12:53 PM

3.7k

avatar image
Former Member

Hello,

Anybody knows benefit why Association would be used in CDS view instead of any of teh JOIN (Inner, left outer etc.) . As the association cardinality mentioned is anyways not validated at runtime. Also the association behaves differently (as INNER join or LEFT outer) based on where it is used.

Please let me know if anyone has inputs on the same.

Thanks.

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

3 Answers

avatar image
Former Member Oct 26, 2016 at 02:45 PM
0

Well, One thing is that you can expose the association without having to list all the fields inside.

It's good to if you want to repeat the same association varios time but with different filters:


excdsas.png (40.9 kB)
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Oct 27, 2016 at 05:32 AM
0

Hello Marc,

Thanks for the comment. That helps.

This (to repeat the same association various time but with different filters) indeed is unique about Associations which cannot be done in JOINs.

Anything else unique about ASSOCIATIONS?

Share
10 |10000 characters needed characters left characters exceeded
Sean Zhang
Mar 23, 2017 at 10:46 AM
0

Hi Kumail,

Actually, you could always use join and association, which should be a decision case by case.

one thing is that you don't need to expose the field from the target entity if you're using association, and in where you want to use, e.g. in higher level CDS, you could always follow the association to get the related field from the association. so you could say association make you leave the last point you really need to touch the field from the target association view.

in the meantime, the cardinality you mentioned is indeed taken into consideration when the related SQL view is generated.

e.g. [1..1] or [0..1] will be interpreted as LEFT OUTER MANY TO ONE JOIN

while [0..*] will be interpreted as LEFT OUTER MANY TO MANY JOIN

the first one will definitely benefit the runtime performance, because the left out join might be bypassed, in case that there is no field from the right part requested. and this is similar to what we could achieve by using join directly.

one further high importance for association is that when you're trying to use CDS for OData scenario, you will really be benefited by association, because all the association could be automatically exposed as entity in OData service.

You could also get some idea from the naming: association, which is connecting the data/entity, but it's not coupled together, with association, you always have the possible to achieve more, but you don't have to.

Hope this would give you some hints for the association.

Best Regards,
Sean

Share
10 |10000 characters needed characters left characters exceeded