Lookup Vs. Master-Detail: The Real Difference

I have a confession:

For a long time, I never really understood the difference between a “Lookup” field and the “Master-Detail” lookup field. Whenever I needed to create a field that referenced another object, I would read over the Salesforce explanation and then randomly chose one field.

Lookup...or...Master-Detail
Lookup…or…Master-Detail

Over time I discovered various nuances, but the real “Aha!” moment was when I really, really got it.

Simply put, a Lookup field connects 2 objects to each other. For example, a customer can be linked to a store they frequently shop at. This relationship, while helpful to know, does not intricately bind the customer and store to each other. If the store closes down, the customer will still be around and shopping – but in another store. The relationship ends with no affect on either end.

Let’s use a Parent-Child analogy to explain the Master-Detail relationship:

Parent & Child
Parent & Child Relationship

MasterDetail is like a human parent child relationship. Just like a child can not exist without a parent, a Detail (child) record MUST have a Master (parent) record. This strong relationship makes the relationship field required on all records. As well, the child record inherits the same ownership and security (think DNA) as the parent record. Should the Master record be deleted, all the Detail records will be deleted with it (think of going back in a time machine – before the parent was born = no parent, no children).

Similarly, going back to our store, the inventory can have a MasterDetail relationship to the store. If the store closes down, the inventory has no use and and can be deleted. You might chose to send the merchandise to another store which would be called Reparenting in Salesforce (sorry, not detailing that here!).

Hope this helps you navigate object relationships in Salesforce!

Wishing you a wonderful, relaxing, long weekend,
Rachel

One thought on “Lookup Vs. Master-Detail: The Real Difference

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s