web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Relationship type property

(0) ShareShare
ReportReport
Posted on by 1,552

I have a table called table 1, that has Id1 as a unique index.

Then i have another table called table2, where it has two fields Id1 and Id2 (where Id2 is unique index)

There is a relation between Id1 in table 2 and Id1 in table1.

So to describe the relation, i can have different Id2 related to the same Id1.

Id1 Id2

1     1

1     2

1     3

2     4

3     5

3     6

So based on this, Cardinality is ZeroMore and RelatedTableCardinality is ExactlyOne. Also onDelete property is restricted.

However i can't decide the relationship Type. Based on Microsoft documentation, i feel that association works because of Id1 relation but also it seems composition work as well. 

1. Can you please help me in explaining relationship types more and how to decide the correct one?

2. Also does putting wrong values affect how tables works?

I have the same question (0)
  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Junior AX,

    1. It depends on the purpose of these tables and where you define the relation (table1 or table2). if it's header + line concept, it should be a composition. If it's just 2 independent tables, it should be Association. But it could be also aggregation  in certain cases when

    2. Relations define certain OOB features and if the relation is not defined properly you can get incorrect behavior or some of these features can be missing. But I haven't faced any major issues (check out the list in the documentation docs.microsoft.com/.../defining-table-relations )

  • junior AX Profile Picture
    1,552 on at

    Hi Sergie,

    The relation is on table2.

    1. it's not like a sales order with lines but it has the same concept, that multiple records in table2 can't be related to more than one record in table1.

    So should i put it as composition?

    and why not put it as as association or aggregation? can you please explain these more and put an example on them. I mean how are the going to be independent tables and have relation at the same time?

    2. I think the post you shared, says the benefit of relation in general. Not what would happen if put wrong cardinality or wrong relation type.

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi JuniorAX,

    1.  The composition can be used in this case, if you don't have or plan to use another composition relation. Association also will work.

    Aggregation is used if you have related field in Table1 for for Table2, but Table2 still can have several related records.

    By the way, Have you seen the article how to choose relationship type microsoft-dynamics-ax-erp.blogspot.com/.../understanding-relationshiptype.html ?

    2. Yes, it's correct, i don't recall anything major happened if relation is incorrect (maybe one old case related to composite entity development, but i don't remember details)

  • junior AX Profile Picture
    1,552 on at

    Hi Sergie,

    1. you mean i should only have one composition relation type in each table?

    2. if composition and association works, which is better to choose and why?

    3. I read the article but i have few questions:

       a.  It says when nothing is specified, the system infers an appropriate value. So the system internally

            detects the correct relation type. why would the system want to detect it? and what do they mean

            by system here?

       b. maybe my answer to question 2 must be composition, because the system detects composition

           before association?

       c. It says you must set the RelationshipType property to Association if the system does not set the

           value of property to anything. But in a it said that the system detects and now it says if the system

           doesn't set it. How can i know if the system sets it or not?

    4. You mean aggregation is used when it's like sales and lines relation but the difference is that same lines can relate to different headers?

  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi JuniorAX,

    1. Yes, let's go back to header+lines case, lines will have composition relation to the header and it would be strange if you will have another header1 + lines case

    2. You still should decide if you case quite close header+lines or not. If you i'm sure, I choose association. Anyway, it will not make any harm and you can change relation from association to composition later if needed.

    3. I'm not sure what author ments about "NotSpecified" value, but you will get BP warning if you not specify it.

    4. For aggregation you can check expample with CustTable + CustBankAccount, on customer can have multiple bank account, but there is also field on customer to indicate primary bank account and relation for this field is aggregation.

  • junior AX Profile Picture
    1,552 on at

    I think i will put it as composition for now. I'm not sure if this will cause any issues.

    and i will check the relation on custTable as you suggested thank you.

  • Lauras U Profile Picture
    955 on at

    Sorry, for resurrecting older thread, but it's first google result of "dynamics 365 "relationship type" composition vs aggregation" :-)

    I always find this document in handy when have to decide relationship type: https://docs.microsoft.com/en-us/previous-versions/dynamics/ax-2012/reference/hh803131(v=ax.60) 

    Quoting that article this is quite good description of composition:

    "Is a stronger type of Aggregation. A table must not have more than one Composition relation. For example, a building is composed of rooms, and a given room cannot exist in more than one building."

    So if relation is from table2 to table1, then I think it's composition. Otherwise relation from table1 to table2 should be aggregation. Correct me if I am wrong?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 449 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 422 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans