The next relationship type that we are going to discuss about is self relationship or self.
Look up a relationship.
So what does it say.
Relationship means ask the name says creating a relationship from an object to itself it basically look
up to the same object.
So what actually happens in a regular lookup relationship which we have been creating all these days
in a regular lookup relationship.
The child Ricard look up to a parent a card from a different object.
So if you see our data model this is an example of a lookup relationship.
The relationship between students and extracurricular activity.
So then we create a student record and then we attach to extracurricular activity.
We basically look up to extracurricular activity which is a different object.
So that does not look up a relationship but unsafe look up relationship.
Then we create a safe look up relationship he'd basically look up to itself meaning the same object.
So one good example that we can give for our scenario is a train of this train of relationship feel
we can replicate the DSA self look up a relationship and thus we are going to create it and they instruct
us object.
So what does is instruct us object.
It basically holds the details of all the instructors working in that educational institution.
So that design instructor object.
So let's don't all the instructors however the business process is such that the instructor does work
as a trainees for a certain period of time and then they are promoted to instructors.
So trainees are also instructors but just that they are in that training period and after that period
of time they get promoted as instructors.
So basically the training details are also stored and they instruct our table.
So then you'll say when you create a trainee Ricard we look up to a trainer who is an instructor.
So it basically looks up to itself so that this call doesn't look up self relationship in real time
scenarios we can give many examples for this.
Say for example accounts and then we have parent accounts so parent to Gonzales again accounts and they
are all grouped in that same entity and as some other example we can think officer say for example we
are having the story details stores OK and in the let a store entity we have some of the stores which
serve as headquarters so you know the headquarters becomes a parent entity.
But however the stores the headquarters everything is grouped under the same stores entity.
So this is a concept of self.
Look up a relationship.
Now let's quickly create one in our salesforce application.
We are going to use a instructor's object so go to the instructor's object and create a new relationship
feel.
And as the name says it is a safe look up.
So it is a look up a relationship that we are going to create
create a new feel and that could be a relationship field lookup relationship and then related to gender
the to the parent object.
And here it is a self relationship meaning it relates to itself.
So here again will be choosing the instructor object
fill in the details here.
Then let's say if this relationship feet
perfect our self lookup relationship is created.
Now let's create a instructor Ricard fill in the details.
I am creating a trainee at a card here.
So this Sara Johnson this regard this instructor as a trainee.
So click the check box and then choose that department.
Let me say informatics and now fill in the trainer.
So the train that it will be basically all the instructors again
so this is how we create a safe relationship.
So for this particular construct that I caught Sara Johnson who is a trainee now the V.C. at a trainees
a related list basically have renamed a related list to be trainees.
So it does more more more makes sense here so that I know trainees as such.
The trainer this bias so he figured to buy that card.
And the check box is not checked because Baez is not a trainee buys is a trainer basically.
And here in the related list of trainees we see the list of all trainees who are trained by this particular
instructor.
And here now we have only one right guard Sara Johnson.
So this is how we create a safe look up relationship.
And this is a very common scenario in real time projects and there are a couple of considerations that
we need to have in mind while creating and using this safe look up relationship.
The first consideration is that you have a card can't look up to itself makes sense right.
Say for example this particular card bias bias cannot have the training as bias.
Right.
That that wouldn't make sense.
So that is called as a red card.
Can't look up to itself however indirectly it can happen.
What does that meaning the trainee here is.
SARA JOHNSON Right so Bynes is a trainer and Sara Johnson is the trainee and the other way also works
fine meaning Sara Johnson can train Miles.
Basically they train each other that is possible.
Let me quickly edit and show you
so here why is strange Sara Johnson and Sara Johnson trains Bice.
This may or may not work logically that completely depends on the business.
Some educational institutions may have that working model.
However some institutions may not.
However what we are trying to infer here is that it is possible technically in Salesforce however the
implementation totally depends on the business process and how they wanted but technically this possible
and while implementing it based on the business we can change it accordingly.
Say for example when we consider this example train us the business may say that only certain car types
can be trainers or only certain instructors with certain positions can can be trainers of a certain
number of experienced can be trained as you know that totally depends on the business and that differs
from business to business.
So what we are trying to infer here is that it is possible in sales force.
However when it comes to the implementation side you have to basically follow the business process from
the customer's so this is all about self relationship.