top of page
Search

JourneyToCTA Diaries Part 8 - Data Relationships

  • Shreyas Dhond
  • Mar 14
  • 4 min read

In the previous blog, we explored normalization and denormalization as key concepts in logical data modelling and their impact on Salesforce data architecture.


We reviewed the three primary normal forms (1NF, 2NF, and 3NF) and how they help reduce redundancy, enforce clear relationships, and maintain data integrity. Using examples such as Account and Address structures, we demonstrated how normalized designs separate related data into dedicated entities connected through relationships.


We also discussed denormalization, which intentionally introduces controlled redundancy to simplify data retrieval and improve performance for reporting and analytics. While this approach improves read efficiency, it introduces additional complexity in maintaining data consistency.


From an architectural perspective, effective Salesforce data models often require a balance between normalization and denormalization depending on the use case, data access patterns, and scalability needs.


In this blog we will discuss the relationship types that support the normalization process. Salesforce supports this principle through several relationship types that allow architects to structure data across objects while preserving data integrity and reducing redundancy.


Understanding when and how to use these relationship types is essential when designing normalized data models in Salesforce.


Lookup Relationships


A Lookup Relationship is the most common and flexible relationship type in Salesforce. It creates a loose association between two objects where one record can reference another without enforcing strict ownership or lifecycle dependencies.


Lookup relationships are often used in normalized designs when objects represent distinct business entities that should remain independent but still related. For example, an Order object may have a lookup to an Account, allowing orders to reference customers without tightly coupling their lifecycle.


This relationship type supports normalization by allowing data to be stored once in its own entity and referenced wherever needed, reducing duplication across the system.



Master-Detail Relationships


A Master-Detail Relationship represents a stronger dependency between objects. In this relationship, the child record cannot exist without the parent, and the parent record controls ownership, security, and deletion behavior.


Master-detail relationships are commonly used when the child object represents a component or extension of the parent entity. For example, an Order may contain multiple Order Line Items, where each line item depends entirely on the order.


From a normalization perspective, master-detail relationships allow complex data structures to be broken into logically related tables while maintaining strict integrity between them.



One-to-One Relationships


Salesforce does not natively provide a dedicated one-to-one relationship type, but this pattern can still be implemented using a combination of relationships and automation.


One approach is to create lookup relationships on both objects, allowing each object to reference the other. Automation such as a Flow or Apex trigger can then be used to enforce the constraint that both lookup fields must always point to the corresponding record. This logic ensures that when one record is updated, the related record maintains the correct reference, effectively simulating a one-to-one relationship.


Another common approach is to maintain a parent–child structure (using either a lookup or master-detail relationship) and enforce through automation that the parent can have only a single child record. This restriction preserves the one-to-one nature of the relationship while still leveraging Salesforce’s native relationship types.


While this approach is relatively straightforward to maintain, it can introduce additional complexity when querying data. Since the relationship is technically modeled as parent–child, retrieving the associated record may require additional SOQL queries or relationship traversals, particularly when accessing child records from the parent object.



Many-to-Many Relationships


Salesforce implements many-to-many relationships using an intermediary object known as a junction object. The junction object contains two master-detail relationships that link the two parent entities.


This pattern is often used when a normalized data model requires multiple records from one entity to be associated with multiple records from another. For example, Students and Courses may have a many-to-many relationship, where a student can enroll in multiple courses and each course can have multiple students.


By introducing a junction object such as Enrollment, the relationship is normalized while allowing the system to store additional attributes related to that association.



Hierarchical Relationships


A Hierarchical Relationship is a special relationship type available on the User object that allows users to reference other users within the same object. This relationship is commonly used to represent organizational reporting structures, such as managers and subordinates.


While more specialized than other relationship types, hierarchical relationships still support normalization by maintaining relationships within a single entity without duplicating organizational data.



External and Indirect Relationships


In environments where Salesforce integrates with external systems, External Lookup and Indirect Lookup Relationships allow Salesforce objects to reference records stored outside the platform through external objects.


These relationships help maintain normalized architectures across system boundaries by allowing Salesforce to reference external master data rather than duplicating it within the platform.



Architectural Perspective


Salesforce provides multiple relationship types to support normalized data design patterns. Each relationship type introduces different levels of dependency, ownership, and integrity enforcement.


Choosing the correct relationship type allows architects to:

  • Maintain data integrity

  • Avoid unnecessary data duplication

  • Design scalable data models

  • Support clear business relationships between entities


When used thoughtfully, these relationships form the foundation for implementing normalized data models within the Salesforce platform while still accommodating the platform’s performance and usability considerations.


In the next blog we will dive into security and governance considerations and also look at some common Account (Contact) models and their usecases in Salesforce. Stay tuned!



 
 
 

Comments


Copyright © 2024 SFDCShred

bottom of page