anusha(salesforce developer)

SFDC Relationships

How many relationships included in SFDC & What are they? 
  • We are having two types of relationships, they are
  • Lookup Relationship
  • Master-Detail Relationship

What is a “Lookup Relationship”?
This type of relationship links two objects together,
  • Max. number of Relationship Fields per an object: 40 (Increased from 25 to 40 in Summer'14)
  • Parent is not a required field.

No impact on a security and access.
  • No impact on deletion.
  • Can be multiple layers deep.
  • Lookup field is not required.

What is “Master-Detail Relationship”?
Master Detail relationship is the Parent child relationship. In which Master represents Parent and detail represents Child. If Parent is deleted then Child also gets deleted. Rollup summary fields can only be created on Master records which will calculate the SUM, AVG, MIN of the Child records.
  • Up to 2 allowed to object.
  • Parent field on child is required.
  • Access to parent determines access to children.
  • Deleting parent automatically deletes child.
  • A child of one master detail relationship cannot be the parent of another.
  • Lookup field on page layout is required.
  • Max number of Roll-up Summary fields per an object: 25 (Click here for the Reference)

How can I create Many – to – Many relationship?
Lookup and Master detail relationships are one to many relationships. We can create many – to – Many relationship by using junction object. Junction object is a custom object with two master detail relationships.
A custom object contains some records, now my requirement is to create field in this object with master detail relationship. Can we create master detail relationship in this case?
   No, directly we cannot create master details relationship if custom object contains existing records.
   Following are the steps to create to create master-detail relationship when records are available in custom object.
  1. First create field with lookup relationship.
  2. And then associate look field with parent record for every record
       3. Next change the data type of the field from look up to Master detail.
Child records will be get deleted which are related to Department as well as Project.

Note: If we undelete the IT department record from the Recycle bin then along with IT department record all the related child (Employee) records will be restored those will be reflected for Project as well. (We cannot see the child object records in the Recycle bin)
A child object which is having master detail relationships with two different parent object is called junction object.

Example:
Object1: Department
Object2: Project
Child Object: Employee

  • Field1: Department (Master Detail with Department )
  • Field2: Project(Master Detail with Project)
Note: From the above example we can say Employee Object as Junction Object.
If we delete the parent object record all the child object records will be get deleted.

Example:
Child Object: Employee (Employee object have Department field which is related to Department Object)
Master Object: DepartmentSuppose N number of employee records related to IT department, if we delete IT department all the child records will get deleted.
Note:
Salesforce store deleted records only for 15 day in Recycle bin later it will remove the records permanently.
If we undelete the IT department record from the Recycle bin then along with IT department record all the related child (Employee) records will be restored. (We cannot see the child object records in the Recycle bin)

What will happen if we undelete the deleted Junction Object?
Master – Detail Relationship data types will be converted to look up relationship data types
Is it possible to delete junction – Object in case of Mater – Detail Relationship?

3 comments:

  1. hi,
    in junction object two parent.i.e. A and B and one child i.e. C. if we delete parent A then Child i.e C Will Be Deleted but what happens with B.Is still Exist or deleted?

    ReplyDelete
  2. If we deler=te parent B then also Child C will be deleted.

    ReplyDelete
  3. If we delete parent B then also Child C will be deleted.

    ReplyDelete