About Self-Referential 1:N and N:N Relationships

In this article, we will discuss Self-referential 1:N and N:N relationships in MS Dynamics CRM 2011. It fulfills the need of maintaining parent-child relationships using the same entity. To simply understand this lets consider an example of custom entity Office which can be used to keep records of parent office as same as child office. In fact, this is a 1:N relationship.

Self-referential relationships

A self-referential relationship is a relationship between an entity and itself. There are two types of  self-referential relationships:

  • Self-referential 1:N relationships
  • Self-referential N:N relationships

Self-referential 1:N relationships

Self-referential 1:N relationships are useful for representing the hierarchical associations between the records, for example, a master order with related sub-orders.
Self-referential 1:N relationships can have a parental relationship behavior. If the relationship behavior is parental, any assign, share/unshare, reparent, delete, or merge action applied to the parent record will also be applied to all its child records.
A self-referential relationship cannot be used to create either direct or indirect circular relationships where the primary record is related to itself or any record in its own hierarchy.
To create a self-referential 1:N relationship, follow the procedure to create a 1:N relationship and specify the primary entity to be the same entity as the related entity.

Self-referential N:N relationships

Self-referential N:N relationships are useful for representing the loose associations between records, for example, cases linked to other cases where the root cause of all cases is the same.
To create a self-referential N:N relationship, follow the same procedure that we discussed earlier in previous section for creating an N:N relationship and specify the initial entity to be the same entity as the other entity.