+ Start a Discussion
Aniket SupeAniket Supe 

how many ways we can achieve one-to -one relationship in salesforce.

Deepthi BDeepthi B
Hello Aniket,

Let's consider the scenario that we would like to establish a One to One relationship between Accounts and Contacts..
Step 1:
Create a custom field on the Contact object. Make the field unique. This field would be used to hold the ID of the associated Account.

Step 2:
Create a Workflow rule on Contact. Update the custom field with the value of the associated Account ID.

Done!! you have established a one to one relationship between Account and Contacts...
When you try to add a second contact to the Account, the "unique" constraint would be violated and an error would be thrown.....
You can also check the link for other way to creating one to one relationship :

Hope this helps you!

Sumit Kumar Singh 9Sumit Kumar Singh 9
The possible ways are - 
1) Validation rule
2) Trigger

Sumit Kuamr Singh
salesforce mesalesforce me
hi check this once....

salesforce mesalesforce me
hi check this once....

Types of relationships that Salesforce provide
Master-detail relationship
LookupI assume that you are familiar with the difference between the two relations.
In this article we'll be using Master-detail relationship to implement one-to-one relationship.

Every department has only one manager
One manager can manage only one DepartmentGo to schema builder and create two objects Manager and Departments. Then create a Master-Detail relationship between the Department and manager.
Note: The relationship here is show by a line joining the two objects. The line diagram is quite intuitive. The multiple forks the end suggests the child objects.

User-added image

As of now we have created a relationship where a department can have multiple managers, but that's not what we are looking for; hold on

To make a this relationship one-to-one we will be using rollup summary concept.
Create a rollup summary field managerCount (count)  in departments, this will be auto populated depending upon the number of managers associated with that particular department.
 Create a validation rule in department object on managerCount field. Throw an error "department can be managed by only one manager"when the managerCount is greater that 1.