Skip to Content

Cardinality in CDS assocation

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jun 23, 2017 at 07:48 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 28, 2017 at 11:17 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded