function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
saleforce beesaleforce bee 

Relationships in

Please explain the practical scenario where we can use the below relationships in


secondly, I heard only about Look up and master details relationship that would be used for forming the one to many relationship, dont know how to implement One to One relationship and Many to many relationship



One to One relationship

One to many relationship

Many to many relationship



1:1 relationships: The only example I have of this is the PersonAccount feature, where one contact relates to exactly one account, and vice versa. Any other 1:1 relationships made in the platform require supporting code (triggers) to enforce that this is true.


1:n relationships: This is the predominant relationship in One account can have many contacts, many opportunities, many cases, many activities, and so on. These are formed by creating a lookup relationship or a master-detail relationship from one object to another. The sub-types of this relationship determine their attributes. A lookup relationship will set its value to null when the related record is deleted, and is not required by the system to save a record. The master-detail relationship requires a value to save a new record, can never be changed once the record is created, and will cause the child record to be deleted when its parent is deleted (and undeleted when the parent is restored).


n:n relationships: Any time you need to link many records to many other records in a sort of "spider web" design, you have a many-to-many relationship. This always involves an intermediary object with two master-detail relationships. Examples of this include OpportunityContactRole, AccountContactRole, PricebookEntry, AccountTeamMember, etc. Each master-detail relationship behaves the same as a normal master-detail, with the additional stipulation that either parent record's deletion will also delete the child record, both values are required on create, and neither value may be modified once committed to the database.


Edit: clarification on n:n relationships.





This type of relationship links two objects together, but it has no effect on record ownership or security, and the lookup relationship field is not required in the page layout.


Lookup relationships are loosely coupled relationships.

Lookup relationships have the following properties:



  • • Link two different objects.
  • •Link an object with itself (with the exception of the user object). For example, you may want to link a   custom object called “Bug” with itself to show how two different bugs are related to the same problem.
  • •The two objects records have no relationship dependencies on each other
  • • The lookup field value is optional
  • • Updating and deleting the child record has no effect on the parent




This type of relationship closely links objects together such that the master record controls certain behaviors of the detail and subdetail record. For example, you can define a two-object master-detail relationship, such as Account—Expense Report, that extend the relationship to subdetail records, such as Account—Expense Report—Expense Line Item. You can then perform operations across the master—detail—subdetail relationship.


Master-Detail relationships are more tightly coupled relationships.


Master-Detail relationships have the following properties.


• When two objects are in Master-Detail relationship (also called master-child relationship) the detail/child follows the master.


• The ownership of the child record is given to the master objects owner. The child does not have separate owner.


• The detail inherits the sharing, security settings as well as the look and feel of the master.


• A master record is always required for storing the child record.While creating a Master-Detail relationship; there must be absolutely no record of the object. If there are some records, create a lookup instead. Fill the lookup fields of all the records and then convert it into a Master-Detail.


• If the master record is deleted, the child record is also deleted.


• In a Master-Detail relationship between a standard object and custom object,the custom object will always be the detail record.


• An object can maximum of two master objects. In cases of multiple objects,both the masters are required. If one master is deleted, the child object gets deleted immediately.


• A Master-Detail can be multiple level deep, parent-child-grand-children.


Special relationships

Using the Master-Detail and lookup relationships we can create two more types of relationships:


• Self-relationship:

When an object has a lookup with itself, it is a self-relationship. A self relationship creates a tree diagram of the objects. For example, the account has a lookup on himself, called Parent Account.

On the user object a special self-relationship called the hierarchical relationship helps create superior roles such as supervisor, manager on user object. The hierarchical relationship is a self-relationship of the user object.


• Many-to-many relationships:

 A many-to-many relationship between two objects is a relationship in which an object A can have many child objects B, while object B can have multiple child objects


A real world example is the relationship between student and teacher. A student can be taught by multiple teachers while a teacher can teach multiple students. Normally

Lookup and master child relationships are 1:N, however, a small trick can create a many-to-many relationship on The trick to create the master child object

Is as follows:


• First create a junction object, which contains a link to two master-objects

• Create the name field as auto-number in the junction object some properties of the junction objects are as follows.

• The junction object identifies the first master as the primary master. It uses the look and feel of the primary master.

• If any master record is deleted, the junction record is automatically deleted.


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

saleforce beesaleforce bee

In cases of multiple objects,both the masters are required. If one master is deleted, the child object gets deleted immediately.

>> here how another master can live without child object ? Could you pls brief on this

Dnyaneshwar ParkheDnyaneshwar Parkhe
Relationships Among Objects