DBMS-Set 1 (1,5,7)
DBMS-Set 1 (1,5,7)
DBMS-Set 1 (1,5,7)
Q.1 a) Create a conditional trigger that prints salary change information whenever a delete, insert or update (15 M)
statement affects the employees table—unless that information is about the President. The database
evaluates the ‘when’ condition for each affected row. If the ‘when’ condition is true for an affected
row, then the trigger fires for that row before the triggering statement runs. If the when condition is
not true for an affected row, then trigger does not fire for that row, but the triggering statement still
runs.
b) Create a log table and a trigger that inserts a row in the log table after any update statement affects the
salary column of the employees table, and then updates employees.salary and show the log table.
-------Use the below schema for the table:
Q.2 Consider the following database for storing business related information. A customer table can be (15 M)
described with a unique customer id, customer name, annual revenue and customer type. A Shipment
table has a unique shipment id, customer id, weight (in pounds), truck id, destination and shipping date.
Each Truck table must have a unique truck id and its driver’s name. City table which consists of city
name and its population in millions(1million=1000000).
The schema of tables is as follows:
Write the SQL queries for the following (based on the schema that are given):-
a) List the cities that have received shipments from customers having over 4 million in annual
revenue.
b) Display the city names having population over 700 which have received a 100-pound package
from customer 101
c) List the customers who are manufacturers or have sent a package to Manali.
d) Display the customers having over $5 million in annual revenue who have sent shipments
weighing less than 1 pound or have sent a shipment to Vishakhapatnam?
e) Create a view for the Customers with annual revenue between $1 million and $2 million and
then list populations of cities along with city name which have received shipments from
customers with revenue between $1 million and $2 million?
.
*******************************