Hi I am wondering if there is such thing as a ‘cascade copy’ that honors foreign key relationships when copying records, so that if you copy a record that has related records pointing to it, they are also implicitly copied? If not is there an elegant way to do this that will scale, so that if I add new FK relationships or modify my tables I dont have to retest code?
My situation is that I have a main database and small mobile databases that I would like to merge with the main one periodically. Lets say I have Customers – Orders – OrderItems and a new Customer is created in the mobile DB with new order information, I would like to merge that into the main DB so the whole tree comes across.
UPDATED:
I am using SQLite on both main and satellite DBs. I would just like to bring across a Customer order without having to manually copy the related Orders and OrderItems.
Any thoughts would be much appreciated!
There is no built-in mechanism that will provide the functionality of automatically copying a row and its related data in a given database when a copy is desired. That logic must be encapsulated into a stored procedure which would have to be updated and tested when new relationships are created.
However, if what you are seeking is replicating data between two databases, that is possible through the built-in replication mechanism or using something like the Sync Framework.
Microsoft Sync Framework