Now let's discuss about the look up relationship.
We already had an old view about the various relationships and says force right.
Look up M.D. tell many to many self hierarchy an external look up internal look up I'm along these relationships
First let's discuss about look up relationship look up relationship as a relationship between two objects
in sales force and the relationship type we know there are two relationship types that is one too many
are many too many right.
Look at relationship falls in the first category.
That is one too many.
So what does one too many wonder at card of one object would be related to multiple records of another
object.
That's a one to many relationship and look up relationship is a one to many relationship so let's take
a look at our data model and see which is the lookup relationship here.
The relationship between students and the extracurricular activities we have marked it as you look up
right.
And here are some of the other relationships I have marked with that master detail.
But again we say that some relationships are look up on some relationships some master detail.
We should also understand that in real time in real time project experience this master detail look
up all the other relationships customers the one who decides what kind of relationship exists between
two objects two entities because they know the business process right.
So we basically understand the business process from them and decide whether it has to be a lookup autumn
or strategic relationship.
And in this scenario let's consider the relationship between student and extracurricular activity is
a lookup relationship.
So let's define what does it look up relationship
look up a relationship as a relationship between a apparent object and a child object and how they are
related is what defines it in master dating relationship.
Child records should be associated with pattern however and look up.
It is optional.
Child Records need not be associated glove pattern.
So what does that mean.
The meaning is in the look of a relationship.
When we define two objects that are related to look up relationship it does not lose binding.
The relationship is optional it does not.
That child records always have to be associated to the parent.
No that is a master detailed relationship in lieu of relationship.
It is optional that can be often records existing in the system.
It does not that tie all the child records are associated look bad and correct like some may some may
not.
So that is a basic characteristic of the look up relationship.
So look up the relationship is optional that has master detail is more tightly bonded.
It is mandatory the next feature this cascade a deletion.
So in Monster detail that is Cascade regard deletion however and look up that is no cascade or deletion.
So when we talk about cascade or deletion what does cascade or deletion.
It means then apparent regard regardless deleted whether the child records are deleted off not that
is called this cascade or deletion in Cascade regard deletion the child record get deleted.
Meaning in the master detailed relationship then a pattern card is deleted all its related.
Child records are also deleted.
How valid and look up.
That is not the scenario but we have some control we will work this cascade record deletion which we'll
be discussing later.
However the general feature is that monster detail allows cascade record deletion and look up does not
allow cascade or deletion the next characteristic as standard objects that cannot be detail objects
that does a child object.
And here there are no such restrictions meaning in look up relationship the bad object and the child
object can be a standard object not a custom object.
There are no such restrictions out here.
However in monster they did relationship though that may not be any restrictions for the patent object
when it comes to the child object that does that detail object standard objects cannot be a detail object.
All right.
There are no restrictions on the patent object though but we have to note this particular restriction
in musty detail the next characteristic is then above it create a massive detailed relationship.
The mustard agent relationship field is required on the page layout of the detail object.
However you know this is a loose bonding so it does not necessarily require it.
And then we create master detailed relationship.
We can create roll up somebody feels expert on the patent object which will basically do a summary of
the records of the detail object and populated on the and object however we cannot establish at all
up somebody fields using lookup relationship and being a guide wanting the detail object the detailed
record basically completely depends on the master of the court for all its sharing and security settings.
However it is independent the parent card and the child art are independent in their sharing and security
settings.
So from this we understand that master detail is more of a tied one thing.
However look up is more of a loose bonding and now that we have understood the basic characteristics
and differences between a master detail and lookup relationship.
Let's go ahead and create a look of relationship and sales force.
So what in our data model the example that we have taken as a student and extracurricular activity.
So when we take student an extracurricular activity the parent object will be extracurriculars not the
child object would be students meaning in one extracurricular activity there can be multiple students
enrolled.
However one student can enroll him himself or herself in only one extracurricular activity.
All right.
So this is how students and extracurricular activities are related.
Now you can ask me why one student can be in more than one executive activity right.
But this is how the data model is and this is how we have assumed.
Maybe because that particular educational institution operate that way you know maybe they allow a student
to have only one extracurricular activity.
All right.
So that's where as previously mentioned it all depends on the business how they how they have their
business process.
All right.
So in our data model the assumption is one student can have only one extracurricular activity.
However there can be multiple students enrolled in a particular extracurricular activity.
So this is our hook up relationship.
Now let's replicate this relationship and says force so let's jump on the census application.
Step 1 would be to go to the child object in our scenario of the child object students so go to students
go to the object definition page and let's create a relationship feed.
So custom fields and relationships we have only two fields already in there.
Let's create a new relationship feed.
So he'd then you button select the lookup relationship hit next and it is related to meaning just the
parent object and the parent object in our scenario is extracurricular hit next fill in the details
while filling in the details.
Note these options that we have out here the child relationship name I have just let it out as students
but then we have the other options that are available while creating this lookup relationship.
So what does that required always require a value in this field in order to save a record.
This is pretty similar to the required option that we have for the other fields but if you choose this
option among the two options only do not allow deletion of the lookup record and only that option is
available.
So what does this second option.
The second option is that.
So what happens then.
Look up at a card get deleted meaning when a pattern record gets deleted.
What should happen to the child records so that all options that are available.
The first option is that clear the value of this field.
You can't choose this option if you make this feel required.
Meaning when a parent at a card is deleted.
The association between the parent and the child is also deleted.
That's the meaning of clearing the value of this field however if you make it required this option is
not available.
You know that makes logical sense right because it is required.
So this option doesn't make any sense yet.
And what does the second option do not allow deletion of the lookup record.
That's part of the lookup relationship meaning if you choose this option it will not let you delete
the parent card if it does godchild child records associated with it.
The system would say that there are already records of electric.
So you can delete does it at though I'm not explicitly showing you like you know what the error message
or the wanting message that is displayed and says force.
I highly highly recommend you to replicate this scenario and see the error message.
So you have a better learning experience.
So among all these you'll let me stay with the default.
Let me not make it required and let me choose are clear the value of this field.
And there is also another option which is called as lookup filters.
Let's discuss in detail about this look up filters later for the time being.
Once you are done giving all the values hit next and save that at card
perfect.
So now we are done creating our first look up relationship and that is between students and extracurricular
activities.
So now let's see how this particular relationship behaves in the UI.
So let me create a new student record.
Fill in the details.
And now we can see a new relationship field that is the look of a relationship feel extracurricular
activity and we have two extracurricular activities.
All right.
So now that a new student record is created and that particular student has got this extracurricular
activity assigned to him.
So this is all we create and look up a relationship.
And this is in the child object right.
Student does a child object and one student can have only one extracurricular activity.
However if you drill down to the parent object that is extra curricular activities you will see a new
related list created or here.
Meaning this extracurricular activity has got these many students enrolled.
Okay.
However now we have only one student.
So let me create one more student Ricard and associate that student.
All right.
So now that what we see here is this extracurricular activity that is a community service activity has
got those students enrolled in that meaning one parent God has got to child.
Student Records associated to it.
However one student a guard can have only one parent or associate degree with meaning one student can
have only one extracurricular activity associated with.
So this is the overall concept of lookup relationship.