Assume that FiredUp has created a database with the following tables:
CUSTOMER (CustomerSK, Name, Phone, EmailAddress)
STOVE (SerialNumber, Type, Version, DateOfManufacture)
REGISTRATION (CustomerSK, SerialNumber, Date)
STOVE_REPAIR (RepairInvoiceNumber, SerialNumber, Date, Description, TotalCost, TotalPaid, CustomerSK)
A. Create a view called RepairSummary that shows only RepairInvoiceNumber, TotalCost, and TotalPaid
B. Show a SQL statement to retrieve all RepairSummary data sorted by TotalCost.
C. Create a view called CustomerRepair that shows CUSTOMER.Name and STOVE_REPAIR.SerialNumber, Date, Description, and TotalDue, where TotalDue is the difference between TotalCost and TotalPaid.
D. Suppose that FiredUp has the rule that a customer's record can be deleted only if TotalPaid is equal to TotalCost in all repair records. Explain how you would use a trigger to enforce this rule. What type of trigger would you use? On which table would you place the trigger? Show the SQL statements that you would code, but write the rest of the trigger in generic code.
This deals with creation of views using SQL statements. Also some other operations involving views are included.