Back

Relationships Interview Q&A

1. Is it possible to create the Master – Detail Relationship field for the child object which is having existing records?

No, we cannot create directly. To create first we should create Look up relationship then populate the field value for all the records and then convert the look up relationship to master detail relationship.

2.Is it possible to convert Mater – Detail Relationship to Look Up Relationship?

If the parent object doesn’t have Roll up Summary fields for the child object then we can convert.

3.Is it possible to delete junction – Object in case of Mater – Detail Relationship?

If the parent objects don’t have Roll up Summary fields for the child object then we can delete. To delete a child object it should not be referred in Apex Classes and Apex Triggers. Later if we undelete the object, Master detail fields on the junction objects will be converted to look up Fields.

Note: If we delete only Master – Detail Relationship field from the child object and undelete it from the Recycle Bin then it will be converted to look up relationship. Parent Object we cannot delete because it will be referred in the child object.

4. What will happen if we undelete the deleted Junction Object?

Master – Detail Relationship data types will be converted to look up relationship data types.

5.What will happen to child records if we delete a parent record in case of Lookup Relationship?

If we delete parent object record all the child object records relationship’s field value will be get deleted. (Entire record won’t be get deleted) Example:

Child Object: Employee (Employee object have Department field which is related to Department Object)

Parent Object: Department

Suppose N number of employee records related to IT department, if we delete IT department all the child (Employee) records Department field value related to IT department will be 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 all the related child records department field value will be restored.

6.What will happen to child records if we delete a parent record in case of Master Detail Relationship?

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: Department

Suppose 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)

7.What is Junction Object?

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.

8.For a junction object if we delete one of the parent record what will happen to child records?

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)



Back
Site developed by Nikhil Karkra © 2023 | Icons made by Freepik