Two Types of One-To-Many Relationships
Master-Detail
- The owner of master record automatically owns all associated detail records.
- Security controls for the master record control the detail record.
- A detail record must be linked to a master record in order to save the record (e.g. you must link an opportunity to account to save the opportunity).
- Only one level deep a detail object cannot also be a master object. Please vote to remove this limitation:
I have created two Objects in order to show how to create master-detail relationship.
Object2 Named: Child Object
Go to Child Object and Click on New button
|
Any questions please do write back. :)
Master-detail relationship also know as Parent-child relationship.
- Child row not automatically deleted when a parent row is deleted
- No inherited sharing.
- 25 lookup relation relationships allowed per object.
- Lookup field on child not necessarily required.
- Add Lookup Relationship
- Master controls the behaviour of detail Object, if the master is deleted,all its child records will be deleted.[One of the difference between lookup and master-detail relationship]Now we would be creating the M-D relationshipObject1 Named: Master ObjectWe have two objects ready. Time to create a custom field with data type [Master-Detail Relationship].Now select data-type as 'Master-Detail Relationship'Next Step to mention the master object name , In this case I have used as 'MasterObject'Mention the Field label nameClick Next in Step 4 and 5 , as its read only page and you will not able to edit anythingNow final step 6 , you need to choose whether you want to show the related list on the master record or notNow Save.Our Master-Detail relationship is ready , create a new record on Child object and you will find a mandatory lookup, that's your Master Object reference.Hope you have enjoyed! remember don't forget to do it practical and share your demo screen with me.
Lookup Relationship
- This type of relationship links two objects together, but has no effect on deletion or security. Unlike master-detail fields, lookup fields are not automatically required. When you define a lookup relationship, data from one object can appear as a custom related list on page layouts for the other object. See the Salesforce online help for details.