chapter

    Relational Algebra and Sql Queries Practice Questions for Gate Da

    Solve 760+ Relational Algebra and Sql Queries practice 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
    Level 1: Warm-up

    Let contain tuples and contain . Using the standard division formula , what is the number of tuples in the result?

    Question 2
    Level 1: Warm-up

    Let be a relation with 100 tuples. What is the maximum number of attributes in the result of the expression ?

    Question 3
    Level 1: Warm-up

    Let be a relation. The projection yields exactly 8 distinct values, and yields exactly 6 distinct values. What is the minimum possible number of tuples in the relation ?

    Question 4
    Level 1: Warm-up

    Consider the relations , , , and with the following tuples:

    :

    :

    :

    :

    Match the relational algebra expressions in List I with their resulting number of tuples in List II:

    List I

    I.

    II.

    III.

    IV.

    List II

    1. 2 tuples
    2. 1 tuple

    Which option correctly matches all expressions?

    Question 5
    Level 1: Warm-up

    Which of the following statements about the division operation and the set difference operation is TRUE?

    Question 6
    Level 1: Warm-up

    Consider relations with 8 tuples and with 3 tuples. If the natural join yields exactly 8 tuples, what is the MINIMUM possible number of distinct values in ?

    Question 7
    Level 1: Warm-up

    Consider the division operation , where has attributes and has attribute . Which of the following statements about is TRUE?

    Question 8
    Level 1: Warm-up

    Consider the English query: "Find the IDs of employees who work in the IT department". The relations are and . Which of the following Relational Algebra expressions correctly constructs the result?

    Question 9
    Level 1: Warm-up

    Consider the English query: "Find the names of students who have scored above 90 in at least one course". The relations are and . Which of the following Relational Algebra expressions correctly constructs the result?

    Question 10
    Level 1: Warm-up

    Consider the English query: "Find the names of departments that have a budget greater than 100000". The relations are and . Which of the following Relational Algebra expressions correctly constructs the result?

    Free preview ends here

    Login to view the complete practice 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.

    Explore complete test series, official past papers, and chapter-wise study tools.

    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 Practice Questions for GATE DA

    Solve 760+ Relational Algebra and Sql Queries practice 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 (10 Problems)

    Question 1 · Database Management and Warehousing MCQ

    Let contain tuples and contain . Using the standard division formula , what is the number of tuples in the result?

    1. A.

      1

    2. B.

      2

    3. C.

      3

    4. D.

      0

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a direct formula application question for the division operation. The formula computes tuples in that match all tuples in .

    Step 1: Identify . The values in are .

    Step 2: Compute . This pairs every value with every value in : .

    Step 3: Subtract from this product. contains and , but not . The difference is .

    Step 4: Project the difference onto . .

    Step 5: Subtract this from . .

    The number of tuples in the result is 2.

    Question 2 · Database Management and Warehousing MCQ

    Let be a relation with 100 tuples. What is the maximum number of attributes in the result of the expression ?

    1. A.

      4

    2. B.

      2

    3. C.

      5

    4. D.

      0

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is an observation question about the schema preservation property of the select operation.

    Step 1: The select operation filters rows based on a condition but does not alter the schema (columns) of the relation.

    Step 2: The input relation has 4 attributes: .

    Step 3: The condition uses some attributes, but the output still retains all original attributes.

    Step 4: Therefore, the maximum number of attributes in the result is exactly the number of attributes in , which is 4.

    Answer: 4

    Question 3 · Database Management and Warehousing MCQ

    Let be a relation. The projection yields exactly 8 distinct values, and yields exactly 6 distinct values. What is the minimum possible number of tuples in the relation ?

    1. A.

      8

    2. B.

      14

    3. C.

      48

    4. D.

      6

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a minimum bound question using the Pigeonhole Principle via contradiction for multi-column projections.

    Step 1: The projection contains pairs of values.

    Step 2: The number of distinct values in is at most 8 (since has 8).

    Step 3: The number of distinct values in is at most 6 (since has 6).

    Step 4: To minimize the number of tuples in , we must cover all 8 distinct values and all 6 distinct values with as few pairs as possible.

    Step 5: Since each tuple provides exactly one value and one value, we need at least tuples to cover all 8 distinct values.

    Step 6: It is possible to cover all 6 distinct values within these 8 tuples (e.g., by repeating some values).

    The minimum possible number of tuples is 8.

    Question 4 · Database Management and Warehousing MCQ

    Consider the relations , , , and with the following tuples:

    :

    :

    :

    :

    Match the relational algebra expressions in List I with their resulting number of tuples in List II:

    List I

    I.

    II.

    III.

    IV.

    List II

    1. 2 tuples
    2. 1 tuple

    Which option correctly matches all expressions?

    1. A.

      I-1, II-2, III-2, IV-1

    2. B.

      I-2, II-1, III-1, IV-2

    3. C.

      I-2, II-2, III-1, IV-2

    4. D.

      I-1, II-1, III-2, IV-2

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: Natural join matches tuples on common attributes and discards non-matches. Evaluate step-by-step.

    Step 1: Evaluate . Common attribute is .

    Result: 2 tuples. (I matches 2)

    Step 2: Evaluate . Common attribute is .

    • : , no match.

    Result: 1 tuple. (II matches 1)

    Step 3: Evaluate . Common attribute is .

    • : , no match.

    Result: 1 tuple. (III matches 1)

    Step 4: Evaluate . Common attribute is .

    Result: 2 tuples. (IV matches 2)

    Answer: I-2, II-1, III-1, IV-2 (Option B).

    Question 5 · Database Management and Warehousing MCQ

    Which of the following statements about the division operation and the set difference operation is TRUE?

    1. A.

      and always have the same number of attributes.

    2. B.

      If is empty, then must also be empty.

    3. C.

      requires and to be union-compatible, just like .

    4. D.

      The schema of is a subset of the schema of , while has the exact same schema as .

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: Understand the schema and semantic differences between division and set difference.

    Step 1: Analyze Option A.

    • requires union-compatibility, so it has the same schema as .
    • returns attributes from that are NOT in . Thus, it generally has fewer attributes than .
    • Option A is FALSE.

    Step 2: Analyze Option B.

    • empty means no tuple in matches ALL tuples in .
    • empty means .
    • These are independent conditions. can be empty while is not.
    • Option B is FALSE.

    Step 3: Analyze Option C.

    • requires union-compatibility (same number of attributes, compatible domains).
    • requires 's attributes to be a subset of 's attributes. It does NOT require union-compatibility.
    • Option C is FALSE.

    Step 4: Analyze Option D.

    • Schema of = Schema() - Schema(). This is a subset of Schema().
    • Schema of = Schema().
    • Option D is TRUE.

    Answer: Option D.

    Question 6 · Database Management and Warehousing MCQ

    Consider relations with 8 tuples and with 3 tuples. If the natural join yields exactly 8 tuples, what is the MINIMUM possible number of distinct values in ?

    1. A.

      1

    2. B.

      2

    3. C.

      3

    4. D.

      8

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: The size of the natural join depends on the product of matching tuple counts for each distinct value. We need to find the minimum distinct values in that can sum to 8.

    Step 1: Let be the number of tuples in with value , and be the number of tuples in with value .

    • The join size is .
    • We know (total tuples in ) and (total tuples in ).

    Step 2: Test if 1 distinct value in is possible.

    • If has 1 distinct value, then .
    • The join size would be .
    • Since must be an integer, and 8 is not divisible by 3, this is impossible.

    Step 3: Test if 2 distinct values in is possible.

    • Let have and (sum = 3).
    • Let have and (sum = 8).
    • Join size = .
    • This works! uses 2 distinct values.

    Step 4: Since 1 is impossible and 2 is possible, the minimum is 2.

    Answer: 2 (Option B).

    Question 7 · Database Management and Warehousing MCQ

    Consider the division operation , where has attributes and has attribute . Which of the following statements about is TRUE?

    1. A.

      It can be expressed as .

    2. B.

      It returns all tuples of that do not match any tuple in .

    3. C.

      It can be expressed as .

    4. D.

      It always returns a relation with the same schema as .

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: The division operation finds all values that match EVERY value in . Its standard formula uses a double difference.

    Step 1: Analyze the formula for division.

    • The correct expression is .
    • generates all possible pairs for values present in and values in .
    • Subtracting from this gives pairs that are MISSING from .
    • Projecting this on gives all values that are missing at least one value.
    • Subtracting this from leaves values that are missing NO values (i.e., they match all in ).

    Step 2: Evaluate the options.

    • Option A: . Here has attributes (or is invalid if not renamed). It is not union-compatible with . FALSE.
    • Option B: "Returns tuples of not matching any in ". This describes an anti-join or set difference, not division. FALSE.
    • Option C: . This matches the correct double-difference formula. TRUE.
    • Option D: "Same schema as ". Division returns only attribute , not . FALSE.

    Answer: Option C.

    Question 8 · Database Management and Warehousing MCQ

    Consider the English query: "Find the IDs of employees who work in the IT department". The relations are and . Which of the following Relational Algebra expressions correctly constructs the result?

    1. A.

      \pi_{ ext{EID}} ( \sigma_{ ext{DName}= ext{'IT'}} ( ext{Employee} owtie ext{Department}) )

    2. B.

    3. C.

      \pi_{ ext{Name}} ( \sigma_{ ext{DName}= ext{'IT'}} ( ext{Employee} owtie ext{Department}) )

    4. D.

      \sigma_{ ext{DName}= ext{'IT'}} ( \pi_{ ext{EID}} ( ext{Employee} owtie ext{Department}) )

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Translate the English query step-by-step into relational algebra operations.

    Step 1: "work in the IT department" requires filtering by department name. Since is only in the relation, we must join and first.

    Step 2: Apply the selection on the joined result.

    Step 3: "Find the IDs of employees" requires projecting the attribute. So we apply .

    Step 4: Combine these: .

    Answer: A.

    Question 9 · Database Management and Warehousing MCQ

    Consider the English query: "Find the names of students who have scored above 90 in at least one course". The relations are and . Which of the following Relational Algebra expressions correctly constructs the result?

    1. A.

      \pi_{ ext{Name}}(\sigma_{ ext{Score} > 90}( ext{Student} owtie ext{Grades}))

    2. B.

    3. C.

      \pi_{ ext{SID}}(\sigma_{ ext{Score} > 90}( ext{Student} owtie ext{Grades}))

    4. D.

      \sigma_{ ext{Score} > 90}(\pi_{ ext{Name}}( ext{Student} owtie ext{Grades}))

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Translate the English query step-by-step into relational algebra operations, ensuring all required attributes are available at each step.

    Step 1: "scored above 90" requires filtering by the Score attribute. Since Score is only in the Grades relation, we must join Student and Grades first to access it alongside Name.

    Step 2: Apply the selection on the joined result.

    Step 3: "Find the names" requires projecting the Name attribute. So we apply .

    Step 4: Combine these: .

    Answer: A.

    Question 10 · Database Management and Warehousing MCQ

    Consider the English query: "Find the names of departments that have a budget greater than 100000". The relations are and . Which of the following Relational Algebra expressions correctly constructs the result?

    1. A.

    2. B.

      \pi_{ ext{DName}}(\sigma_{ ext{Budget} > 100000}( ext{Employee} owtie ext{Department}))

    3. C.

    4. D.

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Translate the English query step-by-step into relational algebra operations, ensuring all required attributes are available at each step and avoiding unnecessary joins.

    Step 1: "budget greater than 100000" requires filtering by the Budget attribute. Since Budget is only in the Department relation, we apply the selection on Department.

    Step 2: "Find the names of departments" requires projecting the DName attribute. So we apply .

    Step 3: Notice that the Employee relation is not needed because all required attributes (Budget and DName) are already in the Department relation. Joining with Employee would be unnecessary.

    Step 4: Combine these: .

    Answer: A.

    More practice questions in this unit