Okay, so I know it's simple if you think about it, but sometimes people miss the obvious (I certainly did).
If you use the replace() function in Query Builder, the record is first deleted: this means if you have any foreign key constraints setup, with the cascade on delete option, all your related records are going to be deleted too.
A little warning about this may help.