Question

In: Computer Science

Q) A shared lock is issued when a transaction must read data from the database and...

Q)

A shared lock is issued when a transaction must read data from the database and no exclusive locks are held on the data to be read.” Is it correct? Justify the answer by explaining the conditions (or by an example) under which both types of locks are granted

Solutions

Expert Solution

Please find the answers below.

"A shared lock is issued when a transaction must read data from the database and no exclusive locks are held on the data to be read.” This statement is correct.

There are two types of locks. 1) Shared Lock (S) 2) Exclusive Lock (X)

While holding shared lock the transaction does not have the permission to update data on the data item. A shared lock is also called a Read-only lock. With the shared lock, the data item can be shared between transactions. This is because there will not be any permission to update data on the data item. For example, consider a case where two transactions are reading the account balance of a person. The database will let them read by placing a shared lock. However, if another transaction wants to update that account's balance, shared lock prevent it until the reading process is over.

In exclusive lock (X) data item can be both read as well as written.This is exclusive and cannot be held simultaneously on the same data item. Transactions may unlock the data item after finishing the 'write' operation. For example, when a transaction needs to update the account balance of a person. This can be allowed by placing X lock on it. Therefore, when the second transaction wants to read or write, exclusive lock prevent this operation.

If a transaction A holds a shared lock on item N, then a request from another transaction B for an exclusive lock on N will cause B to go into a wait state until A releases the lock. A request from transaction B for a shared lock on N will be granted. So,  B will now also hold a shared lock on N.

If transaction A holds an exclusive lock on record N, then a request from transaction B for a lock of either type on N will cause B to go into a wait state and B will wait until A releases the lock.

This can be summarised by means of the compatibility matrix below, that shows which type of lock requests can be granted simultaneously:

Type of lock N that transaction B requests for data item N Types of lock that transaction A hold on data item N
Exclusive lock (X) Shared lock (S) No lock
Exclusive lock (X) No No Yes
Shared lock (S) No Yes Yes
No lock Yes Yes Yes

Related Solutions

A database Deadlock a. is a lock placed on a record to prevent it from being accessed by other processes. b. occurs when two records ..
A database Deadlocka. is a lock placed on a record to prevent it from being accessed by other processes. b. occurs when two records are accidentally assigned the same primary keyc. occurs when a unique record is accessed by several different processes simultaneously. d. is none of the above. 
When is the conceptual schema of a database changed?- if we update data in the database...
When is the conceptual schema of a database changed?- if we update data in the database -if we alter the logical structure of the database -if we retrieve data from the database -if we alter the storage structure of the database Which of the following has the same meaning as the outer union? Group of answer choices -the left outer (natural) join -the right outer (natural) join -the full outer (natural) join -the inner (natural) join Assume {A, B} is...
(C++) Write a program to read from a grade database (data.txt). The database (text file) has...
(C++) Write a program to read from a grade database (data.txt). The database (text file) has students names, and grades for 10 quizzes.Use the given function prototypes to write the functions. Have main call your functions. The arrays should be declared in main() and passed to the functions as parameters. This is an exercise in parallel arrays, int and char 2 dim arrays. Function prototypes: int readData(ifstream &iFile, int scores[][10], char names[][30]); This functions takes the file stream parameter inFile...
When you read data in (without using getLine) how is the data read. does it read...
When you read data in (without using getLine) how is the data read. does it read spaces and line breakers(\n). Also how can you read a paragraph into a double vector of strings ( into words and strings again without using getLine)
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Can i have an essay in 400 word about When building a database, an organization must...
Can i have an essay in 400 word about When building a database, an organization must carefully consider these topics: content, access, |logical structure, and physical organization. Elaborate on these points ? include interdtion,body and conclution ?
Very carefully read the following data requirements for a prospective document translation database: i. Document translation...
Very carefully read the following data requirements for a prospective document translation database: i. Document translation initially relies on a source document. The source document is a text provided in the originally recorded, valid language (see below, and assume only one language for the original document), and has an associated author and publication date. Source document authors are not related to translators in any manner. ii. Translation of a document also relies on a translator, who is capable of translating...
With a cube from a database or data warehouse, you are bringing data "forward." Explain what...
With a cube from a database or data warehouse, you are bringing data "forward." Explain what this means and how it impacts the front-end and back-end user from a database perspective. Provide examples to illustrate your ideas. typed please
Data from adoption studies on handedness indicate that the effects of shared biological heritage are more...
Data from adoption studies on handedness indicate that the effects of shared biological heritage are more powerful determinants of hand preference than sociocultural factors. Biological offspring were found to show nonrandom distributions of right and non-right handedness as a function of parental handedness. In contrast, the handedness distribution of adopted children as a function of parental handedness was essentially random. The following table gives the handedness of biological offspring as a function of parental handedness. Biological Offspring Parental Handedness (father...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT