You are on page 1of 6

Department of Computer Science & Engineering

Database Management System – 18CS53

Question Bank

Second IA (Module 2)

1. Explain ER to relational mapping algorithm with suitable example for each. (10M)
2. Consider the two tables:
T1 T2
P Q R A B C
10 a 5 10 b 6
15 b 8 25 c 3
25 a 6 10 b 5

Show the results of the following:


i) T1 ⨝ T1. P = T2. AT ii) T1 ⨝ T1. Q = T2. BT2
iii) T1 ⟕T1. P = T2. AT2 iv) T1 ⟖ T1. Q = T2. BT2
3. T1 ⨝ (T1. P = T2. A) AND (T1.R = T2.C)T2
4. Discuss equi-join and natural join with suitable example. (5M)
5. Explain the relational algebra operations from Set theory, with examples. (6 M)
6. With an example for each, explain the purpose and notation for the following
operations of relational algebra:
i. SELECT ii) PROJECT iii) UNION

ii. CARTESIAN PRODUCT v) DIVISION


7. Explain with examples in SQL: (i) INSERT command (ii) UPDATE command (4 M)
8. Write the SQL syntax with example for the following (6 M)
I. Alter II. Insert III. Update
9. Write a command that is used for table creation. Explain how constraints are specified
in SQL during table creation with suitable example. (5M)
10. Consider the following relational schema
SALESPERSON (SSN, NAME, START_YEAR, SEX, DEPT_NO)
TRIP (SSN, FROM_CITY, TO_CITY, DEP_DATE, RET_DATE, TRIP_ID,
DESCRIPTION)
Department of Computer Science & Engineering

EXPENSE(TRIP_ID, ACC_NO, AMOUNT, REMARKS)


Write the relational algebra queries for the following:
a. Give the details for trips that exceeded 5000 dollars in expense.
b. Print the SSN and names of salesman who took trips to “San Fransico”.
c. Print the total trip expenses incurred by the salesman with the name
“RAJARAM”.
11. Consider the following relational schema:
STUDENT (STUD_ID, SNAME, MAJOR, GPA)
FACULTY (FAC_ID, FNAME, DEPT, DESIG, SAL)
COURSE (CID, CNAME, FAC_ID)
ENROLL (CID, S_ID, GRADE)
Write the relational algebra queries for the following:
a. List the names of all students enrolled for the course ‘CS-53’.
b. List the names of students enrolled for the course ‘CS-53’ and have received
‘A’ grade.
c. List the departments where the salary is greater than Rs 20,000/-.
12. Explain different aggregate functions with and SQL example. (10 M)
13. Explain how Group by and Having clause works with respect to SQL. (6 M)
14. What are basic data types available for attributes in SQL? Explain with examples.
(6M)
15. Consider the following COMPANY database

EMP(Name,SSN,Salary,SuperSSN,Gender,Dno)

DEPT(DNum,Dname,MgrSSN,Dno)

DEPT_LOC(Dnum,Dlocation)

DEPENDENT(ESSN,Dep_name,Sex)

WORKS_ON(ESSN,Pno,Hours)

PROJECT(Pname,Pnumber,Plocation,Dnum)
Department of Computer Science & Engineering

Write the relational algebra queries for the following ( 10 M)

(i) Retrieve the name, address, salary of employees who work for the Research
department.
(ii) find the names of employees who work on all projects controlled by
department number4.
(iii) Retrieve the SSN of all employees who either in department no :4 or directly
supervise an employee who work in department number :4
(iv) Retrieve the names of employees who have no dependents
(v) Retrieve each department number, the number of employees in the department
and their average salary.
16. Consider the following relation schema (10 M)

Works(Pname,Cname,salary)

Lives(Pname,Street,City)

located_in (Cname, city)

Manager(Pname,Mgrname)

Write the SQL queries for the following

i) Find the names of all persons who live in the city Bangalore.
ii) Retrieve the names of all person of "Infosys" whose salary is between
Rs .50000
iii) Find the names of all persons who lives and work in the same city
iv) List the names of the people who work for “Tech M” along with the cities they
live in.
v) Find the average salary of “Infosys” persons
17. Consider the following COMPANY database( 10 marks)

EMP(Name,SSN,Salary,SuperSSN,Dno)

DEPT(DNum,Dname,MgrSSN,Dno)
Department of Computer Science & Engineering

DEPT_LOC(Dnum,Dlocation)

DEPENDENT(ESSN,Dep_name,Sex)

WORKS_ON(ESSN,Pno,Hours)

PROJECT(Pname,Pnumber,Plocation,Dnum)

Write the SQL queries for the following (10 M)

i) Retrieve the name of the employee who works with same department as ravi
ii) Retrieve the number of dependents for an employee “Ravi”
iii) Retrieve the name of the managers working in location “DELHI”who has no
female dependents
iv) List female employees from Dno=20 earning more than 50000
v) List “CSE” department details
18. Consider the following scheme
Sailors (Sid, Sname, Rating, age)
Boats (Bid, Bname, Color)
Reserves (Sid, Bid, Day)

Write the SQL queries for the following (10 M)

I. Find the name of sailors who have reserved boat no. #103.
II. Find the name of sailors who have reserved red boat.
III. Find the name of sailors who have reserved red or green boat.
IV. Find the name of sailors who have reserved all boat.
V. Count the number of Red boats.
19. Explain unary relation operations with an example. (6 M)

Module 3

1. How to create views in SQL? Explain with an example. (6 M)


2. How are triggers defined in SQL? Explain with examples. (5 M)
Department of Computer Science & Engineering

3. Illustrate insert, delete, alter, drop and update statements in SQL with examples. (10
M)
4. How are assertions and triggers defined in SQL? Explain with examples. (10 M)
5. Explain correlated nested queries with examples. (5 M)
6. Consider the following COMPANY database( 10 marks)

EMP(Name,SSN,Salary,SuperSSN,Dno)

DEPT(DNum,Dname,MgrSSN,Dno)

DEPT_LOC(Dnum,Dlocation)

DEPENDENT(ESSN,Dep_name,Sex)

WORKS_ON(ESSN,Pno,Hours)

PROJECT(Pname,Pnumber,Plocation,Dnum)

Write the SQL queries for the following (10 M)

i) Retrieve the name of the employee who works with same department as ravi
ii) Retrieve the number of dependents for an employee “Ravi”
iii) Retrieve the name of the managers working in location “DELHI”who has no
female dependents
iv) List female employees from Dno=20 earning more than 50000
v) List “CSE” department details
7. Consider the following relational schema
MEMBERS (MEM_ID, NAME, DESIGNATION, AGE)
BOOKS (BID, BTITLE, BAUTHORS, BPUBL, BPRICE)
RESERVES (MEM_ID, BID, DATE)
a. Find the names of members who are professors older than 45 years.
b. List the titles of books reserved by professors.
c. Find the ids of members who have not reserved books that costs more than Rs
500.
d. Find the authors and titles of the books reserved on 07-May-2007.
Department of Computer Science & Engineering

e. Find the names of members who have reserved all the books.

You might also like