
Larry C. answered 06/12/19
Experienced programmer, analyst, database designer and administrator
A query is a single unit of work that does one action with a table or tables. However, in real world applications, things are seldom so simple. Consider a point-of-sale application that scans items being purchased by the customer. It might be acceptable to add each item scanned to an OrderItems table as a done deal before handling the next if mistakes were never made or a customer never changes their mind. However, it's far more efficient to consider a sale as a whole, where changes are only temporary until the decision is made to either commit the changes (making them permanent) or rolling them back (eliminating the temporary changes from the tables.) This is what a transaction essentially does...considers a series of queries as a temporary unit until the go/no-go decision is reached.