serving the solutions day and night

Pages

Saturday, January 19, 2013

MS Dynamics Entity Relationship

An entity relationship in Microsoft Dynamics CRM defines how two entities interact with each other.
Microsoft Dynamics CRM uses three types of data relationships, which we review in more detail in the following sections:
Hierarchical Relationships - 1:N and N:1

One-to-many (1:N) - relationship between two entities in which a single entity can possess multiple (many) related entities. For Example, Each Account can have many Contacts, but you can assign only one Account to each Contact.

Many-to-one (N:1)
Many-to-many (N:N) - For Example,  The relationship between the Marketing List entity and the Marketing List members. You can create many marketing lists in Microsoft Dynamics CRM, and then you can assign multiple members to each list. In addition, you can add members to multiple marketing lists.

Self-Referential Relationships - an entity has a relationship with itself. Both hierarchical relationships and many-to-many relationships can be self-referential. For example, opportunities can be linked to related opportunities. The only limitation to self-referential relationships is that entity instances cannot be related to themselves in a parental relationship. This creates a circular reference.

Relationship Types
System - A parental relationship type automatically defined by Microsoft Dynamics CRM for system entity relationships. You cannot modify this kind of relationship.
Parental - All operations on the parent entity instance are propagated to the child entity instances (cascade all):
  • If the entity instance is deleted, its related entity instances will also be deleted.
  • If the entity instance is assigned to another user, its related entity instances will also be assigned to the other user.
  • If the entity instance is shared with another user, its related entity instances will also be shared with the other user.
Example - If you delete an Account record (the primary entity), CRM deletes all of that record’s related data, including its Activity, Note, custom entity, and Opportunity, because of the parental relationships those entity records have with the Account entity. 

Referential - Operations are not cascaded between entities (cascade none):
  •     If the entity instance is deleted, only the link from its related entity instances is deleted.
  •     If the entity instance is assigned to another user, its related entity instances are not affected.
  •     If the entity instance is shared with another user, its related entity instances are not affected.
Example - If you delete the Account shown in Fig, CRM deletes all of the records except custom entity B and its Note.

Referential, Restricted     - The entity instance can only be deleted if it has no related entity instances. Otherwise, this relationship type is the same as referential.

Configurable Cascading - Cascading rules can be configured for most actions. For system relationships, you can select the cascading rules for all actions except merge or delete. For custom relationships, cascading rules can be selected for all actions except merge. Cascading on merge is dependent on the referenced entity. If the referenced entity is an account, contact, or lead, the action cascades. Otherwise, it does not.

Six actions are affected by relationship types -  Assign, Delete, Merge, Reparent, Share, Unshare

The cascading rules are described in the following table.
Cascade All -  Perform the action on the specified entity instance and all related entity instances.
Cascade None - Perform the action on the specified entity instance only. Do not cascade to related entity instances.
Cascade Active - Perform the action on the specified entity instance and all related entity instances that are active or open.
Cascade User Owned -Perform the action on the specified entity instance and all related entity instances that are owned by the same user as this entity.
Remove Link - Perform the action on the specified entity instance and remove the link to the related entity instance. No changes are made to the related entity instance.
Restrict - Applies to delete only. The delete is not allowed if there are other entity instances that reference the ID of the entity instance being deleted.

Creating a Mappings
1. Entities -> Entity -> click the  N:1 relationship.

2. Double-click the entity relationship  - > click Mappings.

3. click New

Reference
http://msdn.microsoft.com/en-us/library/bb955303.aspx
http://www.microsoft.com/en-us/download/details.aspx?id=2640
http://msdn.microsoft.com/en-us/library/gg309396.aspx

No comments: