chapter
    Relational Algebra and SQL Queries PYQs for GATE DA

    Solve 9+ Relational Algebra and SQL Queries previous year questions for GATE DA with answers and detailed solutions. Free sample questions below.

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    2026 PYQ
    Let Account be a relation as shown.

    Account
    AccNo Balance
    A1 5000
    A2 5000
    A3 10000
    A4 15000
    A5 18000

    Consider the given SQL query.

    SELECT AccNo FROM Account AS A
    WHERE (SELECT COUNT(*) FROM Account AS B
    WHERE A.Balance < B.Balance) >= (SELECT COUNT(*)
    FROM Account AS C WHERE A.Balance > C.Balance)

    The number of rows returned by the SQL query is __________ . (Answer in integer)
    Question 2
    2026 PYQ
    Let there be two relations and as shown. has three columns and . has two columns and .


         
    P1   Q1   R1
    P2   Q2   R2
    P3   Q3   R2


      
    P1   10
    P1   15
    P2   20
    P3   1

    Consider that the following tuple relational calculus expression is evaluated.



    The number of tuples that will be returned is __________ . (Answer in integer)
    Question 3
    2026 PYQ
    Consider a table Employee(EmpID, TeamID), where the column EmpID (ID of an employee) is the primary key. The column TeamID denotes the team ID of the team of which the employee is a member. TeamID is a NOT NULL column.

    We want to display the size of the team (denoted as TeamSize) in which each employee is a member by using SQL. As an example, the desired output for the given Employee table is also shown in tabular form.

    Which of the following is/are correct?

    Employee
    EmpID TeamID
    1 8
    2 8
    3 8
    4 7
    5 7
    6 9

    Output
    EmpID TeamSize
    1 3
    2 3
    3 3
    4 2
    5 2
    6 1
    Question 4
    2026 PYQ
    Consider the given relations and . The relation has three columns and . The relation has three columns and . The relation has two columns and .


         
    P1   Q1   R1
    P2   Q2   R2
    P3   Q3   R2


         
    P1   Q1   2
    P1   Q2   5
    P2   Q1   6
    P3   Q3   1


      
    P1   T1
    P3   T2
    P4   T3
    P4   NULL

    Consider the relational algebra expression



    where denotes natural join operation.

    Which of the following options is the correct output for the given expression?
    Question 5
    2025 PYQ
    Consider the following tables, Loan and Borrower, of a bank.

    Loan
    loan_num branch_name amount
    L11 Banjara Hills 90000
    L14 Kondapur 50000
    L15 SR Nagar 40000
    L22 SR Nagar 25000
    L23 Balanagar 80000
    L25 Kondapur 70000
    L19 SR Nagar 65000

    Borrower
    customer_name loan_num
    Anand L11
    Karteek L11
    Karteek L14
    Ankita L15
    Gopal L19
    Karteek L22
    Karteek L23
    Sunil L23
    Sunil L25

    Query: \pi_{\text{branch_name}, \text{customer_name}}(\text{Loan} \bowtie \text{Borrower}) \div \pi_{\text{branch_name}}(\text{Loan})
    where denotes natural join.
    The number of tuples returned by the above relational algebra query is
    (Answer in integer)
    Question 6
    2025 PYQ
    Consider the following three relations:

    Car (model, year, serial, color)
    Make (maker, model)
    Own (owner, serial)

    A tuple in Car represents a specific car of a given model, made in a given year, with a serial number and a color. A tuple in Make specifies that a maker company makes cars of a certain model. A tuple in Own specifies that an owner owns the car with a given serial number. Keys are underlined; (owner, serial) together form key for Own. ( denotes natural join)


    Which one of the following options describes what the above expression computes?
    Question 7
    2025 PYQ
    On a relation named Loan of a bank:

    Loan
    loan number branch name amount
    L11 Banjara Hills 90000
    L14 Kondapur 50000
    L15 SR Nagar 40000
    L22 SR Nagar 25000
    L23 Balanagar 80000
    L25 Kondapur 70000
    L19 SR Nagar 65000

    the following SQL query is executed.

    SELECT L1.loan number
    FROM Loan L1
    WHERE L1.amount > (SELECT MAX (L2.amount)
                        FROM Loan L2
                        WHERE L2.branch name = ’SR Nagar’);

    The number of rows returned by the query is (Answer in integer)
    Question 8
    2024 PYQ
    Consider the following two tables named Raider and Team in a relational database
    maintained by a Kabaddi league. The attribute ID in table Team references the
    primary key of the Raider table, ID.

    Raider
    IDNameRaidsRaidPoints
    1Arjun200250
    2Ankush190219
    3Sunil150200
    4Reza150190
    5Pratham175220
    6Gopal193215

    The SQL query described below is executed on this database:

    SELECT *
    FROM Raider, Team
    WHERE Raider.ID=Team.ID AND City=“Jaipur” AND
    RaidPoints > 200;

    The number of rows returned by this query is ______.

    Team
    CityIDBidPoints
    Jaipur2200
    Patna3195
    Hyderabad5175
    Jaipur1250
    Patna4200
    Jaipur6200
    Question 9
    2024 PYQ
    Consider a database that includes the following relations:
    Defender(name, rating, side, goals)
    Forward(name, rating, assists, goals)
    Team(name, club, price)
    Which ONE of the following relational algebra expressions checks that every name
    occurring in Team appears in either Defender or Forward, where denotes the
    empty set?
    Free preview ends here

    Login to view the complete previous-year questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Relational Algebra and SQL Queries PYQs for GATE DA

    Solve 9+ Relational Algebra and SQL Queries previous year questions for GATE DA with answers and detailed solutions. Free sample questions below.

    Chapter Roadmap: Relational Algebra and SQL Queries

    Your Learning Journey
    1

    Relational Algebra & Semantics

    Formal query language using mathematical operations. Highest weightage topic.

    2

    SQL Joins, Aggregation & Grouping

    Practical SQL implementation with table combinations and summary computations.

    3

    SQL Subqueries & Evaluation

    Nested queries and execution semantics. Understand internal processing.

    By the end of this chapter, you will:
    • Write queries in both relational algebra and SQL
    • Predict query results for any given database instance
    • Understand join semantics and aggregation behavior
    • Analyze nested queries and their execution order

    What is Relational Algebra?

    The Core Idea

    Relational algebra is a procedural query language that operates on relations (tables) to produce new relations.

    InputOne or two relations
    OutputA new relation (table)
    ProceduralSpecifies how to get the result
    ComposableOutput becomes next input

    The Six Fundamental Operations

    OperationSymbolPurpose
    SelectFilter rows
    ProjectFilter columns
    UnionCombine rows
    DifferenceRemove rows
    ProductAll combinations
    RenameRename attrs

    Relational Algebra and SQL Queries: Solved Questions with Step-by-Step Explanations (9 Problems)

    Question 1 · Database Management and Warehousing · 2026 NAT
    Let Account be a relation as shown.

    Account
    AccNo Balance
    A1 5000
    A2 5000
    A3 10000
    A4 15000
    A5 18000

    Consider the given SQL query.

    SELECT AccNo FROM Account AS A
    WHERE (SELECT COUNT(*) FROM Account AS B
    WHERE A.Balance < B.Balance) >= (SELECT COUNT(*)
    FROM Account AS C WHERE A.Balance > C.Balance)

    The number of rows returned by the SQL query is __________ . (Answer in integer)
    Question 2 · Database Management and Warehousing · 2026 NAT
    Let there be two relations and as shown. has three columns and . has two columns and .


         
    P1   Q1   R1
    P2   Q2   R2
    P3   Q3   R2


      
    P1   10
    P1   15
    P2   20
    P3   1

    Consider that the following tuple relational calculus expression is evaluated.



    The number of tuples that will be returned is __________ . (Answer in integer)
    Question 3 · Database Management and Warehousing · 2026 MSQ
    Consider a table Employee(EmpID, TeamID), where the column EmpID (ID of an employee) is the primary key. The column TeamID denotes the team ID of the team of which the employee is a member. TeamID is a NOT NULL column.

    We want to display the size of the team (denoted as TeamSize) in which each employee is a member by using SQL. As an example, the desired output for the given Employee table is also shown in tabular form.

    Which of the following is/are correct?

    Employee
    EmpID TeamID
    1 8
    2 8
    3 8
    4 7
    5 7
    6 9

    Output
    EmpID TeamSize
    1 3
    2 3
    3 3
    4 2
    5 2
    6 1
    1. A. SELECT E.EmpID, B.TeamSize
      FROM Employee AS E, (SELECT TeamID, COUNT(TeamID) AS TeamSize FROM Employee GROUP BY TeamID) AS B
      WHERE E.TeamID = B.TeamID
    2. B. SELECT A.EmpID, COUNT(B.TeamID) AS TeamSize
      FROM Employee AS A, Employee AS B
      WHERE A.TeamID = B.TeamID AND A.EmpID = B.EmpID
      GROUP BY A.EmpID
    3. C. SELECT B.EmpID, B.TeamSize
      FROM (SELECT EmpID, COUNT(TeamID) AS TeamSize
      FROM Employee GROUP BY EmpID) AS B
    4. D. SELECT A.EmpID, B.TeamSize
      FROM Employee AS A, (SELECT COUNT(TeamID) AS TeamSize FROM Employee GROUP BY TeamID) AS B
      WHERE A.TeamID = B.TeamID
    Question 4 · Database Management and Warehousing · 2026 MCQ
    Consider the given relations and . The relation has three columns and . The relation has three columns and . The relation has two columns and .


         
    P1   Q1   R1
    P2   Q2   R2
    P3   Q3   R2


         
    P1   Q1   2
    P1   Q2   5
    P2   Q1   6
    P3   Q3   1


      
    P1   T1
    P3   T2
    P4   T3
    P4   NULL

    Consider the relational algebra expression



    where denotes natural join operation.

    Which of the following options is the correct output for the given expression?
    1. A.

      Two rows (P1, R1, 2) and (P1, R1, 5)

    2. B.

      Three rows (P1, R1, 2), (P1, R1, 5) and (P2, R2, 6)

    3. C.

      One row (P1, R1, 2)

    4. D.

      Zero rows

    Question 5 · Database Management and Warehousing · 2025 NAT
    Consider the following tables, Loan and Borrower, of a bank.

    Loan
    loan_num branch_name amount
    L11 Banjara Hills 90000
    L14 Kondapur 50000
    L15 SR Nagar 40000
    L22 SR Nagar 25000
    L23 Balanagar 80000
    L25 Kondapur 70000
    L19 SR Nagar 65000

    Borrower
    customer_name loan_num
    Anand L11
    Karteek L11
    Karteek L14
    Ankita L15
    Gopal L19
    Karteek L22
    Karteek L23
    Sunil L23
    Sunil L25

    Query: \pi_{\text{branch_name}, \text{customer_name}}(\text{Loan} \bowtie \text{Borrower}) \div \pi_{\text{branch_name}}(\text{Loan})
    where denotes natural join.
    The number of tuples returned by the above relational algebra query is
    (Answer in integer)
    Question 6 · Database Management and Warehousing · 2025 MCQ
    Consider the following three relations:

    Car (model, year, serial, color)
    Make (maker, model)
    Own (owner, serial)

    A tuple in Car represents a specific car of a given model, made in a given year, with a serial number and a color. A tuple in Make specifies that a maker company makes cars of a certain model. A tuple in Own specifies that an owner owns the car with a given serial number. Keys are underlined; (owner, serial) together form key for Own. ( denotes natural join)


    Which one of the following options describes what the above expression computes?
    1. A.

      All owners of a red car, a car made by ABC, or a red car made by ABC

    2. B.

      All owners of more than one car, where at least one car is red and made by ABC

    3. C.

      All owners of a red car made by ABC

    4. D.

      All red cars made by ABC

    Question 7 · Database Management and Warehousing · 2025 NAT
    On a relation named Loan of a bank:

    Loan
    loan number branch name amount
    L11 Banjara Hills 90000
    L14 Kondapur 50000
    L15 SR Nagar 40000
    L22 SR Nagar 25000
    L23 Balanagar 80000
    L25 Kondapur 70000
    L19 SR Nagar 65000

    the following SQL query is executed.

    SELECT L1.loan number
    FROM Loan L1
    WHERE L1.amount > (SELECT MAX (L2.amount)
                        FROM Loan L2
                        WHERE L2.branch name = ’SR Nagar’);

    The number of rows returned by the query is (Answer in integer)
    Question 8 · Database Management and Warehousing · 2024 NAT
    Consider the following two tables named Raider and Team in a relational database
    maintained by a Kabaddi league. The attribute ID in table Team references the
    primary key of the Raider table, ID.

    Raider
    IDNameRaidsRaidPoints
    1Arjun200250
    2Ankush190219
    3Sunil150200
    4Reza150190
    5Pratham175220
    6Gopal193215

    The SQL query described below is executed on this database:

    SELECT *
    FROM Raider, Team
    WHERE Raider.ID=Team.ID AND City=“Jaipur” AND
    RaidPoints > 200;

    The number of rows returned by this query is ______.

    Team
    CityIDBidPoints
    Jaipur2200
    Patna3195
    Hyderabad5175
    Jaipur1250
    Patna4200
    Jaipur6200
    Question 9 · Database Management and Warehousing · 2024 MCQ
    Consider a database that includes the following relations:
    Defender(name, rating, side, goals)
    Forward(name, rating, assists, goals)
    Team(name, club, price)
    Which ONE of the following relational algebra expressions checks that every name
    occurring in Team appears in either Defender or Forward, where denotes the
    empty set?
    1. A.

    2. B.

    3. C.

    4. D.

    More previous year questions (pyqs) in this unit