Types of Relation ships in Salesforce:
There are 3 types of Relation ships in Salesforce
1. Self Relation ship
2. One - to - Many Relation ship
i) Master - Detail Relation ship
ii) Look up Relation ship
3. Many - to - Many Relation ship
1. Self Relationship: If we are creating relation ship with the same object then that relationship is called as "Self Relation ship".
Ex: Student - custom object
i) Set up -> Build -> Create -> Objects -> Click on "Student" object -> Go to "Custom Fields & Relationship" section -> Click on "New"
ii) Select data type as "Look up Relationship " -> Select the object as "Student" and click on "Next"
iii) Finally "Save" it
2. One - to - Many Relationship:
Master - Detail Relationship:
i) If we delete record in the master object the corresponding child records will also deleted.
ii) The detail(child) record will not have the standard "Owner field" to change the owner of that record.
iii) The owner of the "Master" record will be the owner of "Detail" record.
iv) Sharing settings of "Master" object will be applicable to the "Detail" Object.
v) The master field is "Mandatory" field. With out giving value if we are trying to save the record,it will show the error message.
Eg: DepartmentNew - Custom Object (Master Object)
EmployeeNew - Custom object (Detail Object)
Roll up Summary Field:
This data type is enabled only for the "Master Object"
If any custom object is acting as "Master object" to any other custom object. Only for that "Master object" this data type is "Enabled".
Roll summary field is a read only field. This is enable only for master object. With the help of roll up summary field we can know the count,sum,min & max of related list records.
count
max
min
sum
Only for the "DepartmentNew" object this "Roll up summary field" will be enabled.
Set up -> Build -> Create -> objects -> Click on the Master object(Eg:Deparment MD) -> Custom fields & Relation ship section -> New -> Select "Roll up summary field" -> Next -> Select object name in the "Summarized object" -> Choose the function -> Next -> Save.
Limitations of Master Detail Relation:
For one custom object, we can create only 2 Master-Detail relation ship with objects.
For one custom object, we can create 20 look up relation ship with other object.
i) 2 Master - details relation ship with other objects
ii) 25 Look up relation ship with other objects.
Look Up Relationship:
i) This field is "Optional" field. With out giving value also we can save the record. It wont display the error message.
3. Many - to - Many Relationship:
To acheive many - to - many relation ship between two objects we have to create one intermediate object that object called as "Junction object".
Steps to Many - to - Many Relationship:
i) Students
ii) Courses
Want to create Many - to - Many Relation ship between students and courses at that we need an intermediate object to achieve this relation ship. That intermediate object will call as "Junction Object".
iii) Studying - Custom object (Through this acheiving Many-to-Many R.S between Students & Courses)
i) set up -> Build -> Create -> Objects -> Click on "Studying" object -> Click "New" in Custom Fields & Relationship section -> Select Master-Detail Relation ship data type -> Next -> Select "Students" in the drop down -> Next -> Next -> Save
ii) set up -> Build -> Create -> Objects -> Click on "Studying" object -> Click "New" in Custom Fields & Relationship section -> Select Master-Detail Relation ship data type -> Next -> Select "Courses" in the drop down -> Next -> Next -> Save
2 fields:
i) Master - detail relation ship (Student) - Primary relation ship
ii) Master - detail relation ship ( Courses) - Secondary Relation ship
There are 3 types of Relation ships in Salesforce
1. Self Relation ship
2. One - to - Many Relation ship
i) Master - Detail Relation ship
ii) Look up Relation ship
3. Many - to - Many Relation ship
1. Self Relationship: If we are creating relation ship with the same object then that relationship is called as "Self Relation ship".
Ex: Student - custom object
i) Set up -> Build -> Create -> Objects -> Click on "Student" object -> Go to "Custom Fields & Relationship" section -> Click on "New"
ii) Select data type as "Look up Relationship " -> Select the object as "Student" and click on "Next"
iii) Finally "Save" it
2. One - to - Many Relationship:
Master - Detail Relationship:
i) If we delete record in the master object the corresponding child records will also deleted.
ii) The detail(child) record will not have the standard "Owner field" to change the owner of that record.
iii) The owner of the "Master" record will be the owner of "Detail" record.
iv) Sharing settings of "Master" object will be applicable to the "Detail" Object.
v) The master field is "Mandatory" field. With out giving value if we are trying to save the record,it will show the error message.
Eg: DepartmentNew - Custom Object (Master Object)
EmployeeNew - Custom object (Detail Object)
Roll up Summary Field:
This data type is enabled only for the "Master Object"
If any custom object is acting as "Master object" to any other custom object. Only for that "Master object" this data type is "Enabled".
Roll summary field is a read only field. This is enable only for master object. With the help of roll up summary field we can know the count,sum,min & max of related list records.
count
max
min
sum
Only for the "DepartmentNew" object this "Roll up summary field" will be enabled.
Set up -> Build -> Create -> objects -> Click on the Master object(Eg:Deparment MD) -> Custom fields & Relation ship section -> New -> Select "Roll up summary field" -> Next -> Select object name in the "Summarized object" -> Choose the function -> Next -> Save.
Limitations of Master Detail Relation:
For one custom object, we can create only 2 Master-Detail relation ship with objects.
For one custom object, we can create 20 look up relation ship with other object.
i) 2 Master - details relation ship with other objects
ii) 25 Look up relation ship with other objects.
Look Up Relationship:
i) This field is "Optional" field. With out giving value also we can save the record. It wont display the error message.
3. Many - to - Many Relationship:
To acheive many - to - many relation ship between two objects we have to create one intermediate object that object called as "Junction object".
Steps to Many - to - Many Relationship:
i) Students
ii) Courses
Want to create Many - to - Many Relation ship between students and courses at that we need an intermediate object to achieve this relation ship. That intermediate object will call as "Junction Object".
iii) Studying - Custom object (Through this acheiving Many-to-Many R.S between Students & Courses)
i) set up -> Build -> Create -> Objects -> Click on "Studying" object -> Click "New" in Custom Fields & Relationship section -> Select Master-Detail Relation ship data type -> Next -> Select "Students" in the drop down -> Next -> Next -> Save
ii) set up -> Build -> Create -> Objects -> Click on "Studying" object -> Click "New" in Custom Fields & Relationship section -> Select Master-Detail Relation ship data type -> Next -> Select "Courses" in the drop down -> Next -> Next -> Save
2 fields:
i) Master - detail relation ship (Student) - Primary relation ship
ii) Master - detail relation ship ( Courses) - Secondary Relation ship