I have an application run on an enterprise having head office and branches. Each branch has separate local server and DB. The master server and DB is updated daily by batch updation . How can i overcoming the id conflict in such situation.
Eg: i have a record with ID 10 on branch A
Also a transaction with reference id 10(foreign key) but while saving this into master db the unique id may be changed and hence the transaction is mismatched….
Pls help me for solving this…
Advance thanks to all….
Not knowing the details of exactly how you do your batch updation or how big your database is and how many tables you have which face this kind of issue, one generic way that is possible way is by maintaining mapping tables
In your batch updation logic,
for new records, you will first insert the records into the master table and then using their new ID’s generated from master, insert a record into mapping table with details like eg: branch, branchID, MasterID which stores the relation between the 2 ID’s
for existing records, you will join with the mapping table and update the records using their masterID’s from the mapping table
Usually, in SQL Server, if the batch updation is a job, you can use SSIS and have this kind of logic within your SSIS package.
Additionally, it depends on your design but there is usually a
Source DB –> Staging DB –> Destination DB
in your case which maps to
Branch DB –> Staging DB –> Master DB
for such ETL kind of tasks. In such cases, the mapping tables should probably reside in the Staging Database but if you do not have such a design (which you really should ) these mapping tables can reside in Destination i.e. Master database as well