TotalAmount column in the orders table always stays accurate.
Whenever an OrderDetails record is inserted, updated, or deleted, the trigger should
automatically recalculate the total amount of the affected orders as the sum of (Quantity x
Price) for all its items. If all OrderDetails of an order are deleted, the total amount of this
order should be set to 0.
For example, if you run the following queries on the table OrderDetails, the corresponding
orders will be updated.
-- test case 1 -> TotalAmount of the orders with OrderID = 3 and OrderID = 5 will be updated
INSERT OrderDetails (OrderID, ItemID, Quantity, Price)
VALUES (3, 2, 3, 75000.00), (5,27,2,40000.00)
-- test case 2 -> TotalAmount of the order with OrderID = 6 will be updated
9 of 9
Paper No: 7
delete from OrderDetails where OrderID = 6 and ItemID = 1
Question 10:
Write SQL statements to create a new reservation for a customer. The reservation should be
made for CustomerID = 7, with 5 guests, on November 20, 2025, at 19:15 PM. The
ReservationID should be 210.
After inserting the reservation into the Reservations table, assign the reservation to a table in
the Reservation Tables table. The assigned table should be the one with the smallest
TableID among all tables that have a capacity greater than or equal to 5.
Zoom
+100%
Close