See the attached file and answer those 4 questions

User Generated

gten

Computer Science

Description

Please if you are not familiar with this assignment let others take it


See the attached file and answer those 4 questions......................................................................................................................................................................................................

Unformatted Attachment Preview

The purpose of this assignment is to give students practice with writing stored procedures. All stored procedures will be based on the database depicted above. Write the stored procedure for each question below and submit it to Blackboard as a word document. 1. Create a stored procedure that lists all the information for all repairs that a customer has had over a given date range sorted by the VIN of the car. The procedure should be named uspListRepairs and should include the customer first name, customer last name, and date range as input parameters. 2. Create a stored procedure that calculates the total cost of repairs for both parts and labor on a given car owned by a given customer. The stored procedure should be named uspCalculateTotalRepairCostByCar and should return a variable named @totalRepairCost. The stored procedure should take the customer first name, customer last name, and VIN number as input. 3. Create a stored procedure that adds a new repair to the database based on a car’s VIN number. The stored procedure should be named uspAddCarRepair and include the repair code, VIN, Employee ID, and date/time as input variables. 4. Create a trigger that updates the total parts and total labor cost of a repair in the Car Repair table when a new repair is added. The stored procedure should be named uspUpdateCost and should include the repair code and VIN as input. Hint: The Repair table contains a set cost for each repair. When a new repair is added, the cost for the repair can be obtained by selecting based on the repair code input.
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

The files below contain complete work of your assignment. Kindly check it and let me know if you need any clarification. Thank you.

/*QUESTION 1*/
DELIMITER $$
CREATE PROCEDURE uspListRepairs(IN First_Name VARCHAR(30), IN Last_Name
VARCHAR(30), IN FromDateTime TIMESTAMP, IN TomDateTime TIMESTAMP)
BEGIN
SELECT * FROM Car ca, `Car Repair` cr, CUSTOMER cu, `Repair` re,
Technician te
WHERE Cu.First_Name=First_Name AND Cu.Last_Name=Last_Name AND
cr.`DateTime` BETWEEN FromDateTime AND TomDateTime
AND cu.Customer_ID=ca.Customer_ID AND ca.VIN=cr.VIN AND
cr.Repair_Code=Re.Repair_Code AND cr.Employee_ID=te.Employee_ID
ORDER BY ca.VIN ASC;
END$$
CALL uspListRepairs('', '', '2008-01-01 00:00:01','2018-01-01 00:00:01');
/*QUESTION 2*/
DELIMITER $$
CREATE PROCEDURE uspCalculateTotalRepairCostByCar(IN First_Name VARCHAR(30), IN
Last_Name VARCHAR(30), IN VIN INT, OUT totalRepairCost DOUBLE)
BEGIN
SELECT SUM(cr.Total_Cost_Parts+cr.Total_Cost_Labor) INTO @totalRepairCost
FROM Car ca, `Car Repair` cr, CUSTOMER cu
WHERE Cu.First_Name=First_Name AND Cu.Last_Name=Last_Name AND ca.VIN=VIN
AND cu.Customer_ID=ca.Customer_ID AND ca.VIN=cr.VIN ;
Select @totalRepairCost into totalRepairCost;
END$$
/*QUESTION 3*/
DELIMITER $$
CREATE PROCEDURE uspAddCarRepair(IN inRepair_Code ...


Anonymous
I was having a hard time with this subject, and this was a great help.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags