Locking methods are the most widely used approach to ensure serializability of concurrent
transactions. There are several variations, but all share the same fundamental character-istic, namely that a transaction must claim a shared (read ) or exclusive (write) lock on a
data item before the corresponding database read or write operation. The lock prevents
another transaction from modifying the item or even reading it, in the case of an exclusive
lock. Data items of various sizes, ranging from the entire database down to a field, may be locked. The size of the item determines the fineness, or granularity , of the lock. The
actual lock might be implemented by setting a bit in the data item to indicate that portion
of the database is locked, or by keeping a list of locked parts of the database, or by other
means. We examine lock granularity further in Section 20.2.8. In the meantime, we
continue to use the term ‘data item’ to refer to the lock granularity. The basic rules for
locking are set out in the following box.