Salesforce Admin Interview Questions - Objects and Relationships
Objects and Relationships
22. What is an object in salesforce?
Objects are database tables that allows us to store data specific to organization in salesforce. Each object contains fields and relationships.
23. What are all the different types of objects available in salesforce.
There are two main types of objects in salesforce. They are
Standard objects : The objects provided by salesforce is called standard objects. For example Leads, accounts, contacts opportunities, products, campaigns and cases
Custom Objects : the objects created by us are called custom objects. Example invoice__c , Employee__c and Payroll__c.
Note that all custom object names ends with __c.
There are other types like platform events ends with __e and external objects ends with __x
24. What are the different fields or data types available in Salesforce?
Text Area (long)
Text Area (Rich)
25. What are the different data types a standard record name field can have?
Standard field record name can have a data type of either auto number or text with a limit of 80 characters.
26. What is an external ID in salesforce? Which field type supports external IDs?
An External ID field is a custom field that has an External ID attribute, meaning that it contains a unique record identifier from a system outside of the salesforce.
It is used mainly while importing data.
Only the following custom field supports External IDs like Text, Number, Email and Auto-Number fields.
27. What are different relationships available in Salesforce?
There are 4 relationships available in Salesforce
Master-detail (one to many)
Lookup relationship (one to many)
Hierarchical Relationship (it is available only for user object)
External Lookup relationship
Apart from those, we can also create few more relationship on salesforce objects.
Many to many relationships (Using Junction object)
One to one relationship
28. What is Master-detail relationship?
It is a parent-child relationship between two objects in salesforce, and it is a tightly coupled relationship. Ex
When a master record is deleted then, its related detail record also gets deleted automatically.
The detail record automatically inherits the sharing and security settings of its master record.
Master field is mandatory on the detail record page.
Up to 2 allowed for an object.
The Owner field on the detail object or the child object is not available and it is automatically set as the owner of its related master or parent record.
Custom objects which are child in a master-detail relationship cannot have sharing rules, manual sharing, or queues, as these require the Owner field.
We can define master-detail relationships between two custom objects or between a standard object and a custom object. However, the standard object cannot be a child object with a custom object.
Also, we cannot create a master-detail relationship in which the User or Lead objects are the masters.
29. What is lookup relationship?
It is a parent-child relations ship between two objects in salesforce, it is loosely coupled relationship which means
When we delete parent record child record will not be deleted.
Child sharing is not dependent of the parent. It can have its own sharing
Parent field is not mandatory on child record page
Up to 25 allowed for an object
30. What are many to many relationships?
We can use master-detail relationships to model the many-to-many relationship between any two objects.
A many to many relationship allows each record of one object to be linked to multiple records from another object and vice versa.
You can create a many-to-many relationship using junction object.
31. What is a junction object?
A junction object is a custom object in between the two object for which we have to create a many to many relationships.
To create many-to-many relationship, simply create a custom junction object and create two master-detail relationship from the junction object to two object for which you want to create many to many relationship.
32. What is Hierarchical Relationship?
It is a special relationship on user object.
It creates a hierarchical lookup relationship between user object.
It allows user to use a lookup field to associate one user with another user record.
Ex: It can be used in a situation when we need to associate a manager to the user where manager is also another user.
33. What is external lookup relationship?
It is another new type of relationship introduced with salesforce connect.
This relationship can link to an external object.
Use a lookup relationship when the external data includes a column that identifies related Salesforce records by their 18-character IDs.
Use an external lookup relationship when the parent is an external object. Use an indirect lookup relationship when the external data doesn’t include Salesforce record IDs
34. What is one to one relationship?
It is used when we want to restrict a user to create only one child record for a parent record. I.e. only one parent will have one child record.
35. How can we achieve one to one relationship?
one to one relationship can be achieved in two ways, one is with configuration and other way is using trigger.
Method1 : Let’s say you want to create one to one relationship between account and contact. Then follow these steps
Step1: Create a custom field on contact object and name it parentID and make it unique.
Step2 : Create a workflow field update on contact and update the parentID field with accountid. If it is first record it will create the child record but if we create the second record then it will fail as the account id is not unique and is repeating for second time
Method 2 : Let’s say you want to create one to one relationship between account and contact then follow these steps
Step 1 : Create a field as a roll up summary field on account object and name it as Contact Count and use the count function while creating the roll up summary.
Step 2 : Create a trigger on contact object and check the roll up summary field which we created i.e. Contact count field and if it’s count is greater than zero the throw and error which says account cannot have more than one contact record.
36. What is self-relationship or self lookup?
Self-relationship or self-lookup is the lookup relationship we create on the same object.
Let’s say we create multiple accounts of the same company and we want to treat one account to be the parent Account of rest of the accounts of the same company then we can create a self relationship on the account objects and one account as parent account and rest of the accounts as child accounts.
37. How do we create relationship fields. Or From which object we create relationship fields?
First, identify which is parent object and which is child object for a particular requirement and We should always create relationship fields from child object.
38. Can we create Lookup relationship on an object which already have existing data?
Yes, we can.
39. Can we convert lookup relationship to Master detail relationship?
Yes, we can convert the lookup relationship to master detail relationship only if all the existing records should be populated with the value in parent field.
40. Can we create Master detail relationship on an object which already have existing data?
Yes. But it is not straight forward.
First, we have to create a lookup relationship then populate the values of parent value on all the record and then convert the relationship to master detail relationship.
41. What happens to the child record when a parent record is deleted?
In Master-detail relationship, when a parent record is deleted, then child record is automatically deleted. It is called a cascade delete.
In lookup relationship, even if the parent record is deleted, child record will not be deleted.
42. What is roll up summary? and Which type of relationship supports roll-up summary?