Many to Many Relationship in Salesforce.
Object relationships in Salesforce : In this Salesforce Tutorial we are going to learn about How to create Many to Many Relationship in Salesforce application and what is M:M Relationship.
What is Many to Many Relationship in Salesforce?
In Many to Many Relationship, one record of One object is linked to multiple records of another object and vice versa.
So how do we create Many -to-Many Relationship in Salesforce.com? We don’t have any Many-to-Many relationship field in Salesforce. We create Many-to-Many Relationship by creating two master-details relationship with a common Junction Object. Junction object is the key term used while creating Many to Many Relationship.
What is Junction Object in Salesforce?
In Salesforce, Junction Object is custom object which is use to link one instance of a record to many child records and many child records to on records equally.
Example:- The relationship between a company and a Customer is many to many relationship because a company can sell a product to multiple customers and a customer can purchase a product from multiple companies.
How to create Many to Many Relationship?
Let us learn how to create Many to Many Relationship in Salesforce. Before creating M:M relationship in salesforce, firstly we have to create a Junction Object.
Creating Junction Object in Salesforce.
- To create Junction Object in Salesforce go to Setup | Build | Create | Objects | New.
Click on new button to create new object. Enter Label name and Plural label as shown below.
- Click on Save button.
How to create Many to Many Relationship | M:M
In this salesforce tutorial we are going to create Many-to-Many Relationship between Invoice object and Pharma Product object. As already we have create junction object Pharma Product Invoice so establish Many-to-Many relationship between Pharma Product(parent Object) and Junction Object(Child Object), Invoice Object(parent Object) and Junction Object(Child Object).
As show above we have create to master Detail relationship in Child Object(Junction Object).
Here we have created a multiple invoices to one products and multiple products to one Invoice.
In Many-to-Many relationship(M:M) Invoice 1 is associated to multiple pharma products and one pharma product is associated to multiple invoice. In our next salesforce tutorial we are going to learn about Schema Builder.