DBMS Lab Assignment-9
DBMS Lab Assignment-9
1. Consider the tables ‘Customers’ and ‘Orders’ with the given schema and data as follows:
Table: Customers
Table: Orders
For the above scenario, write SQL queries for the following:
a) Write a trigger that automatically updates a customer’s status to 'active' whenever they place
a new order.
b) Write a trigger that prevents a new order from being inserted into the Orders table if the
customer’s status is 'inactive'.
c) Create a trigger that automatically updates the status of an order to 'confirmed' if the
‘total_amount of the order exceeds $1000.
d) Create a trigger that updates a total_orders column in the Customers table every time an
order is inserted or deleted in the Orders table.
e) Write a trigger that sets the default status of an order to 'pending' if no status is provided
during the order insertion.
f) Create a trigger that prevents the deletion of orders that have the status of 'shipped'.