1.
Object and Records
● Objects: These are tables in Salesforce where data is stored, such as
Accounts, Contacts, or Opportunities. Each object has a defined set of fields
and a unique structure to hold data.
● Records: These are individual rows in an object, representing specific data
points. For example, an Account object can have records for different
companies, and each record holds company-specific information like Name,
Industry, and Location.
2. Field Types
Fields store data within records. Examples include:
● Text: Simple text strings.
● Number: Numerical values.
● Date: Stores dates.
● Picklist: Drop-down options.
● Lookup: Stores reference IDs to relate records across objects.
3. Relationships Between Objects
Salesforce supports different types of relationships to structure data and link
objects effectively.
4. Lookup Relationship
● Definition: A Lookup Relationship is a loosely coupled relationship where one
object can relate to another object, but deleting one doesn’t impact the other.
This allows for optional linking, where a child object can exist without a
parent.
● Use Case: A common use case is linking Contacts to an Account. A Contact
can exist independently and may or may not have an Account associated
with it.
Example:
● Suppose you have Account and Contact objects.
● You want to relate a contact to an account without requiring every contact to
be associated with an account.
● In this case, you create a Lookup Relationship field on the Contact object
that points to the Account object.
Implementation:
plaintext
Copy code
Contact
└── AccountId (Lookup to Account)
● Here, AccountId in Contact references the Account but isn’t mandatory. If
the account is deleted, the contact can remain.
5. Master-Detail Relationship
● Definition: A Master-Detail Relationship is a tightly coupled relationship
where the child record depends on the parent record. If you delete the
parent, the child records are also deleted.
● Use Case: Consider an Invoice object (parent) and Invoice Line Item object
(child). An Invoice Line Item only makes sense if it’s associated with an
Invoice.
● Characteristics:
○ Deleting a parent record deletes all associated child records.
○ Child records inherit security and sharing settings from the parent.
○ Roll-up summary fields can be created on the parent to summarize
data from child records.
Example:
● Assume Invoice and Invoice Line Item objects.
● An Invoice Line Item record is tied to an Invoice and cannot exist
independently.
● If the Invoice is deleted, all associated Invoice Line Items are also deleted.
Implementation:
plaintext
Copy code
Invoice Line Item
└── InvoiceId (Master-Detail to Invoice)
● Here, InvoiceId in Invoice Line Item must reference an Invoice. This
relationship ensures that each line item is associated with an invoice, and
deleting the invoice deletes all line items.
6. Many-to-Many Relationship
● Definition: A Many-to-Many Relationship allows each record in one object to
be related to multiple records in another object, and vice versa. Salesforce
accomplishes this through a Junction Object.
● Junction Object: A custom object created to enable the many-to-many
relationship. It has two master-detail relationships, one for each related
object.
● Use Case: For example, a Course object and a Student object. Each student
can enroll in multiple courses, and each course can have multiple students.
Example:
● Let’s consider Course and Student objects.
● To link these, you create an Enrollment object as a junction, which has
master-detail relationships to both Course and Student.
Implementation:
plaintext
Copy code
Course
└── Enrollment (Junction Object)
└── Student
● Here, the Enrollment object allows a many-to-many relationship, so a student
can enroll in multiple courses, and each course can have multiple students.
7. Parent and Child Objects
● Parent Object: This is the primary object in a relationship. In a master-detail
relationship, the child object cannot exist without it.
● Child Object: The object that depends on the parent. In master-detail
relationships, the child object inherits permissions and visibility from the
parent.
Examples:
● In an Account and Contact lookup relationship, Account is the parent, and
Contact is the child.
● In an Invoice and Invoice Line Item master-detail relationship, Invoice is the
parent, and Invoice Line Item is the child.
Summary Table of Relationships
Relationship Couplin Deletion Sharing Settings Example Use
Type g Impact Inheritance Case
Lookup Loose No No Account and
Contact
Master-Detail Tight Yes Yes Invoice and
Invoice Line Item
Many-to-Many Tight Yes (on Yes Student and
(Junction) Junction) Course
Each relationship type helps structure data effectively, whether you need flexible
connections with Lookup Relationships, strict parent-child dependencies with
Master-Detail Relationships, or complex many-to-many setups with a Junction
Object. Let me know if you’d like more detailed examples on any specific type!