You are on page 1of 3

Salesforce

Course

Ranjith Kumar Krishnan - sfdcmeet@gmail.com


TYPES OF OBJECT RELATIONSHIPS

1. Master-Child Relationship
Closely links objects together such that the master record controls certain behaviors of the detail an
d sub detail record.
a. If Master is deleted, Child records would be deleted automatically.
b. The child security access is derived from master
c. Rollup summary is possible
Example 1:
Suppose we are storing information of differnt schools in a custom object called "School" and the
classes related to each School is stored in a custom object called "Class". Then we may have records
as below in the corresponding objects. These two objects are related to each other by a custom field
called "School" in child object "Class"
Object: Student (API name - School__c)
ScohoolId SchoolName Address
--------- ---------- -------S001
ABC School Ameerpet
S002
Veer School Moosapet
S003
DAV School Moosapet
S004
SIV School Moosapet
Object: Class
ClassId CName
--------- ---------C001
VI
C002
VII
C003
VIII
C004
IX
C005
VI
C006
VII
C007
VIII
C008
IX
C009
VI
C010
VII
C011
VIII
C012
IX

Seats
-------30
35
35
30
30
35
35
30
30
35
35
30

School
-------S001
S001
S001
S001
S002
S002
S002
S002
S003
S003
S004
S004

Hence the relationship field "School" is a foreign key which would have the values populated from
primary key in parent object. (--> this is a custom relationship field created of type "Master-Child
Relationship").
This value in salesforce is termed as record id. Every record that created in salesforce will have
record id generated automatically. Here, the SchoolId (from school object) may have the record id in
the pattern a00i0000004JzIE (15 digit length) which is a primary key for Salesforce record that can be
used to uniquely identify a record. Here the value S001 is given for an example but in real time this
would be the record id.

Salesforce
Course

Ranjith Kumar Krishnan - sfdcmeet@gmail.com

So back to the mater child concept, now if we delete any school record, the class records will be get
deleted automatically and we can also have the rollup summary field on parent record. Rollup
summary field is to summarize/average/count the child information on a parent record like no of
classes under particular school and total number of seats available in a school.
2. Lookup Relationship
Links two objects together. Lookup relationships are similar to masterdetail relationships, except they do not support sharing or rollup summary fields. With a lookup relationship, you can: Link two different objects.
Example 1:
Campaign (Child)
- website
- webinar
Venue (Parent)
- address
This case, the Campaign can exist without parent also (means without venue).
3. Many-to-Many Relationship
We can use masterdetail relationships to model manytomany relationships between any two
objects. A manytomany relationship allows each record of one object to be linked to multiple
records from another object and vice versa.
Example 1: A Custom object called Bug that relates to the standard
case object such that a bug could be related to multiple cases and a case could also be related to mul
tiple bugs.
Instead of creating a relationship field on the Bug object that directly links to the Case Object, we
can link them using a junction object. A junction object is a custom object with two master-detail
relationships, and is the key to making a many-to-many relationship.
For example, if you wanted to use a junction object to create a many-to-many relationship between
bugs and cases, you could name the junction object BugCaseAssociation.
3. Hierarchial Relationship
A special lookup relationship available for only the user object.
It lets users use a lookup field to associate one
user with another that does not directly or indirectly refer to itself. For example, you can create a cu
stom hierarchical relationship field to store each user's direct manager.
4. External Look up
An external lookup relationship links a child standard, custom, or external object to a parent external
object. When you create an external lookup relationship field, the standard External ID field on the
parent external object is matched against the values of the childs external lookup relationship field.
External object field values come from an external data source.
External ID - A field can be marked as external id field which means it can have values to denote the
external system.

Salesforce
Course

Ranjith Kumar Krishnan - sfdcmeet@gmail.com

Example: It can store oracle id to denote the records populated from external oracle system. So you
can refer data in oracle system using this external id.
5. Indirect lookup
An indirect lookup relationship links a child external object to a parent standard or custom object.
When you create an indirect lookup relationship field on an external object, you specify the parent
object field and the child object field to match and associate records in the relationship. Specifically,
you select a custom unique, external ID field on the parent object to match against the childs
indirect lookup relationship field, whose values come from an external data source.

You might also like