DBMS Software retrieves records rather than files, as a a consequence editing can be also controlled based on records rather than files. Imagine two users have retrieved the same record, if both users subsequently make changes to this record then which version of the record should be stored The DBMS must implement a strategy whereby records can be locked; commonly DBMS provide two different strategies: pessimistic locking and optimistic locking Pessimistic Locking - As the name suggests, it is somewhat negative.
- The first user to start editing the record effectively locks the record and hence subsequent users must wait for the updated record to be stored/released before they can commence editing.
Optimistic Locking - is more positive
- Based on the assumption that conflicts will rarely occur. Such a strategy does not require the DBMS to be informed as editing commences, rather the DBMS checks for record changes prior to storing each record. If another user has made a change to the record then there are two possible options
- either, the currently stored record can be overwritten
- or, current user's changes are discarded.
- Commonly, the user is given the task of making this decision via a warning message.
- Clearly, optimistic locking can have dangerous consequences in terms of maintaining data integrity
|