> For the complete documentation index, see [llms.txt](https://docs.mydbsync.com/cloud-replication-main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mydbsync.com/cloud-replication-main/v6/source-apps-to-database/application-design.md).

# Application Design

The application is developed in Java to ensure that it can work in both Windows and Linux environments.

![](https://help.mydbsync.com/docs/download/attachments/31983293/Source%20app.jpg?version=1\&modificationDate=1545936309000\&api=v2)

<br>

On running "startup.bat db\_to\_source apps\<profilename>", a mirror schema with the following structure will be created for each table in source applications.

***Source apps Objects: (Salesforce and Microsoft CRM)***\
Table Name: source apps\[Source apps Object Name]\
Column Name: Source apps\[Source apps Column Name]

***Control Columns:***\
Primary key: "SYNC\_ID"\
Date last modified: SYNC\_LAST\_MODIFIED\_DATE\_TIME\
Flag to indicate sync status: DO\_SYNC\_FLAG\
Flag to indicate merged record: MERGE\_ID

**Schema Requirements:**

*Create schema into a Database for replicating schema from source applications.*

The schema will be created by running a command from the console. The application will evaluate the schema difference between Source apps and Database - Source apps DB instance and generate “ALTER TABLE” command to add the columns. It will not remove any columns for a given table to maintain historical data.

**Note:** All table names and columns will be trimmed to 30 characters in length.

**Data synchronization Requirements:**

*Source apps to Database replication*

The data replication from source apps to Database will be initiated every time a command from console is initiated. The application will maintain an association between source apps and Database table last synch timestamp. It will query all tables in source apps which have been created or modified since the last synch query and will perform an update or insert in Database tables.

Command: startup.bat \<Profile Name>source\_to\_db

The command to synchronize a particular table or object is

startup.bat \<Profile Name>source\_to\_db\<source Object Name>

Source Object Name can be any object from source apps – e.g. Account, Lead etc.

**Database to Source apps data Replication:**

*Database to Source apps data replication.*

The data replication from Database to Source apps will be initiated every time a command from console is initiated. The application will maintain an association between Database and Source apps table last synch timestamp. It will query all tables in Database which have been created or modified since the last synch query and will perform an update or insert in Source apps tables.

Command: startup.bat \<Profile Name>db\_to\_source

The command to synchronize a particular table or object is

startup.bat \<Profile Name>db\_to\_source\<Source Object Name>

Source Object Name can be any object from source apps – e.g. Account, Lead etc.

### Parent Child Relationship Columns <a href="#applicationdesign-parentchildrelationshipcolumns" id="applicationdesign-parentchildrelationshipcolumns"></a>

To maintain the relationship for creation of new records from external system into Database Source schema, the external application will have to establish relationship between the parent and child elements. To create a relationship in child or related table, the standard practice is to add a related column as REL\[Source Table Name]ID to point to the primary key of "SYNC\_ID" of the related / parent table.

***Synchronization sequence example between Account and Contact*****:**

* A new account is added with two new contacts in Database. The contacts table "SOURCECONTACT" will contain a column called "RELACCOUNTID".
* When the synchronization is initiated, the tool will do a check for "SOURCEID" on the Account record. In case the SOURCEID does not exist (which is Source apps (Salesforce and Microsoft CRM id) it will initiate an insert operation into source and update the "SOURCEID" back into that record in Database.

The system will do a check on SOURCECONTACT table and retrieve two new records without SOURCEID and updates those records with respective SOURCEIDs. At the same time it will find the external id, RELACCOUNTID and associates it to the right parent record into source applications.

***Note*****:**

Create a column with the following convention:

* RELXXXXXID where XXXXX is the name of the parent Table.\*\* Example: RELACCOUNTID column on SOURCECONTACT showing that Contact has a relationship with Account.
* If the table is a custom field, then use RELXXXXX\_\_C as the column showing relationship with another table.\*\* Example: RELCONTACT\_*C column on SFSPECIALITYC showing that SPECIALITY*\_C has a relationship with CONTACT.

<br>

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mydbsync.com/cloud-replication-main/v6/source-apps-to-database/application-design.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
