The next a relationship type that we are going to discuss about is master detailed relationship among
the different type of relationships available and sets forth.
We've already discussed about look up a relationship.
Now let's understand what is master detailed relationship.
We know that our two relationship types one to many and many to many among that look up false in the
fluff category.
That is one too many similarly monster detail also false in the first category.
That is one too many.
So both to look up and master detail falls into one too many category meaning one direct guide of one
object he is related to multiple records of the other object so bored to look up and study did false
in this one too many category.
However they are different from each other with their characteristics
let's understand the difference between them master detail and he look up so master detail childlike
guards should be associated to a pattern because it does are tied bonding look up is basically a loose
bonding meaning not all child Gaza associated parents you a child.
There may be scenarios but in child records are not associated with it parent class and come into cascade
regard deletion that happens in master detail that it doesn't happen and look up.
So when a lot of master that card is deleted all its related detail records are also deleted.
And the other important difference between master detail and look up is about the detail object that
cause the child object in master detailed relationship the child object cannot be a standard object.
So for any standard object you cannot create a master detailed relationship have other than I'm also
trust actions.
Look up a relationship and the master key to the relationship field that is required on the page layout.
It is not required on the lookup roll up somebody fields can be created in master detailed relationship
that it cannot be established in look up relationship and in lost or detailed relationships the detailed
recorded inherits the sharing and security settings of its parent record.
However in lookup relationship are independent they have no effect on the security.
Perfect.
So now that we know the difference between master detail and look up and what hold the basic characteristics
of a master data relationship let's go ahead and take a look at our data model and see which is a master
detailed relationship here.
Basically this one that is the relationship between the instructor and a department meaning every instructor
is associated to our department.
However one department will have many instructors obviously.
Right.
So this is the relationship between the instructor and the department.
Now let's replicate this relationship in sense.
We'll see what so open Salesforce application navigate to the child object in our scenario the child
objects instruct us so go to instruct us and let's create a new relationship.
So go to the object definition Page
let me create a new relationship feel we know the relationship field is always created on the detail
object that does the child object and here the relationship pipe would be master detail so select master
detailed relationship and now a choose the parent object to it and in our case the parent object will
be departments choose department hit next fill in the details also life filling in the details nor do
the options that we have while creating this relationship.
Few remember while creating a look up a relationship we had options like whether we want to make that
feel the required on the order to clear the value of the feel and then the pattern record gets deleted.
Also how do recorded parent track or deletion.
Whether the system should love it or not.
So those were the options available to us why create didn't look up a relationship.
However in my study DIL relationship there is an option for sharing setting so this option this decides
what is the minimum access level that is required on the master required to create it on a daily deal
related a detailed records meaning one of the users who have at least a read access to the master record
to create a read or delete that related detailed records are users with read write access to the master
record to create it on daily death related detailed records.
So does are depends on the business process in Hollywood as defined so based on that choose that eat
only option are the read write option and also that is an option for parenting.
Re parenting then the child records can be repatriated to the other parent records after the great and
as a generally see all these options.
Please do try out and see how good behaves in the you UI so that we can enhance our learning experience
and look up filter.
Lee discussed in detail about this a look up filtered in the previous video so we have that option off
of having the idea through that logic and then it actually applies to the cards and finally once we
define everything we can enable the filter to take its action.
Right.
Similarly that lookup filter option is available here and lastly Dallas.
But so once they are done configuring all these let's go ahead and save the relationship.
Perfect.
So what the system saves the system saying that you cannot create a master detailed relationship on
an existing custom object if a records already exist so that object that be trying to create this more
strategic relationship.
We are trying to created in the instructor's object right.
So any instructor's object.
We already have data.
So in an object which already has data it is not possible for us to create a new monster the relationship.
So there are two two ways to work around this.
One is to delete the day Diana instruct us object and then create it fresh.
The second option would be to create a look up a relationship and then to convert it to mustard Dill
relationship.
The second option is the practical one and that does the most logical one because in real time in real
time projects it is absolutely not possible to delete the records just for creating a hostage in a relationship.
So why do we generally do as we create a lookup relationship and then convert it to my study.
So now let's go ahead and create a look up relationship however had in mind that creating a monster
detailed relationship in objects that there is no data that could be simple and straightforward.
However this object having data we have to do a walk around of creating value.
So go to the object and create to look up a relationship.
Now we are done creating of a lookup relationship field.
So let me go and change the feel type from look up to my study test.
So did the field hit change field type and there it would have just the other option that is master
detailed relationship hit next and then it is giving us the same options what do we have while creating
a master detailed relationship he'd save.
Perfect.
So now that we have converged I would look up the master design relationship.
This is actually a walk around as I mentioned before the straight way would be to create a master detailed
relationship and that would happen on objects when there is no data.
However this is a walk around with it and when an object has guard data you create to look up relationship
populate all that records with the data and then convert it to mustard.
Tip.