Salesforce Interview Question and answers for Developers Part 9

49. What is the significance of master detail relationship?
Ans - Master detail relationship can be set by creating master detail field on the detail object. In master detail relationship whenever a master detail record is deleted the detail records are also deleted. When creating a detail record it is mandatory that the master field is populated with a value(i.e master field is mandatory) It is also mandatory that this field is kept on pagelayout. A standard object can never be set as detail object. With master detail relationship roll up summary fields can be created on master object.

50. What is trigger recurssion and how can you you avoid it?
Ans - If an exceting trigger calls itself then it goes to into infinite loop and is called recursion. If a trigger on a particular object executing on a particular dml does the same dml on that object then the same trigger would be called and it will go into recursion. A static variable can be set in a class before executing the trigger to avoid the recursion.

51. What is an external id?
A external id is field that can be used as a reference while updating records. If the data is coming from an external system then the unique field that the external system has could be used as an external id within salesforce. External id can be used while upserting records within salesforce using data loader. There is a limit on the number external ids you can have in an object.

52. What are governers limit and what is its significance?
Ans - Governers limit is a limit that salesforce enforces on every code execution so as to avoid monopoly by any single org. Since the resources are shared across organisation governer limit checks on the resource utilisation. Number of limits are imposed limit 100 soql query exception, 50000 rows can be fetched using soql etc

53. Why one should not put a soql or a dml within for loop?
Ans - Putting soql or dml in for loop can easily hit the governer limit hence we should not put them in for loop. Only 100 soql are allowed in one transaction and only 150 dmls are allowed.

54. What are the various collections available in salesforce?
Ans - In salesforce along with primitive data types and sObjects there are collections. Apex uses following collections as below
    List - stores duplicate values which are ordered.
    Set - stores unique values which are unordered
   Map - consists of keys and values

No comments:

Post a Comment