Control Issues
This assignment is ungraded and should not be submitted. The questions review key concepts from the reading for this module.
- Expected duration
- 30–45 minutes
- Deadline
- None (no explicit submission is required)
- Points
- None
Help Policy
- Authorized Resources
- Any
- Notes
- You may jointly work on this assignment with classmates
Assignment
Answer the following questions from Fundamentals of Database Management Systems (solutions):
-
Describe the two different problems that forward recovery and backward recovery are designed to handle. Do mirrored databases address one of these two problems or yet a third one? Explain. (Question 11.13)
In forward recovery, restoration of a database – e.g., following a crash or system failure – starts with the latest (complete) backup and committed changes in the transaction (or change) log are applied to that backup.
In backward recovery, changes in the transaction (or change) log are reversed to “undo” all those that follow an erroneous one that corrupted the database. The reversed transactions are then re-executed.
A mirrored database is a duplicate that is updated simultaneously with the “main” database. If either is destroyed, then applications can continue to use the other.
-
What is the lost-update problem? (Question 11.18)
The lost-update problem is an example of a dirty read (i.e., a read phenomenon) where a transaction reads data that has been modified by a concurrent transaction but not yet committed. In the lost update problem, both transactions attempt to update the value and the last write wins – i.e., the two transactions have a race condition where the behavior is dependent on the order of their execution.
-
What is deadlock and how can it occur? (Question 11.20)
Deadlock occurs when two (or more) database transactions wait indefinitely for a resource being used by another transaction. The necessary conditions for deadlock are as follows:
- hold and wait
- each transaction must be holding at least one resource and waiting for additional resource(s)
- mutual exclusion
- at least one resource must be held exclusively (i.e., not shared)
- no preemption
- a resource can only be released by the transaction that is currently using (i.e., holding) it
- circular wait
- the dependency graph of transactions waiting for resources must contain a cycle
-
A large bank has a headquarters location plus several branches in each city in a particular region of the country. As transactions are conducted at each branch, they are processed online against a relational database at headquarters. You have been hired as the bank’s Director of Data Security. Design a comprehensive set of data security measures to protect the bank’s data. (Exercise 11.1)
A summary of key security controls is as follows:
- Physical security
- Limit access to those personnel required to maintain the equipment and use two-factor authentication for access. Minimize risks due to natural disasters (e.g., floods) and terrorist attacks by placing servers in an interior location within the building. Hire armed security guards for the facility.
- Controlled access to the database
- Limit database access to computers owned by the company and preferably only those used by employees whose jobs require access. Use two-factor authentication to access these computers. Restrict database permissions to only those capabilities required to accomplish an employee’s job functions.
- Data encryption
- Encrypt data at rest and in transit. Encryption minimizes the risks of disks being lost or stolen and the risks of interception.
- Firewalls, intrusion detection, data loss prevention, etc.
- Use the recommended tools to minimize the risks due to malware and advanced persistent threats (APTs).
- Training
- Educate users about security controls and proper cybersecurity hygiene.
-
The Tasty Seafood Restaurant is a large restaurant that specializes in fresh fish and seafood. Because its reputation for freshness is important to Tasty, it brings in a certain amount of each type of fish daily and, while trying to satisfy all of its customers, would rather run out of a type of fish than carry it over to the next day. After taking a table’s order, a waiter enters the order into a touch-screen terminal that is connected to a computer in the kitchen. The order is sent from the touch-screen terminal to the computer only after all of it has been entered.
At 8:00 PM there are 10 servings of salmon, 15 servings of flounder, and eight orders of trout left in the kitchen. At 8:03 PM, waiter Frank starts entering an order that includes five servings of salmon, six of flounder, and four of trout. At the same time, on another touch-screen terminal, waitress Mary starts entering an order that includes one serving of salmon, three of flounder, and two of trout. At 8:05 PM, before the other two have finished entering their orders, waitress Tina starts entering an order that includes six servings of salmon, one of flounder, and five of trout. Frank finishes entering his order at 8:06 PM, Mary finishes at 8:07 PM, and Tina finishes at 8:09 PM. (Exercise 11.3)
-
What would the result of all of this be in the absence of locks?
Because Tina starts entering her order before Frank and Mary finish entering their orders, Tina sees that there are 10 servings of salmon, 15 servings of flounder, and 8 orders of trout available. When Tina finishes her order, her changes overwrite those made by Frank and Mary, resulting in 6 servings of salmon, 14 servings of flounder, and 3 orders of trout being marked as available.
Time Frank Mary Tina 8:03pm Read (salmon) Read (flounder) Read (trout) Read (salmon) Read (flounder) Read (trout) 8:05pm Read (salmon) Read (flounder) Read (trout) 8:06pm Write (salmon - 5) Write (flounder - 6) Write (trout - 4) 8:07pm Write (salmon - 1) Write (flounder - 3) Write (trout - 2) 8:09pm Write (salmon - 6) Write (flounder - 1) Write (trout - 5) -
What would the result be with a locking mechanism (specifically strict two-phase locking (2PL)) in place?
The transaction schedule may vary, but one example is as follows:
Time Frank Mary Tina 8:03pm Lock-S (salmon) Lock-S (flounder) Lock-S (trout) Read (salmon) Read (flounder) Read (trout) Lock-S (salmon) Lock-S (flounder) Lock-S (trout) Read (salmon) Read (flounder) Read (trout) 8:05pm Lock-S (salmon) Lock-S (flounder) Lock-S (trout) Read (salmon) Read (flounder) Read (trout) 8:06pm Lock-X (salmon) – fails 8:07pm Lock-X (salmon) – fails Deadlock – abort transaction (and release locks) Lock-X (salmon) – fails 8:09pm Lock-X (salmon) – fails Deadlock – abort transaction (and release locks) Lock-X (salmon) Lock-X (flounder) Lock-X (trout) Write (salmon - 5) Write (flounder - 6) Write (trout - 4) Commit (and release locks) 8:10pm Lock-S (salmon) Lock-S (flounder) Lock-S (trout) Read (salmon) Read (flounder) Read (trout) Lock-X (salmon) Lock-X (flounder) Lock-X (trout) Write (salmon - 1) Write (flounder - 3) Write (trout - 2) Commit (and release locks) 8:11pm Lock-S (salmon) Lock-S (flounder) Lock-S (trout) Read (salmon) Read (flounder) Read (trout) Lock-X (salmon) Lock-X (flounder) Lock-X (trout) Write (salmon - 4) Write (flounder - 1) Write (trout - 2) Commit (and release locks) In this instance, locking prevents the “lost update” problem, and Tina’s transaction, which completes last, cannot enter more than the remaining number of salmon and trout. The end result is that there is no servings of salmon, 5 servings of flounder, and no servings of trout remaining, and Tina has several patrons who will have to eat flounder for dinner.
-
What would happen if versioning was in use?
The outcome is the same as the prior part (although the transaction schedule would be different – namely, not requiring locks).
-
-
Construct examples of the lost update problem for the case of a joint bank account (i.e. two people with access to the same bank account). (Exercise 11.4)
In the lost update problem, one transaction overwrites the value written by a concurrent transaction. An example is as follows:
Sue wants to deposit $20 into the bank account while Tom wants to withdraw $5 from an ATM using the same account. The transaction schedule follows:
Sue Tom Read (balance) Read (balance) Write (balance + 20) Write (balance - 5) In this instance, the account’s balance decreases by $5 even though it should increase by $15. Sue’s deposit and increase to the account balance has been overwritten (i.e., “lost”) by Tom’s concurrent ATM withdraw.