We will learn what are relationship in Microsoft CRM. Relationship or entity relationship defines how a particularly specific entity record is related to another specific entity record. For example, the Account entity record can a unique logical relationship with the Contact entity record which represent the actual connection between the account and its contact.
Types of entity relationship in Microsoft CRM
Microsoft CRM supports three different types of relationship which are given below.
- 1:N relationships (One To Many).
- N:1 relationships (Many To One).
- N:N relationships (Many to Many).
1:N relationships (One To Many)
Relationship defines how the records can be related to each other in the CRM database. Adding a lookup field to an entity creates a new 1:N (one-to-many) relationship between the two different entities. With help of the lookup field, one parent entity record is associated to many child entity records. Basically it forms the parent-child relationships. A parent object can have many child’s objects but a child object must have only one parent object. Consider the above example where the Mother is the parent entity (1) and the Children is the child entity (N), and logically the Mother can have multiple Children.
N:1 relationships (Many To One)
With an N:1 relationship, multiple primary child entity records have relation with one single parent entity record. For example, multiple Student entity record will have a common University entity record related with it.
N:N relationships (Many to Many)
In N:N or many to many relationship, there is not one single primary entity record and another secondary or related entity record, rather they both act as both types. For example, you might want to have one Books entity record related to many Authors entities or one Authors related to many Books entities.
Relationship behavior in Microsoft CRM
The are four different types of relationship behavior in Microsoft Dynamics 365 which are listed below.
- Referential, Restrict Delete.
- Configurable Cascading.
In the parental relationship between two entities, any operation taken on a record of the parent entity is also taken on any child entity records that are related to the parent entity record. If you delete a record in the parent entity, the related child entity records are also deleted; or if you share a parent entity record, the related records from the child entity are also shared. All option are disable for Parental relationship.
In a referential relationship between two entities, you can navigate to any related records, but actions taken on one will not affect the other.
Referential, Restrict Delete Behavior
Actions taken on parent entity record will not affect the child entity record but parent record cannot be deleted till the child record exists. i.e you cannot delete a entity record when related records exist.
Configurable Cascading Behavior
We can set the cascading behavior for the operations like, Assign, Share, Un-share ,Re parent,Delete & Merge. We can have one of the below cascading options while configuring relationship. The type we are interested here is “Configurable Cascading”. It allows you to decide what type of behavior we need to apply.The useful details of different cascading rules are (note here me is referred to the user on whom you will perform actions)
• Cascade All: Perform action on all of my child records. Like if assigned my account to another user then all my activities, orders, invoices etc are assign to new user including open, completed and other user owned records
• Cascade Active: Perform action on only my active child records
• Cascade User-Owned: Perform action on all my child records which is owned by me
• Cascade None: do nothing to my child records
• Remove Link: remove link from child record
• Restrict: Applies to Delete. The delete is not allowed if there are other entity instances that reference the ID of the entity instance being deleted.
The cascading concept provided by Microsoft is given below.