IMP
IMP
Q1) Consider the following relational database employee (employee_name, street, city works
(employee_name, company_name, salary) company (company_name, city) manage
(employee_name, manager_name). Give an expression in SQL to express each of the following
queries:
i. Find the names and cities of residence of all employees who work for XYZ bank.
ii. Find the names, street address, and cities of residence of all employee who works for
XYZ Bank and earn more than Rs. 10,000 per annum.
iii. Find the names of all employees in this database who live in the same city as the
company for which they work.
Q2) Consider the following relation. The primary key is Rollno, ISBN, Student(Roll No,
Name, Branch), Book(ISBN, Title, Author, Publisher) Issue(Roll No, ISBN, date_of_issue).
Write the query in relational algebra and SQL of the following:
i. List the Roll Number and Name of All CSE Branch Students.
ii. Find the name of students who have issued a book of publication ‘BPB’.
iii. List the title and author of all books which are issued by a student name started
with ‘a’.
iv. List the title of all books issued on or before 20/09/2012.
v. List the name of student who will read the book of author named ‘Sanjeev’.
Q3) Suppose there are two relations R(A, B, C), S(D, E, F). Write TRC and SQL for the
following RAs :
i. A, B (R)
ii. B = 45 (R)
iii. A, F(C = D(R × S))
Q4) Consider the following relational DATABASE. Give an expression in SQL for each
following queries. Underline records are primary key Employee(person_name, street, city)
Works(person_name, Company_name, salary) Company(Company_name, city)
Manages(person_name, manager_name)
i. Finds the names of all employees who works for the ABC bank.
ii. Finds the name of all employees who live in the same city and on the same street as
do their managers.
iii. Find the name street address and cities of residence of all employees who work for
ABC bank and earn more than 7,000 per annum.
iv. Find the name of all employee who earn more than every employee of XYZ.
v. Give all employees of corporation ABC a 7% salary raise. vi. Delete all tuples in
the works relation for employees of ABC. vii. Find the name of all employees in
this DATABASE who live in the same city as the company for which they work.