A transaction is a sequence of code that runs against a database. It takes the database from one consistent state to another.