Skip to Content
0

Cardinality in CDS assocation

Jun 16, 2017 at 06:35 AM

780

avatar image

Hi,

If I understand it correctly the cardinality only reflects the target table.

Does the cardinality have any influence at all - thus providing the wrong cardinality gives different results.

Or is this cardinality for documentaion purposes only since association is by default left outer join.

I see mixed messages about this matter.

Speaking of, what about the cardinality for the inner? I only see examples with [1:inner].

I see also examples with filters on inner without cardinality. A good explanation and/or documentation on all this would be very nice, since it's rather confusion with all these mixed/contradictional messages.

Cheers

Eddy

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

2 Answers

Sean Zhang
Jun 23, 2017 at 07:48 AM
1

The target cardinality of an association shall always be defined explicitly providing the minimum and maximum number of target instance occurences, for example [0..1] or [0..*].

It is recommended to increase the transparency of the model by always specifying the maximum cardinality of joins (...left outer to one join.../...left outer to many join...), which are used in the CDS view definition.

If fields are added to a view via joins with the addition "to one" or associations with the target cardinality [0/1..1] the corresponding joins shall only be executed if these fields are actually selected.

This is actually the influence.

because, for "to one" or associaiton cardinality [0/1..1], the generated SQL statement will be interpretated as LEFT out join to one. Then if the DB support the optimization and no fields from the right right is selected in the comsumer level, the join will be by passed. e.g. the HANA supports the optimization.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

This is correct.

In fact we have platform dependent behavior here, because not all DBs optimize.

The documentation was enhanced and will deliver some examples with next release.

0

Hi Horst,

Yes, the optimization is DB specific.

and it's also good to hear that there will be official document and example to explain this.

Best Regards,

Sean

0
Eddy De Clercq Jun 28, 2017 at 11:17 AM
0

I'm afraid it's still not clear to me if specifying the wrong cardinality has influence on the results (on a HANA DB) or not. If I read your answer it's best to specify always [0..*] for a left outer join. But what with an inner join? Specifying [1] or [1:inner]?

It's not clear to me what to do when one wants to create reusable views, where one needs sometimes a left outer join and in other cases en inner join for the same query.

Share
10 |10000 characters needed characters left characters exceeded