Tag: Many to Many Relationship.

Salesforce Relationships Overview

Salesforce Relationships Overview

Salesforce Relationships allows user to build some powerful and useful queries to fetch data. In Force.com data can be abstracted by creating simply relationships between objects. Relationships allows user to build some powerful and useful queries to fetch data. A relationship field in salesforce.com stores the parent record ID in a pre-defined relationship. Salesforce Relationships are of three types, they are lookup relationship, master-detail relationship and many to many relationship. For each relationship user can specify up to 5 levels in a query.

Salesforce Relationships – Types.

  1. Lookup Relationship.
  2. Master-Detail Relationship.
  3. Many to Many Relationship.

Lookup Relationship in Salesforce.

Lookup relationship creates a simple (foreign key) relationship that links one object to another object. These can be used to create one-to-one and one-to-many relationships. When displaying records in the salesforce.com UI, the platform generates a link to the related record allowing you to navigate from record to related record.

Master-Detail Relationship in Salesforce.

A master-detail relationship can be created between “parent object” and a “child object“. The two object will be the parent, or “master” object and its child, or “detail” object. Parent Object will also called as Master Object and Child Object will be called as Detail Object.

  • Detail objects cannot created without a master object once created, Master-Detail Relationship cannot be change
  •  Detail objects inherit the security from the master object and deletes cascade from the master to the detail objects.

Many-to-Many Relationship in Salesforce.

Many-to-Many Relationship in Salesforce can be created using a Junction object. Here a junction object is used to create Many-to-Many Relationships.

What is Junction Object?

In this case salesforce.com uses an intermediate object, which they refer to as a junction object. To implement a junction object, simply create a custom object and add two master-detail relationship. An issue with junction objects involves usability. When you add the junction object as a related list on a page layout, the user may have to make an extra series of clicks to create new records or navigate back to the original record. This can be somewhat confusing from a UI perspective.”