Databases

Client server databases

A client server database is a database that can be accessed from its server by multiple clients simultaneously. To do this it uses database management software (DBMS) which runs on both the server and clients.



Advantages of client server databases

The database can be accessed by multiple users simultaneously.
It can be accessed from several places meaning firms with different branches can share a single database instead of having to each have their own copy.
Access rights and security can be managed centrally.
Back up can be managed centrally.

Problems with concurrent access

A key problem with concurrent access is the lost update problem. One client downloads a copy of a record from the server to their machine. While they are editing it another client downloads a copy of the same record. Whichever of these users saves their data first will have it overwritten by the other.



Record locking

In order to prevent lost updates records can be locked when requested by a client until the transaction is over. If another client requests the same record they will be denied until the initial transaction is complete or abandoned.



Deadlock

Record locking can lead to another problem known as deadlock. This is when two or more database transactions are waiting for each other to release record locks. A database needs to be able to recognize when record locking has occurred and apply serialisation methods to deal with it such as:
* Timestamp ordering
* Commitment ordering



Serialisation

Serialisation is a way of ensuring no two transactions can overlap in time. A new transaction can’t start until the old one is finished. It can be implemented using timestamp ordering or commitment ordering.



Timestamp ordering

Transactions are given a timestamp when they begin. If two transactions affect the same object in the database then the one with the earlier timestamp should be applied first. Each object in a database also has a read and write timestamp. When a transaction starts it reads an object and sets the read timestamp, when it goes to write to the object it checks the read stamp and if it has changed since the transaction started then it knows that the record is being accessed by another transaction and take appropriate action.



Commitment ordering

Commitment ordering is another method of serialisation. As well as making use of the time transactions were initiated it also considers how transactions depend on each other. The less important transactions will have to wait for the more important ones.

Knowledge check


Questions:
Correct:

Question text


© All materials created by and copyright S.Goff