Question 21
with total(name, capacity) as select district_name, sum(capacity) from water_schemes group by district_name with total_avg(capacity) as select avg(capacity) from total select name from total, total_avg where total.capacity >= total_avg.capacity
Question 22
SELECT sch-name, COUNT (*)
FROM School C, Enrolment E, ExamResult R
WHERE E.school-id = C.school-id
AND
E.examname = R.examname AND E.erollno = R.erollno
AND
R.marks = 100 AND S.school-id IN (SELECT school-id
FROM student
GROUP BY school-id
HAVING COUNT (*) > 200)
GROUP By school-id
/* Add code here. Remove these lines if not writing code */
Question 24
FREQUENTS(student, parlor) giving the parlors each student visits. SERVES(parlor, ice-cream) indicating what kind of ice-creams each parlor serves. LIKES(student, ice-cream) indicating what ice-creams each parlor serves. (Assuming that each student likes at least one ice-cream and frequents at least one parlor)Express the following in SQL: Print the students that frequent at least one parlor that serves some ice-cream that they like.
Question 25
COURSES(Cno, name) PRE-REQ(Cno, pre_Cno) COMPLETED(student_no, Cno)COURSES give the number and the name of all the available courses. PRE-REQ gives the information about which course are pre-requisites for a given course. COMPLETED indicates what courses have been completed by students. Express the following using relational algebra:
List all the courses for which a student with student_no 2310 has completed all the pre-requisites.
Question 26
EMP (eno name, age) PROJ (pno name) INVOLVED (eno, pno)EMP contains information about employees. PROJ about projects and INVOLVED about which employees involved in which projects. The underlined attributes are the primary keys for the respective relations. a). What is the relational algebra expression containing one or more of {σ,π,x,u,−} which is equivalent to SQL query.
select eno from EMP, INVOLVED where EMP.eno=INVOLVED.eno and INVOLVED.pno=3b). State in English (in not more than 15 words). What the following relational algebra expressions are designed to determine
(i) πeno(INVOLVED) − πeno((πeno(INVOLVED) X πpno(PROJ))−INVOLVED) (ii) πage(EMP) − πEage<EMP.age(ρE(EMP) x EMP))(Note: ρE(EMP) conceptually makes a copy of EMP and names it K (ρ is called the rename operator))
Question 27
EmployeeDetail (EmpId, FullName, ManagerID, DateOfJoining) EmployeeSalary (EmpID, Project, Salary)Consider the following relational query on the above database:
SELECT Salary FROM EmployeeSalary Emp1 WHERE 2 = ( SELECT COUNT( DISTINCT ( Emp2.Salary ) ) FROM EmployeeSalary Emp2 WHERE Emp2.Salary > Emp1.Salary )Assume that relations corresponding to the above schema are not empty. Which one of the following is the correct interpretation of the above query?
Question 28
SELECT B.isbn, S.copies FROM Book B INNER JOIN Stock S ON B.isbn = S.isbn;Query 2:
SELECT B.isbn, S.copies FROM B B LEFT OUTER JOIN Stock S ON B.isbn = S.isbn;Query 3:
SELECT B.isbn, S.copies FROM Book B RIGHT OUTER JOIN Stock S ON B.isbn = S.isbn;Query 4:
SELECT B.isbn, S.copies FROM B B FULL OUTER JOIN Stock S ON B.isbn = S.isbn;Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?
Question 29
There are 66 questions to complete.