Simulates a sequence of merge operations with tables in a database.

See code below