title: Cascade Copy in SQL? Possible to copy a record and its related records automatically?
body: <p>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?</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Any thoughts would be much appreciated!</p>