We have discussed in detail about a look up and master detailed relationship and what falls and the
one to many category.
So now let's understand what is a Many to Many relationship and how we can implement that in sales force
many to many relationship as the name says he does so many too many meaning one direct card from one
object that is apparent object can be related to multiple records of the child object.
Similarly one record of the child object can be related to multiple records of the parent object.
So that does the concept of many to many.
So let's consider our data model in our data model.
The relationship between courses and students.
Let's consider this one course will have multiple students enrolled in that course at the same time.
One student will have multiple courses and draw the right.
That is a very common scenario.
So in this scenario the relationship between courses and students forms many too many meaning one class
can have multiple students and one student can have multiple courses but effect.
So how do we recreate this a Many to Many relationship in force for a one to many.
We saw that was look up relationship master detailed relationship so we were able to create that.
However that is no direct to many to many relationship assets and since force.
Instead we can achieve the behavior of many to many relationship using the junction object so what does
a junction object.
You jumped junction object is basically a custom object that we create to replicate the scenario off
Many to Many relationship.
So this junction object would serve as the child object for both these two parent objects.
So in other scenario for creating a Many to Many relationship between courses and students will be creating
a junction object.
In this scenario it would be enrolments and this enrolments junction object will soar as the child object
for both courses and students.
So basically a Many to Many relationship comprises of two unsteady deal relationships among that for
master detail one one of the objects will serve as the parent object and the child object would be the
junction object.
In this case enrolments and for master detail to the other object would serve as the parent object that
the students and the junction object would serve as that child object.
In our case enrolments.
So a first step would be to create this junction object that is the end elements object and then to
define these two more DIL relationships.
So once we create these to master these relationships automatically in many to many relationship will
be formed between the two objects that is courses and students.
So let's jump into sales force and first create deep junction object go to the sales for Xu Lai let's
first create a junction object junction object.
As I mentioned it is another custom object but just that it serves as a child object for both the master
detailed relationships.
So fill in all the details.
Just know that always have a record name and then choose the data type to be auto number.
That way it works best for the junction object.
Once done safe and perfect.
Now that our junction object is created that is the elements object.
Step two is to create the master detail relationships.
As I mentioned that our tool master detailed relationships to be created and for both the master detailed
relationships.
This junction object would serve as the child object so first let's create a first master detailed relationship.
In this scenario courses would be the padding object
fill in the details
and then also choose the related list label have you wanted to be let me say student enrolments
and then see the relationship.
So the first master detailed relationship field is created with apparent parent object s courses.
Now let me create my second master little relationship
and this time the and object would be students so sick students
fill in the details
also choose the related list label I have made it a course enrollments.
I feel that makes sense.
Here hit the save button.
Perfect.
So our second relationship is also created that is between students and this junction object enjoyment.
So now basically what we have done is we have created to master detailed relationships.
However then we create a junction object with these two master data relationship it automatically forms
sent many to many relationship and sales force.
Say for example I have courses so when I'm not and never get to a particular course I can't see student
enrolments here right.
No there are no students as such at all.
However this is the letter list that he'll tell you all the students who are all enrolled in this particular
course similarly.
Then I go to the students object click on any particular record.
See that article essential elements meaning this student has got these many courses enrolled for him
now let me try to create a new employment for the student click on new enrollment so automatically the
student this map and then we have to pick the goals say for example marketing management so this student
has good marketing management goals assigned to him.
Meanwhile we can also add like other courses for this particular student similarly if we go to courses
marketing management course in fact we have only one record in courses object for marketing management
course.
He had the list of students are listed out here so there is only one student as such enrolled in the
schools now but this is a Many to Many relationship.
So many students can be enrolled in this particular course.
So this is the concept of many to many relationship.
One guard off one object can be linked to multiple records of another object.
Similarly one I got off the other object can be linked to multiple records of the first object.
So this is the concept of many to many relationship and how we implement that.
Since force.