Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Becoming a Salesforce Certified Technical Architect

You're reading from   Becoming a Salesforce Certified Technical Architect Build a strong command of architectural principles and strategies to prepare for the CTA review board

Arrow left icon
Product type Paperback
Published in Jun 2023
Publisher Packt
ISBN-13 9781803239439
Length 568 pages
Edition 2nd Edition
Arrow right icon
Author (1):
Arrow left icon
Tameem Bahri Tameem Bahri
Author Profile Icon Tameem Bahri
Tameem Bahri
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Chapter 1: Starting Your Journey as a CTA 2. Chapter 2: Core Architectural Concepts: Data Life Cycle FREE CHAPTER 3. Chapter 3: Core Architectural Concepts: Integration and Cryptography 4. Chapter 4: Core Architectural Concepts: Identity and Access Management 5. Chapter 5: Developing a Scalable System Architecture 6. Chapter 6: Formulating a Secure Architecture in Salesforce 7. Chapter 7: Designing a Scalable Salesforce Data Architecture 8. Chapter 8: Creating a Lean Solution Architecture 9. Chapter 9: Forging an Integrated Solution 10. Chapter 10: Development Life Cycle and Deployment Planning 11. Chapter 11: Communicating and Socializing Your Solution 12. Chapter 12: Practice the Review Board: First Mock 13. Chapter 13: Present and Defend: First Mock 14. Chapter 14: Practice the Review Board: Second Mock 15. Chapter 15: Present and Defend: Second Mock 16. Other Books You May Enjoy Appendix: Tips and Tricks, and the Way Forward

Using Database Relationships

One of the goals of the normalization process is to remove data redundancy. To do that, you must divide tables into multiple related subject-based tables. There are three main types of relationships—one-to-one, one-to-many, and many-to-many. Take a look at these in more detail:

  • One-to-one relationship: In this type of relationship, each record in the first table has one–and only one–linked record from the second table. And similarly, each record from the second table can have one–and only one–matching record from the first table. In this relationship, one of the tables is effectively considered an extension of the other. In many cases, the additional attributes will simply end up being added to one of the tables. That is why this relationship is not very common. However, it still has its valid cases, including splitting the data for security reasons.

In Salesforce, this is particularly useful considering the rich sharing model available. You can implement one-to-one relationships in many ways, with the most common being to create a lookup relationship from each object to the other, with an automation script (trigger, workflow, process builder, and others) to ensure both lookup fields are always populated with the right values and each object is linked to its counterpart:

This figure shows one-on-one relationships between two tables namely ‘Customer’ and ‘Customer details.’ The table ‘Customer’ lists ‘ID’, ‘Customer Details ID’, ‘First Name’, and ‘Last Name’. The table ‘Customer details’ lists ‘ID’, ‘Customer ID’, ‘Gender’, and ‘Social Status’.

Figure 2.12 – One-to-one relationship

  • One-to-many relationship: This common type of relationship occurs when a record in one table (sometimes referred to as a parent) is associated with multiple records of another table (sometimes referred to as a child). There are plenty of examples of this, including a customer placing multiple orders, an account with multiple addresses, and an order with multiple order line items.

To have this relationship, you would need to use what are known as primary keys and foreign keys. In the child table, the primary ID would be the unique identifier for each record in that table, while the foreign key would refer to the unique identifier of the parent’s primary key. This type of relationship can be created in Salesforce using lookup fields or master-detail fields. This book assumes you already know the differences between the two. You will also cover some particular differences that you need to remember in later chapters:

This figure shows an example of one-to-many relationships between two tables namely ‘Customer’ and ‘Customer details.’ The table ‘Customer’ lists ‘ID’, ‘First Name’, ‘Last Name’. The second table lists ‘ID’, ‘Customer ID’, ‘Order Total Amount’, ‘Order Date’, and ‘Order Status’.

Figure 2.13 – One-to-many relationship

  • Many-to-many relationship: This type of relationship occurs when multiple records from the first table can be associated with multiple records from the second table. This is also a common type of relationship that you come across every day. Think of the students and courses example, where each student can attend multiple courses, and each course can have multiple students attending it.

To create a many-to-many relationship between two tables, you need to create a third table, often called a bridge table or a junction table. This many-to-many relationship would effectively be broken into two one-to-many relationships. The junction table’s records would hold the value of two foreign keys, each pointing to a record from the two main tables.

Junction objects can be created in Salesforce by creating a custom object with two master-detail fields, or with two lookup fields (in this case, it is more often referred to as a bridge rather than a junction). Both approaches are valid and have their most suitable use cases.

You can even create a junction object using a mix of master-detail fields and a lookup field. This is assuming you put all the validation and business rules required in place to ensure they are always populated with the right values. You will come across examples of and use cases for Salesforce junction objects in later chapters:

This figure shows an example of many-to-many relationships between three tables namely ‘Student’, ‘Student Course’, and ‘Course’. The first table lists ‘ID’, ‘First Name’ and ‘Last Name’. The second table lists ‘ID’, ‘Student ID’, ‘Course ID’. The third table lists ‘ID’, ‘Course Name’.

Figure 2.14 – Many-to-many relationship

Keep in mind that the cardinality of these relationships can take different forms. For example, a one-to-many relationship might be better represented as one-to-zero-or-many if there are occurrences where the first table will have zero related records from the second table, as illustrated in the students and courses example earlier.

The following diagram illustrates a list of other relationships’ cardinalities. The one-and-only-one relationship could be a bit confusing. It is used when the relationship between two records from two different tables cannot be modified—for example, a user and a login ID. Once a login ID is associated with a user, it cannot be assigned to any other user after that. And it can be associated with one user only. This differs from the ownership relationship between a user and a mobile phone, for example, where the relationship itself might get updated in the future if the phone were to be sold to another owner:

This diagram illustrates a list of other relationships’ cardinalities, namely, ‘One’, ‘Many’, ‘Zero or One’, ‘One or Many’, ‘Zero or Many’, ‘One and Only One’.

Figure 2.15 – Table relationship cardinalities

You have been reading a chapter from
Becoming a Salesforce Certified Technical Architect - Second Edition
Published in: Jun 2023
Publisher: Packt
ISBN-13: 9781803239439
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image