Question: Consider the following relational schema: Product ( maker , model, type ) Distributor ( model , name, price ) PC ( model , speed, ram,

Consider the following relational schema:
Product(maker, model, type)
Distributor(model, name, price)
PC(model, speed, ram, hd)
Laptop(model, speed, ram, hd, screen)
Printer(model, color, type)
The name attribute in the Distributor table represents the name of a distributor (and a maker can also be a distributor).
1. 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 DistributorNotifications(distributor_name, notification_date, model).
c. If a printers type is updated, ensure all associated distributors of that printer reduce their prices by 10%.
2. 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 1000.
3. SQL in applications
a. Write a Python function update_printer_type(model, new_type) to update the type of a printer in the Printer table and cascade the changes to reduce the price of all associated distributors by 10%.
b. Create a Python function find_top_distributors(limit) 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 reassign_distributor_products(distributor_name, new_distributor) to move all products handled by a specific distributor to another distributor and log this change in a table DistributorReassignments (old_distributor, new_distributor, reassignment_date).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!