DBMS Set 2
DBMS Set 2
19. Consider the following relational schema for a Loan database application:
Customer {Customer_id, Customer_name, Age, phone_no}
Loan { Loan_id, Amount, Customer_id)}
Include the constraint on Loan_id that it starts with letter ‘L’.
Display the list of the customer_ids and total Loan amount taken.
Display the Customer_id and Customer_name who have taken less than two loans.
21. Write a procedure called proc_udate is created and stored in the database. This procedure
when called in PL/SQL block updates the qty_on_hand in the product_master table it also
updates the order_status in the sales_order table.
Prodct_master { product_no, description, profit_percentage, unit_measure,
qty_on_hand, recorder_level, sell_price, cost_price }
Sales_order {order_no, order_date, client_no, dely_address, salesman_no, dely_type,
billed_yn, delay_date, order_status }
22. Consider the following database consisting of the following tables:
Hostel (hno, hname, type [boys/girls])
Menu (hno, day, breakfast, lunch, dinner)
Warden (wname, qual, hno)
Student (sid, sname, gender, year, hno)
Display the total number of girls and boys hostel in the college.
Display the menu in the hostel ‘x’ on Tuesday.
Display the number of wardens for each hostel.II.
24. Create an Employee table with an attributes { empid, empname, department designation,
Gross_salary . Using cursor, select the five highest paid employees from the Employee table.
Consider the employee relational database, Where the primary keys are underlined.
Employee ( employee_name, street, city)
Works ( employee_name, company_name, salary)
Company ( comapny_name, city)
Manages ( employee_name, manager_name)
Find all employees in the database who earn more than each employee of Small Bank
Corporation.
Assume that the companies may be located in several cities. Find all companies located
in every city in which Small Bank Corporation is located.
Give all managers of first Bank Corporation a 10 percent raise unless the salary
becomes greater than $100,000; in such cases, give only a 3 percent raise.
25. Consider the following relational schema:
Employee( empno, name, office, age )
Books ( isbn, title, authors, publisher )
Loan ( empno, isbn, date )
Write the following queries in SQL:
Print the names of employees who have borrowed any books published by McGraw-Hill.
Print the names of employees who have borrowed all books published by McGraw-Hill.
For each publishers, print the names of employees who have borrowed more than five
books of that publisher.