Question: Consider the following relational schema: Product ( maker , model, type ) Distributor ( model , name, price ) PC ( model , speed, ram,
Consider the following relational schema:
Productmaker model, type
Distributormodel name, price
PCmodel speed, ram, hd
Laptopmodel speed, ram, hd screen
Printermodel color, type
The name attribute in the Distributor table represents the name of a distributor and a maker can also be a distributor
Write triggers that enforce the following conditions?
a Ensure that deleting a product from the Product table automatically removes all associated rows in the Distributor table.
b When a PC is updated with a higher RAM value, ensure all associated distributors are notified by adding an entry to a table DistributorNotificationsdistributorname, notificationdate, model
c If a printers type is updated, ensure all associated distributors of that printer reduce their prices by
Views and Materialized Views
a Create a virtual view DistributorPerformance that lists each distributor, the total number of unique products they distribute, and their maximum product price. Sort the view by maximum product price in descending order.
b Write a query using DistributorPerformance to find distributors who distribute more than three unique products and have a maximum product price above
SQL in applications
a Write a Python function updateprintertypemodel newtype to update the type of a printer in the Printer table and cascade the changes to reduce the price of all associated distributors by
b Create a Python function findtopdistributorslimit that retrieves the top limit distributors based on the total price of all products they distribute. Return the result as a list of dictionaries.
c Develop a Python function reassigndistributorproductsdistributorname, newdistributor to move all products handled by a specific distributor to another distributor and log this change in a table DistributorReassignments olddistributor, newdistributor, reassignmentdate
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
