Skip to Content
avatar image
Former Member

Relationship in CDS Association


Could you help me understand the relationship defined in association in CDS views is same as cardinality?

For Example, what does [0..1] and [1..1] mean? How is this different from cardniality in a join in HANA view?

association [0..1] to Z_I_Material as _Material on $projection.Material = _Material.Material association [1..1] to Z_I_Sales_Hdr as _SalesHeader on $projection.SalesDocument = _SalesHeader.SalesDocument



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Jun 23, 2017 at 11:26 AM


    if you're consuming the association in a higher level view, then [0..1] and [1..1] for association will be interpreted as LEFT OUTER MANY TO ONE JOIN in the sql statement, then it would be similar to the HANA column view's LOJ to one.

    in HANA, such kind LOJ will be optimized in the runtime, e.g. if the fields is not selected, then the join will be by passed.

    you could get the sql statement for your CDS by right click your CDS content->show SQL create statement in AIE.

    you could also check a similar question and the comments in the bottom.

    Best Regards,


    Add comment
    10|10000 characters needed characters exceeded

    • [0..1] here exactly means the target could have minimum 0 entry, and maximum 1 entry.

      actually, if you could always ensure that there will be and only be one entry, then [1..1] shall be used.

      however, you have to think about some rare case, e.g. is it possible that company code be blank in the C_NonManagedPurchasingSpend1? or would there be any data(in C_NonManagedPurchasingSpend1) which doesn't have an entry in the I_CompanyCode?

      if the answer is YES, then [0..1] would be better.

      if the answer if NO, then [1..1] shall be used, which will explain the model more clearly.

      this explains the I_SalesOrderItem, which have the following.

      association [1..1] to I_SalesOrder

      And, all in all, the association cardinality is mainly explaining the modeling, in run time, there is no difference between [1..1] and [0..1], because both of them are interpreted as LEFT out JOIN in SQL View.(at least, it's the case right now), so you don't have to very specific in this case, since it will not introduce any runtime difference.

      Yes, you could be more strict to do the modeling, since it will definitely introduce benefit to you in the future to understand the modeling.

      Hope my comments help you.

      Best Regards,


  • May 29, 2017 at 12:33 PM

    You already answered your question for yourself: it is the cardinality.

    [0..1] there may be one or none entries

    [1..1] there's exactly one entry

    Add comment
    10|10000 characters needed characters exceeded

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

      Yep, on HANA there are optimizations (from 7.50 on) that can influence results. Unfortunately, especially the documented default settings can produce unexpected results. Therefore, the cardinality should reflect the real data.