Well-designed applications can minimize deadlocks by always acquiring locks in the same order. Updates to multiple tables should always be performed in the same order.
For example, the transactions described in Figure 12-1 could have avoided their deadlock by updating either the savings or checking table first in both transactions. That way, one transaction gets the exclusive lock first and proceeds while the other transaction waits to receive its exclusive lock on the same table when the first transaction ends.
In applications with large numbers of tables and transactions that update several tables, establish a locking order that can be shared by all application developers.