Which statement best describes a shared lock in MySQL?
Think about what happens when many people want to read a book but no one should change it while reading.
A shared lock allows many transactions to read the data at the same time but stops any transaction from changing it until all shared locks are released.
What is the main effect of an exclusive lock on a database row in MySQL?
Imagine locking a diary so no one else can even peek or write until you finish.
An exclusive lock blocks all other transactions from reading or writing the locked data until the lock is released.
Consider two transactions that both request a shared lock on the same row simultaneously. What will be the result?
Think about multiple people reading the same book at the same time.
Shared locks allow multiple transactions to read the same data concurrently without blocking each other.
Transaction A holds an exclusive lock on a row. Transaction B requests a shared lock on the same row. What happens to Transaction B?
Think about waiting your turn when someone else is writing in a book.
Shared locks cannot be granted while an exclusive lock is held; the requesting transaction must wait.
You have a table orders where many transactions read order details, but only a few update them. Which locking strategy optimizes concurrency while ensuring data integrity?
Consider how to let many people read without waiting but still protect updates.
Shared locks allow many readers simultaneously, while exclusive locks block others only during updates, balancing concurrency and integrity.