Question


[Q.7] Answer the following questions (a) Explain 2PL in the context of database concurrency control (b) Explain the reason why most DBMS provides isolation level. (c) List and explain 4 different isolation levels of the MySQL DBMS.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer for 3 (a)

First of all, let me explain you a bit about concurrency and why it matters in database systems (I'll use DBMS as its acronym).

Consider a case of a simple system where there's one queue of operations taking place sequentially. This situation is similar to simple tasks such as queuing up for a metro ticket etc. And these operations require a sequential algorithm to manage the process.

A sequential algorithm doesn't have to worry about other simultaneously occuring processes as it deals with just one main thread, or the primary component of the system.

But in a world of smartphones and IOT, simple DBMSs aren't simply enough to cope up with increasing complexity of systems. One such example is our smartphone, and all the simultaneous and concurrent processes it handles simultaenously. It allows for an environment to make many things happen at the same time, and this is only possible because of simultaneous databases that allow dedicated DBMS systems for each user.

Grid computing and cloud computing are two areas where concurrent DBMSs are used that allow for various sub- components (two or more) to access the same data that are executed with time overlap. it allows for the integrity of DBMSs without violating any rules prescribed by the specific DBMS.

So, concurrent DBMSs are used to control concurrency of multiple ovelapped transactions by defining a strict set of rules known as concurrency control protocols. These rules safeguard the 3 out of 4 pillars of secure databse transactions-

  • Atomicity
  • Isolation
  • Serializibility

Now, these protocols can broadly be divided in two parts-

  1. Lock Based protocols- No transaction can read/write data until it acquires a lock over it
  2. Time stamp based protocols- transactions use system time/logical counter as the timestamp

The locks are further of two types-

Binary lock is where the data is either locked or unlocked,

Shared lock is where the operation on data determined what type of lock it has. For example, a write operation would have an exclusive lock. A read permission is shared lock, and for a transaction to acquire an exclusive lock, it must first have a shared lock permission (read permission).

Two Phase Locking Protocol (2PL)

This protocol divides the entire execution time of transaction in three phases, or parts.These phases form the complete cycle of transaction completion, and begins when the transaction begins executing. At this phase, the protocol seeks permissions for the locks it requires.

The second part is where transaction aquires all the locks. This is a a bit longer process, and keeps going until the protocol has acquired all the locks it needs.

And when it releases the first lock, that is when the third phase begins. In this phase, no new locks can be demanded and the protocol can only release the acquired lock.

Locks acquired Locks released phase 2 phase 1 GROWING phase 3 SHRINKING

Thus, this protocol has two phases- GROWING and FALLING/SHRINKING. The growing phase is where protocol acquires all the locks, and shrinking phase is where it releases the locks.

Answer for 3 (b)

Isolation is one of the four pillars of every DBMS, sequential or concurrent- ACID. Isolation determines the visibility of a transaction to other systems/users. A lower isolation level allows every user to access the same data, thus highly risking the data privacy and security of the system. However, a higher isolation level reduces the types of concurrency over the data but requires more resources and is slowed than lower isolation levels.

Isolation protocols help safeguard the data from unwanted transactions. They maintain the integrity of every data by defining how and when the changes made by one operation are visible to the others.  

Answer for 3 (c)

Ideally, the transaction should take place in such a way that its the only transaction accessing resources in a database system. To understand the 4 levels of isolation, it is important we understand what kind of phenomenon may occur in concurrent data types.

Type 1 (dirty read)- Lets say Transaction T1 updates a row and leaves it uncommitted. And T2 transaction sees the change (reads the updated row). If T1 rolled back the change, T2 will have seen a data that never existed. This situation is called dirty read.

Type 2 (non-repeatable read) - It occurs when a transaction reads the same value twice, and gets a different result everytime.

Type 3 (phantom read)- It occurs when the same queries are executed but the rows received by the two are different.

Now based on these three phenomemon, we have four levels of isolation-

  1. Read uncommitted- it is the lowest level of isolation. At this level, dirty reads are allowed. That means one can read the uncommitted changes made by another.
  2. Read committed- It allows no dirty reads, and clearly states that any uncommitted data is committed at the moment it is read.
  3. Repeatable read- This is most restricted level of isolation. The transaction holds read locks on all the rows it referances, and write locks over all the rows it updates/inserts/deletes. So, there's no chance of non-repeatable reads.
  4. Serializable- The highest level of civilization. it demands that all concurrent transactions be executing serially,
Add a comment
Know the answer?
Add Answer to:
[Q.7] Answer the following questions (a) Explain 2PL in the context of database concurrency control (b)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the following protocol for concurrency control. The database system assigns each transaction a unique and...

    Consider the following protocol for concurrency control. The database system assigns each transaction a unique and strictly increasingly id at the start of the transaction. For each dataitem, the database system also keeps the id of the last transaction that has modified the data item, called the transaction-id of the data item. Before a transaction T wants to read or write on a data item A, the database system checks whether the transaction-id of A is greater than the id...

  • Q.5] Answer the following questions based on the company database (based on the homework assignment 2) y dat...

    Q.5] Answer the following questions based on the company database (based on the homework assignment 2) y database (based on the homework assignment 2) 3 IPage 1. For each department whose average employee salary is more than $30,000, write a SQL statement to retrieve the department name and the number of employees working for that department 2. Write a SQL statement to retrieve first name, last name, and address of each employee who lives in Houston, TX. 3. Write a...

  • ) Consider what happens with the locks in order to get each of the following SQL...

    ) Consider what happens with the locks in order to get each of the following SQL isolation levels: (a) READ UNCOMMITTED (b) READ COMMITTED (c) REPEATABLE READ (d) SERIALIZABLE For each of the above, you have to (i) briefly explain what ”locking policies” the DBMS enforces to get that isolation level. (ii) briefly explain why this locking policy ensures that particular isolation level (iii) briefly explain why this locking policy does not ensure the next isolation level. (you don’t have...

  • Help me solve this question. Urgent. Answer following when a distributed database system uses timestamp ordering...

    Help me solve this question. Urgent. Answer following when a distributed database system uses timestamp ordering concurrency control mechanism. The data item X with timestamps Can system allow a transaction, with timestamp 2:45 PM to modify X. Why or why not? The data item Y with timestamps Can system allow a transaction with timestamp 4:20 PM to modify Y, why or why not?

  • Please do not delete the questions. 1. What is the purpose of a database? 2. What...

    Please do not delete the questions. 1. What is the purpose of a database? 2. What is the reason to use a database over a spreadsheet? 3. Based on the previous answers (#1 & #2), there is a simple rule of thumb. A spread sheet is used when there is _________________________. A database is used when there are _________________________. 4. Please answer followings. a) A group of 8 bits is called a ____________ (from Chapter 4). b) The answers of...

  • database qustion Q2) Answer the following: (16 points) Mention three drawbacks of using file systems to...

    database qustion Q2) Answer the following: (16 points) Mention three drawbacks of using file systems to store data and explain how DBMS overcome these drawbacks: 1 - 1- 2- 3- 2- Database system consists of: 2- 1- 3- 3- Database Engine consists of: 1- 3- 4- Mention three types of DB users: 1- 2- 3- 5- is a collection of operations that performs a single logical function in a database application. Transaction manager consists of two main programs: 1- 6-...

  • QUESTIONS 7 - 11 Use the SAME letters above to answer the following questions 7. In...

    QUESTIONS 7 - 11 Use the SAME letters above to answer the following questions 7. In eukaryotic organisms, mRNA that is made from DNA is almost always much larger right after it is synthesized compared to when it finally engages with a ribosome to make a protein. This process is called 8. In the process defined in question 7, is/are cut out of the DNA. 9. In eukaryotic organisms, activators bind to control regions called that are distant from the...

  • 1.1) A data model is a collection of conceptual tools for describing data, data relationships, data...

    1.1) A data model is a collection of conceptual tools for describing data, data relationships, data semantics, and data constraints: a) True b) False 1.2) The three levels of data abstractions provided by a DBMS are a) Users, query processor, storage manager b) Logical design, physical design, indexes c) Logical design, physical design, views d) None of the above 1.3) Johnson wants to store information (names, addresses, descriptions of embarrassing moments, etc.) about his employees. Not surprisingly, the volume of...

  • A) Explain what single-element drum level control is B) Explain what two-element drum level control is C) Explain what three-level drum level control is. 1. 2. Explain what single-point positionin...

    A) Explain what single-element drum level control is B) Explain what two-element drum level control is C) Explain what three-level drum level control is. 1. 2. Explain what single-point positioning contrl is Explain what parallel-point positioning control is. 3. Regarding excess air, explain what happens when: 4. A) Too much air is introduced into the burner B) Too little excess air is introduced into the burner Why do we measure the oxygen content of the flue gas and what do...

  • 4. The exams database: The following database contains multiple choice exam questions tables Questions and On...

    4. The exams database: The following database contains multiple choice exam questions tables Questions and On Hons). Each question has a question Tert and each one of the options has and optid, which is an integer representing options A) (optid=1), B) (optid=2), C) (optid=3), etc. as well as the text of the option. The field correct is either Oor 1 and indicates which is the correct option for that particular question. courseThe exams have numbers 1, 2, 3, etc. Each...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT