SQL

Last Updated :
Discuss
Comments

Question 1

Table A:

Screenshot-2026-02-24-153509

Table B:

Screenshot-2026-02-24-153536

Table C:

Screenshot-2026-02-24-153933

Consider the above tables A, B and C. How many tuples does the result of the following SQL query contains?

SELECT A.id 
FROM   A 
WHERE  A.age > ALL (SELECT B.age 
                    FROM   B 
                    WHERE  B. name = "arun") 
  • 4

  • 3

  • 0

  • 1

Question 2

A table T(X, Y) initially has one record (1, 1). New records are inserted 128 times with:

X = MX + 1, Y = 2*MY + 1

where MX and MY are the current maximums of X and Y.What will MAX(X) and MAX(Y) be after all insertions?

SELECT Y FROM T WHERE X=7;
  • 127

  • 255

  • 129

  • 257

Question 3

Database table by name Loan_Records is given below.

Screenshot-2026-02-24-161349

What is the output of the following SQL query?

SELECT Count(*) 
FROM  ( ( SELECT Borrower, Bank_Manager 
          FROM Loan_Records) AS S 
          NATURAL JOIN ( SELECT Bank_Manager, Loan_Amount 
                         FROM Loan_Records) AS T );
  • 3

  • 9

  • 5

  • 6

Question 4

A relational schema for a train reservation database is given below. Passenger (pid, pname, age) Reservation (pid, class, tid)

Table: Passenger

Screenshot-2026-02-24-164256

Table : Reservation

Screenshot-2026-02-24-164523

What pids are returned by the following SQL query for the above instance of the tables?

SLECT pid
FROM Reservation ,
WHERE class ‘AC’ AND
    EXISTS (SELECT *
       FROM Passenger
       WHERE age > 65 AND
       Passenger. pid = Reservation.pid)
  • 1, 0

  • 1, 2

  • 1, 3

  • 1, 5

Question 5

Let R and S be relational schemes such that R={a,b,c} and S={c}. Now consider the following queries on the database:

gateqa
IV) SELECT R.a, R.b
FROM R,S
WHERE R.c=S.c

Which of the above queries are equivalent?

  • I and II

  • I and III

  • II and IV

  • III and IV

Question 6

Consider the following relational schema: 
 

Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)


Consider the following relational query on the above database: 
 

SELECT S.sname
FROM Suppliers S
WHERE S.sid NOT IN (SELECT C.sid
FROM Catalog C
WHERE C.pid NOT IN (SELECT P.pid
FROM Parts P
WHERE P.color<> 'blue'))


Assume that relations corresponding to the above schema are not empty. Which one of the following is the correct interpretation of the above query?
 

  • Find the names of all suppliers who have supplied a non-blue part.
     

  • Find the names of all suppliers who have not supplied a non-blue part.
     

  • Find the names of all suppliers who have supplied only blue parts.
     

  • Find the names of all suppliers who have not supplied only blue parts.
     

Question 7

A library relational database system uses the following schema

USERS (User#, UserName, HomeTown)
BOOKS (Book#, BookTitle, AuthorName)
ISSUED (Book#, User#, Date)

Explain in one English sentence, what each of the following relational algebra queries is designed to determine  

 
  •  Show all the Book Title which have been issued by User# 6.

  •  The user who’s home town is Delhi and issued a book, Show all the name authors of the book he/she have issued.

Question 8

Consider the set of relations given below and the SQL query that follows

Students : (Roll number, Name, Date of birth)
Courses: (Course number, Course name, instructor)
Grades: (Roll number, Course number, Grade)
SELECT DISTINCT Name
FROM Students, Courses, Grades
WHERE Students.Roll_number = Grades.Roll_number
AND Courses.Instructor =Sriram
AND Courses.Course_number = Grades.Course_number
AND Grades.Grade = A

Which of the following sets is computed by the above query?

  • Names of Students who have got an A grade in all courses taught by Sriram

  • Names of Students who have got an A grade in all courses

  • Names of Students who have got an A grade in at least one of the courses taught by Sriram

  • None of the above

Question 9

Consider the following relational schema:

Suppliers(sid:integer, sname:string, city:string, street:string)
Parts(pid:integer, pname:string, color:string)
Catalog(sid:integer, pid:integer, cost:real)

Consider the following relational query on the above database:

SELECT S.sname
FROM Suppliers S
WHERE S.sid NOT IN (SELECT C.sid
FROM Catalog C
WHERE C.pid NOT IN (SELECT P.pid
FROM Parts P
WHERE P.color<> 'blue'))

Assume that relations corresponding to the above schema are not empty. Which one of the following is the correct interpretation of the above query?

  • Find the names of all suppliers who have supplied a non-blue part.

  • Find the names of all suppliers who have not supplied a non-blue part

  • Find the names of all suppliers who have supplied only non blue parts.

  • Find the names of all suppliers who have not supplied only non-blue parts.

Question 10

Which of the following is true ? I. Implementation of self-join is possible in SQL with table alias. II. Outer-join operation is basic operation in relational algebra. III. Natural join and outer join operations are equivalent.
  • I and II are correct.
  • II and III are correct.
  • Only III is correct.
  • Only I is correct.

There are 66 questions to complete.

Take a part in the ongoing discussion