Question: Task 6 - Retail Inventory System [ 3 marks ] You are tasked with handling transactions in a retail inventory system that tracks product stock
Task Retail Inventory System marks
You are tasked with handling transactions in a retail inventory system that tracks product stock and customer orders.
a Create a database named RetailDB and use it marks
b Create tables marks in total mark for successfully creating each table and for each incorrect table.:
Product: The Product table stores information about the products available in stock.
Products product id productname, stockquantity
Fields:
productname: Name of the product.
stockquantity: The number of units available in stock.
Constraints:
productid is the primary key and uniquely identifies each product.
productname and stockquantity cannot be NULL.
stockquantity must be greater than or equal to zero, ensuring that stock cannot be negative.
Order: Stores information about the orders placed by customers.
Orders order id productid orderquantity
Fields:
productid Foreign Key: References the Product table, identifying the product ordered.
orderquantity: The number of units ordered.
Constraints:
orderid is the primary key and uniquely identifies each order.
productid and orderquantity cannot be NULL.
productid references Productproductid to ensure that the order references an existing product.
orderquantity must be greater than zero, ensuring that the number of items ordered is positive.
c Insert the following data into the Product table marks
d Scenario: Ordering laptops marks for correct answer and reduced for each mistake. marks if your answer contains more than three mistakes.
A customer orders units of the product with productid Laptop
The system needs to deduct units from the product's stock.
Write SQL statements for the following steps:
Start a transaction.
Deduct units from the stock stockquantity for productid Laptop
After running the query in Step execute ROLLBACK as your third query and explain what happens to the Product table Keep your answer within words.
Now, rerun Steps Start a transaction and Deduct units from the stock stockquantity for productid Laptop After running the query in Step execute COMMIT as your third query this time and explain what happens to the Product table Keep your answer within words.
Some Instructions for Task :
Use appropriate SQL statements to handle the transactions.
Ensure your transactions follow the database rules, including foreign key and check constraints.
Explanations for Steps and must be included in the PDF document. The SQL statements for all the steps, including the creation of the database, creation of tables, and data insertions, must be included in the SQL file.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
