Lookup relationship And Master-Detail relationship
A lookup relationship is an object relationship method. A field that uses a lookup method gets the value of a field from another Object, is called a lookup method.
For example, An employee record that contains a field named Emp contact. Which is in the lookup relationship with the contact object, so when the user clicks on the Emp contact field, it provides available contact information. Users can choose among the available contacts.
Field & relationships → New custom Field → Lookup Relationship → Choose related Object → save.
- Create a new field and choose lookup as field type/data type.
Choose the Related object for the field. Here contact object is chosen.
After saving the field, when the new record is created the available contact details appear on the Emp contact field as a dropdown.
The master-detail relationship is like lookup but the child object depends on the master-detail object so the master-detail can be used to control the details of the record since the record details are removed when the Master detail is deleted.
Field & relationships → New custom Field → Master-detail Relationship → Choose related Object → save.
Create a new field and choose Master-detail as the field type/data type.
Choose the Related object for the field. Here contact Account object is chosen
When the new record is created, the available account details appear on the Employee account details as a dropdown field.
Difference between Lookup and Master-detail:
The key difference between lookup and master-detail is when the lookup object details are deleted the child object remains, with that specific field blank.
However, deleting a master record deletes all the record details.
Note: You cannot create a new Master-Detail relationship on an existing custom object if records already exist. You must first create a Lookup relationship, populate the lookup field with data in all records, and then change the relationship type to Master Detail.