+ Start a Discussion
Gaurav AgnihotriGaurav Agnihotri 

Master detail relationship

I am preparing for salesforce developer I certification and ran into a question:
 
A Developer wants to create a custom object to track Customer Invoices.
How should Invoices and Accounts be related to relate that all invoices are visible to everyone with access to the Account?
Of course it’s going to be a master detail relationship
There are two options:
The Invoice should have master detail relationship to the Account
 The Account should have master detail relationship to the Invoice.I want to know what is the difference between the two. They both look similar.
Can someone please help
Gaurav AgnihotriGaurav Agnihotri
Two options are 
  1. The Invoice should have master detail relationship to the Account
  2.  The Account should have master detail relationship to the Invoice.

Apologize they were not clear in the question

 
Tarun Khatri (TK)Tarun Khatri (TK)
Hello Gaurav,

Here Account is standard object. Standard Objects can always be on Master side. Hence, in your case, Account will be on Master side and Invoice will be on Detail side.

-Thanks,
TK
Gaurav AgnihotriGaurav Agnihotri
Of couse you create a master detail relationship onthe invoice  object and choose Account as parent. 
reymagdaongreymagdaong
1. The Invoice should have master detail relationship to the Account
 2. The Account should have master detail relationship to the Invoice.
I want to know what is the difference between the two. They both look similar.
Can someone please help


I think the correct answer on this is the 'The invoice should have master detail relationship to the Account', sine you need to create the relationship inside the invoice object.

As for the difference, option 1 means, that the account can have zero to many invoices. and you cannot have an invoice without an account existing.
option 2 means, that a single invoice can have zero to many accounts, which doesn't make sense for rerequirement.

hope this helps.  
 
Deepthi BDeepthi B
Hello Gaurav,
The Master Detail relationship can exist within Standard and Custom SObjects, but the Master should be the Standard Sobject. We cannot create a Standard Object as child to a Custom Sobject. This can happen with Lookup Relationship.
  • The Invoice should have master detail relationship to the Account --- The invoice(child) is related to Account(parent) stating that invoice couldnt be created without addressing the associated Account 
  • The Account should have master detail relationship to the Invoice --- This is not possible because it states like Account is having MD relationship to custom object. 
Hope this helps you!
Regards,
Deepthi