Concurrency is not bad. In fact, it's essential. Can you imagine all 2400 Wellesley students having to take turns registering for classes, maybe in one long line? (How would people buy airline tickets?)
And there's no reason not to allow Alice to register for English concurrently with Betty registering for Mandarin.
However, just like in the real world, concurrency can cause races and anomalies, where the last ticket/seat is given to more than one person.
We need to allow currency while mitigating its issues.
Ah. There was a typo (now fixed — thanks). Change the "cs340" to "cs304" and it works.
Yes.
Yes.
No. Rollback undoes non-committed updates.
Locking turns 2 or more updates into an atomic transaction: no one else can use that table until the set is done.
The idea of isolation levels is to allow as much concurrency as possible, while reducing effects we don't want. Sometimes, we are willing to suffer some effects in order to allow more concurrency. Hence the different isolation levels.
A different isolation levels, we can allow the reading of an uncommitted value. If you are displaying the number of seats left in a class or on a flight, it might be okay to display a count that includes someone who is booking some seats right now but hasn't (yet) committed.
I'm a little confused by this question. The "before" world is before the transaction. Committing the transaction moves us (atomically) to the "after" world.
I don't think so, because different agents are doing the locking and insertion. Orit locks all records involving CS classes. Sohie inserts a new CS class. The new class is not in the set that Orit locked.
Priorities are a good way to prevent deadlock, though I don't know about your idea of incrementing priorities. We need to make sure we don't end up in a situation of circular priorities, which might happen if priorities can change.