1. Pessimistic Locking = select for update no wait
2. Optimistic Locking Using a Version Column,
3. Optimistic Locking Using a Checksum, CPU time
DEADLOCK is because foreign key is not indexed.
delete a parent will cause lock child table.
update or delete primary key will cause the same issue, when using ORM, the sql generated might do that.