Two-way sync between enterprise systems & databases at any scale

The Complete Architectural Guide

Handling record associations (one-to-many, many-to-many) across systems

Syncing data between Salesforce and Postgres with cross-system ID references.

One of the most challenging aspects of building integrations between business systems and databases is managing record associations. When creating records that need to be associated with each other, such as linking a contact to a company, developers often struggle with timing issues and system coordination. The traditional approach of writing custom code to handle these associations through APIs quickly becomes complex and brittle, requiring careful orchestration of API calls, proper error handling, and management of race conditions. Additionally, integration teams rarely invest sufficient time to implement associations properly, resulting in records that fail to associate correctly in the CRM creating data inconsistencies and causing adverse consequences on business operations.

Two robust approaches exist for handling record associations when using bidirectional sync. The first approach leverages the original business system IDs directly within the database tables. For example, when two-way syncing Salesforce contacts and accounts with Postgres, the contacts table in Postgres includes a field for the Salesforce account ID. When a record is created from the database, the bidirectional sync ensures this Salesforce account ID field is populated once the record is created in Salesforce, enabling proper association management. The Salesforce account ID generated by Salesforce and now feedbacked in Postgres, can be used to create a record in the Postgres contact table and associate it to an account using the Salesforce ID themselves. This approach provides a clear audit trail and makes it easy to track which records are linked across systems, though it requires careful handling of the period between record creation and ID assignment.

Stacksync makes it possible to create synchronous record associations from a database and have all changes propagated instantly to any business system like Salesforce and NetSuite.

The second approach utilizes native association support provided by modern integration platforms like Stacksync. The platform maintains internal mappings of record relationships across systems and automatically handles the sequencing of record creation and association. When a contact and company are created in the database, the platform ensures they are properly created in the business system and linked together, without requiring developers to write complex orchestration code. This approach significantly reduces implementation complexity and potential failure modes, while still maintaining data integrity across systems. The platform handles edge cases such as failed record creation, system outages, rollbacks and race conditions that would otherwise require extensive custom code to manage properly.

This second approach enables associating records with Salesforce IDs in Salesforce to automatically associate the records with Postgres ID in the database and vice versa. Records are associated with database IDs in the database world and Stacksync translates the association to associate the record with Salesforce IDs in the Salesforce word.

Authors

Ruben Burdin
Founder & CEO
Ruben Burdin is the Founder and CEO of Stacksync, the first real-time and two-way sync for enterprise data at scale. Ruben is a Y Combinator alumni with a strong background in software engineering and business.
Armon Petrossian
Founder & CEO
Coalesce logo
As Co-Founder and CEO, Armon created Coalesce, the only data transformation tool built for scale. Prior, Armon was part of the founding team at WhereScape, a leading provider of data automation software. At WhereScape, Armon served as national sales manager for almost a decade.
Ant Wilson
Co-Founder & CTO
Ant is a Co-Founder and CTO at Supabase, the world leading Postgres company. He has a background in large scale storage systems. Ant is a serial entrepreneur that participated in Y Combinator and Entrepreneur First.
Tim Kwan
Data Management Specialist
MongoDB logo
Tim Kwan is a data management specialist at Google, passionate about bridging the gap between business and engineering. With extensive experience in cloud technologies, AI, and database solutions, he helps organizations accelerate application development and drive innovation.