Question 3 Describe two phase locking and serializability (Why it is needed, wha
ID: 3591991 • Letter: Q
Question
Question 3 Describe two phase locking and serializability (Why it is needed, what it is, how it works).
Question 4. Describe the ACID features/principles of a transaction. For each feature/principle, give an example that violates this feature. Namely, discuss a situation where a principle is violated and the corresponding problem(s). For example, what situation will cause a transaction not Atomic.
Note: the words that you use to answer these questions should be at least 1000 words (not including words in questions) in total. Show the word count for each answer. You must use YOUR OWN WORDS to answer questions and make your own examples, instead of simply copying words directly from the text as your answer.
Explanation / Answer
3)Two phase locking:-
1.Two-Phase Locking is a concurrency control method which divides the execution phase of a transaction into three parts.
2.If read and write operations introduce the first unlock operation in the transaction, then it is said to be Two-Phase Locking Protocol.
Two phase locking protocol, locks are applied and removed in two phases:
Expanding phase: locks are acquired and no locks are released.
Shrinking phase: locks are released and no locks are acquired.
Diffrent types of Two–Phase Locking Protocols:-
. Strict 2PL Protocol
. Rigorous 2PL Protocol
. Conservative 2PL Protocol
1. Strict 2PL Protocol:-
Strict Two-Phase Locking Protocol avoids cascaded rollbacks.
This protocol not only requires two-phase locking but also all exclusive-locks should be held
until the transaction commits or aborts.
2.Rigorous 2PL Protocol:-
Rigorous Two – Phase Locking Protocol avoids cascading rollbacks.
3.Conservative 2PL Protocol:-
Conservative 2PL Protocol transactions obtain all the locks they need before the transactions begin.
This protocol is almost free from deadlocks as all required items are listed in advanced.
It requires locking of all data items to access before the transaction starts.
Serializability :-
1.Identifies data transactions as occurring serially, independent of one another, even though they may have occurred concurrently. A schedule or list of transactions is deemed to be correct if they are serialized, otherwise, they may contain errors that can lead to duplication or overlap.
2. Serializability is used to keep the data in the data item in a consistent state. Serializability is a property of a transaction schedule . It relates to the isolation property of a database transaction.
How does the two-phase locking protocol guarantees with serializability:-
1.two-Phase Locking protocol restricts this unwanted read/write by applying exclusive lock. Moreover, when there is an exclusive lock on an item it will only be released in shrinking phase. Due to this restriction there is no chance of getting any inconsistent state.
2.Serializability is mainly an issue of handling write operation. Because any inconsistency may only be created by write operation. Multiple reads on a database item can happen parallely.ACID means:- (atomicity,consistency,isolation,durability)
1.The ACID model of database design is one of the oldest and most important concepts of database theory.
2 In a distributed system, one way to achieve ACID is to use a two-phase commit (2PC), which ensures that all involved sites must commit to transaction completion or none do, and the transaction is rolled back
3 A relational database that fails to meet any of these four goals cannot be considered reliable
1.Atomicity:
Atomicity is a feature of databases systems dictating where a transaction must be all-or-nothing. That is, the transaction must either fully happen, or not happen at all. It must not complete partially.
1. which is a set of principles used to guarantee the reliability of database transactions
2 An atomic transaction is decided by its context or the environment in which it being implemented.
3. It is essential that a database system that claims to offer atomicity be able to do so even in the face of failure in power supply or the underlying operating system or application that uses the database.
4. a transaction to transfer funds from one account to another involves making a withdrawal operation from the first account and a deposit operation on the second. If the deposit operation failed, you don’t want the withdrawal operation to happen either.
2.Consistency:
1. A transaction either creates a new and valid state of data, or, if any failure occurs, returns all data to its state before the transaction was started.
2. these states only valid data will be written to the database.
3. If, for some reason, a transaction is executed that violates the database’s consistency rules, the entire transaction will be rolled back, and the database will be restored to a state consistent with those rules.
4. a database tracking a checking account may only allow unique check numbers to exist for each transaction.
3.Isolation:
1.A transaction in process and not yet committed must remain isolated from any other transaction
2. Each transaction is isolated from other transactions, and hence, each transaction only accesses data that are part of a consistent database state.
3.a teller looking up a balance must be isolated from a concurrent transaction involving a withdrawal from the same account. Only when the withdrawal transaction commits successfully and the teller looks at the balance again will the new balance be reported.
4.Durability:
1.Committed data is saved by the system such that, even in the event of a failure and system restart, the data is available in its correct state.
2. here any transaction committed to the database will not be lost. Durability is ensured through the use of database backups and transaction logs that facilitate the restoration of committed transactions in spite of any subsequent software or hardware failures.
3. If a transaction has been reported back to a user as complete, the resulting changes to the database survive subsequent hardware or software failures.
4.A system crash or any other failure must not be allowed to lose the results of a transaction or the contents of the database. Durability is often achieved through separate transaction logs that can "re-create" all transactions from some picked point in time.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.