finish delete function, put all operation that affects multiple databases to transaction