Relationships in salesforce ?

A relationship is a bi-directional association between two objects.

Types of relationship : -
  →  Master-Detail
  →  Lookup
  →  Many-to-Many

Master-Detail Relationship:
  • A tightly coupled relationship between Master Object and Child Object.
  • When a record of the master object is deleted, its related detail records are also deleted.
  • The master-detail relationship field is required on the page layout of the detail record.
Lookup Relationship :
  • A loosely coupled relationship between Master Object and Child Object.
  • If we delete the master record then child record will not be deleted.
  • 25 lookup relation relationships allowed per object.
Many-to-Many Relationship :
  • A many-to-many relationship allows each record of one object to be linked to multiple records from another object and vise versa.
  • To create a many-to-many relationship, simply create a custom junction object with two master-detail relationship fields, each linking to the objects you want to relate.
        A→C→B
        A1→C1→B1
        A2→C1→B2
        A3→C1→B3

Note :
  • A relationship is always defined on the child object. 
  • Rollup summary field always works with Master-Detail Relationship.
      A → Master Object. 
      B → Child Object
      
      If we want to create relationships between A and B then we will define the relationship on B. 

Example :


Comments

Popular posts from this blog

Tree

AVL (Adelson-Velskii and Landis) Trees

How to Build REST API Using PHP