Answered step by step
Verified Expert Solution
Question
1 Approved Answer
# Transactions Transactions ( 1 0 p . ) Consider the database with the following schema Product ( prodID , name, price, manufID, stock )
# Transactions Transactions
p Consider the database with the following schema
ProductprodID name, price, manufID, stock
ManufacturermanufID name, email
In the initial state, the database contains the tuples
Table : Products
Table : Manufacturers
Let us inspect four transactions happening in our database. We do not know, in which order the
transactions will happen, and they may occur concurrently. The commands inside a transaction will
be executed in the order they are listed.
restocking:
For all the products, read the value of the attribute 'stock'. You may assume that this happens
onebyone in an arbitrary order.
If the value is less than update the value to be increased by
ordering products:
Read the value of 'stock' for the item with id
If the value is at least decrease the value of 'stock' by ie the product has been ordered
You can work on the questions on DBeaver but also include some explanations:
either take screenshots and add explanations in a pdf or comment the sql script with your explanations.
If you prefer to use Standard SQL in pen and paper format or typed in a text editor, you may do so but this is not advisable as you wont be able to check it on DBeaver
p Consider the database with the following schema
ProductprodID name, price, manufID, stock
ManufacturermanufID name, email
In the initial state, the database contains the tuples:
Products
prodID name price manufID stock
ABC shampoo
ABC toothbrush
Headphones
Mouse NULL
Manufacturers
manufID name email
ABCcustomerservice@abc.fi
XYZxyzservices@xyzcom
Let us inspect four transactions happening in our database.
We do not know, in which order the transactions will happen, and they may occur concurrently.
The commands inside a transaction will be executed in the order they are listed.
Trestocking:
For all the products, read the value of the attribute stock You may assume that this happens onebyone in an arbitrary order.
If the value is less than update the value to be increased by
Tordering products:
Read the value of stock for the item with id
If the value is at least decrease the value of stock by ie the product has been ordered
Read the value of stock for the item with id
If the value is at least decrease the value of stock by ie the product has been ordered
Tupdating manufacturers:
Update the ID of the manufacturer ABC to
Update all the items with manufID to have manufID
You may assume that this happens one by one in an arbitrary order.
Tremove tuples breaking consistency:
Read the results of the following query
SELECT prodID
FROM Product
WHERE manufID NOT IN SELECT manufID FROM Manufacturer;
Delete all the tuples in Product whose IDs are in the query.
### a If all the ACID principles of transactions hold, which of the following scenarios are possible in the end?
For possible scenarios, explain in which order the relevant transactions and their commands need to occur.
If the scenario is impossible, explain briefly why.
For the product the value of stock is
For the product the value of stock is less than
The table products contains only one tuple.
The transaction T is able to order the product ABC shampoo but not the product Mouse
### b If all the ACID principles of transactions hold except atomicity, which of the following scenarios are possible in the end?
For possible scenarios, explain in which order the relevant transactions and their commands need to occur. If the scenario is impossible, explain briefly why.
The table Products contains only row.
The transaction T is able to order the product Mouse but not the product ABC shampoo
In the end, the Product table contains the following tuples:
prodID name price manufID stock
ABC shampoo
ABC toothbrush
Headphones
### c If all the ACID principles of transactions hold except isolation, which of the following scenarios are possible in the end?
For possible scenarios, explain in which order the relevant transactions and their commands need to occur. If the scenario is impossible, explain briefly why.
The table Products contains only row.
The transaction T is able to order the product Mouse but not the product ABC shampoo
The value of the attribute stock for item is negative.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started