Two approaches to handle concurrent updates to the same data:
Pessimistic locking:
Lock the row before reading. SELECT ... FOR UPDATE. Other transactions wait. Use when conflicts are common.
Optimistic locking:
Read without locking. On write, check if data changed (version number). Retry if conflict. Use when conflicts are rare.
Example optimistic check:
UPDATE users SET balance = 100, version = 2 WHERE id = 1 AND version = 1
If version changed, update affects rows. Application retries.