GATE CSE · subject-wise

GATE Databases (DBMS) previous year questions

73 questions from GATE papers, newest first, each with the official answer and a worked explanation.

Practise Databases (DBMS) with instant checking
GATE 2026 · Q17MCQ1 mark · -1/3· Moderate

Let R(A,B,C,D,E) be a relational schema with functional dependency set F = {A → BC, CD → E, E → A}. Which of the following statements is correct?

  1. (A)AD, ED and CD are the only candidate keys of R.
  2. (B)AD and ED are the only candidate keys of R.
  3. (C)A, E and CD are the only candidate keys of R.
  4. (D)A and CD are the only candidate keys of R.
Answer: A - show solution

D appears on no right-hand side, so every key contains D. AD+ = {A,D} → BC → CD gives E: all attributes. ED+: E → A, A → BC: all. CD+: CD → E, E → A, A → B: all. Single D alone gives only D. BD+ = {B,D}, not a key. Each of AD, ED, CD is minimal (A, E, C alone do not give D). Any other key containing D would be a superset of these. Answer: (A) AD, ED and CD.

Concept: Attributes never on a right side must be in every key. The trap is (C), forgetting that D can never be derived.

GATE 2026 · Q26MSQ1 mark · no negative· Easy

Consider two relations r and s defined on the relational schemas R(A,B) and S(E,C), respectively. A is the primary key of R and E is a foreign key of S referencing A in R. Which of the following operations will NEVER violate the foreign key constraint?

  1. (A)Inserting records into relation r
  2. (B)Deleting records from relation s
  3. (C)Deleting records from relation r
  4. (D)Inserting records into relation s
Answer: A, B - show solution

s is the referencing relation, r the referenced one. Inserting into r only adds possible targets, so no s tuple loses its match. Deleting from s removes referencing tuples, which can never leave a dangling reference. Deleting from r can remove an A value still used by some E in s, and inserting into s can add an E value absent from r - both can violate. Answer: (A), (B).

Concept: Referential integrity: only deletes/updates on the referenced table and inserts/updates on the referencing table can break it. The trap is mixing up the two directions.

GATE 2026 · Q32NAT1 mark · no negative· Easy

In a relational database, a B+ Tree Index is to be constructed for a relation on a key field. In a B+ Tree, a Node Pointer points to a sub-tree and a Data Record Pointer points to a block of database records. Let, Node size = 4096 bytes, Node Pointer size = 10 bytes, Search Key Field size = 11 bytes and Data Record Pointer size = 12 bytes. The maximum number of Node Pointers that can be present in a non-leaf node of the B+ Tree is ________ . (Answer in integer)

Answer: 195 - show solution

A non-leaf node with p node pointers holds p - 1 keys and no record pointers. Need 10p + 11(p - 1) ≤ 4096, so 21p ≤ 4107 and p ≤ 195.57. Maximum p = 195. Answer: 195.

Concept: Internal B+ tree nodes carry only child pointers and keys. The trap is including the data record pointer size, which belongs to leaf nodes.

GATE 2026 · Q41MCQ2 marks · -2/3· Moderate

Consider a B+ Tree where the maximum number of key values in each leaf node is 2 and the maximum number of pointers in each non-leaf node is 3. The B+ Tree currently is: Root (non-leaf): keys [5 | 8] with three child pointers. Leaves, left to right (linked): [1, 5] → [7, 8] → [9, 12] → NULL. (The left child of the root is the leaf [1, 5], the middle child is [7, 8], the right child is [9, 12].) Which of the following options denotes the key value(s) stored in the root node after inserting a key value 3 in the given B+ Tree?

  1. (A)5
  2. (B)8
  3. (C)3 and 5
  4. (D)3, 5 and 8
Answer: A - show solution

3 goes to leaf [1, 5], which overflows as [1, 3, 5] and splits into two leaves, pushing a new separator (3, as the largest key of the left leaf [1, 3] | [5]) into the root. The root would then hold 3, 5, 8 with four children, exceeding 3 pointers, so it splits: [3] and [8] become two internal nodes and the middle key 5 moves up into a new root. The same result follows if the leaf splits as [1] | [3, 5]. New root: 5. Answer: (A) 5.

Concept: Cascading splits in a B+ tree: leaf keys are copied up, internal keys are moved up. The trap is stopping after the leaf split and answering 3, 5 and 8.

GATE 2026 · Q42MCQ2 marks · -2/3· Moderate

Consider the given relations X, Y and Z. The relation X has three columns P, Q and R. The relation Y has three columns P, Q and S. The relation Z has two columns P and T. X: P Q R Y: P Q S Z: P T P1 Q1 R1 P1 Q1 2 P1 T1 P2 Q2 R2 P1 Q2 5 P3 T2 P3 Q3 R2 P2 Q1 6 P4 T3 P3 Q3 1 P4 NULL Consider the relational algebra expression Π_PRS [ (σ_(Q = Q3 ∨ R = R2) [X ⋈ Y]) ⋈ (σ_(S > 1) [Y ⋈ Z]) ] 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
Answer: D - show solution

X ⋈ Y joins on (P, Q): (P1, Q1, R1, 2) and (P3, Q3, R2, 1); (P2, Q2) has no match in Y. Selecting Q = Q3 or R = R2 keeps only (P3, Q3, R2, 1). Y ⋈ Z joins on P: (P1, Q1, 2, T1), (P1, Q2, 5, T1), (P3, Q3, 1, T2). Selecting S > 1 keeps the two P1 rows. Joining the left result (P3 only) with the right (P1 only) on P, Q, S gives no common tuple. Answer: (D) Zero rows.

Concept: Natural join matches on all common attributes. The trap is joining on P alone or forgetting that the outer join also matches on Q and S.

GATE 2026 · Q51MSQ2 marks · no negative· Moderate

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. Employee Output EmpID TeamID EmpID TeamSize 1 8 1 3 2 8 2 3 3 8 3 3 4 7 4 2 5 7 5 2 6 9 6 1 Which of the following is/are correct?

  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
Answer: A - show solution

(A) The derived table gives (TeamID, size) per team; joining each employee to its team's row yields the required output. (B) The extra condition A.EmpID = B.EmpID pairs each employee only with itself, so every count is 1. (C) Grouping by the primary key EmpID gives 1 for everyone. (D) The derived table has no TeamID column, so B.TeamID is invalid and the query errors. Answer: (A).

Concept: Aggregate per group, then join back. The trap is (B): the self-join condition on EmpID destroys the grouping by team.

GATE 2026 · Q59NAT2 marks · no negative· Moderate

Let there be two relations X and Y as shown. X has three columns P, Q and R. Y has two columns P and S. X: P Q R Y: P S P1 Q1 R1 P1 10 P2 Q2 R2 P1 15 P3 Q3 R2 P2 20 P3 1 Consider that the following tuple relational calculus expression is evaluated. { t | t ∈ X ∧ ∃z ∈ X (t[P] = z[P]) ∧ ∃m ∈ Y (m[P] = t[P] ∧ m[S] > 1) } The number of tuples that will be returned is __________ . (Answer in integer)

Answer: 2 to 3 - show solution

The condition ∃z ∈ X (t[P] = z[P]) is always true (take z = t). So the result is the tuples of X whose P value has some Y tuple with S > 1. P1: S = 10, 15, yes. P2: S = 20, yes. P3: only S = 1, no. TRC returns a set, so the answer is 2 tuples (P1, Q1, R1) and (P2, Q2, R2). The key also accepts 3, which matches counting P1 once per matching Y tuple (bag semantics). Answer: 2 (accepted range 2 to 3).

Concept: Existential quantifiers filter, they do not multiply tuples. The trap is counting P1 twice because two Y tuples match it.

GATE 2026 · Q60NAT2 marks · no negative· Moderate

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. The number of rows returned by the SQL query is __________ . (Answer in integer)

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)
Answer: 3 - show solution

For each account, compare (number of strictly larger balances) with (number of strictly smaller balances). A1: 3 larger, 0 smaller, kept. A2: same as A1, kept. A3 (10000): 2 larger, 2 smaller, kept (2 ≥ 2). A4: 1 larger, 3 smaller, rejected. A5: 0 larger, 4 smaller, rejected. Rows returned: A1, A2, A3. Answer: 3.

Concept: Correlated subqueries evaluated per outer row. The trap is treating the equal balances 5000 and 5000 as smaller/larger than each other; strict comparisons ignore ties.

GATE 2026 · Q61NAT2 marks · no negative· Moderate

Consider an ER model with the entities E1(A11, A12, A13) and E2(A21, A22, A23), where A11, A12, A13 are the attributes of E1, and A21, A22, A23 are the attributes of E2. Let A22 be a multi-valued attribute. A11 and A21 are the primary keys of E1 and E2, respectively. Let R12 be a many-to-many relationship between E1 and E2. Participation of both E1 and E2 in R12 is total. The minimum number of relations required to convert the ER model into relational model (assuming there is no other functional dependency) where each relation is in third normal form (3NF) is __________ . (Answer in integer)

Answer: 4 - show solution

E1 → E1(A11, A12, A13). E2 without the multi-valued attribute → E2(A21, A23). The multi-valued attribute needs its own relation → E2_A22(A21, A22) with key (A21, A22); keeping it inside E2 would repeat A23 and break normal form. The many-to-many relationship needs its own relation → R12(A11, A21). Total participation on an M:N relationship does not allow merging R12 into either entity. Total: 4. Answer: 4.

Concept: Mapping M:N relationships and multi-valued attributes. The trap is merging R12 into an entity because of total participation, which only works for 1:1 or 1:N.

GATE 2026 S1 · Q30MSQ1 mark · no negative· Easy

Let P, Q, R and S be the attributes of a relation in a relational schema. Let X → Y indicate functional dependency in the context of a relational database, where X, Y ⊆ {P, Q, R, S}. Which of the following options is/are always true?

  1. (A)If ({P, Q} → {R} and {P} → {R}), then {Q} → {R}
  2. (B)If {P, Q} → {R}, then ({P} → {R} or {Q} → {R})
  3. (C)If ({P} → {R} and {Q} → {S}), then {P, Q} → {R, S}
  4. (D)If {P} → {R}, then {P, Q} → {R}
Answer: C, D - show solution

(A) P → R says nothing about Q alone; counterexample: Q constant across tuples with different R. False. (B) A composite determinant need not have a single-attribute determinant (e.g. date and room determine booking). False. (C) Augment P → R with Q: PQ → RQ, so PQ → R; similarly PQ → S; union gives PQ → RS. True. (D) Augmentation (or adding attributes to the left side) preserves the FD: PQ → R. True. Answer: (C), (D).

Concept: Armstrong's axioms: you may enlarge the left side (augmentation) but never shrink it. (A) and (B) both try to shrink a determinant.

GATE 2026 S1 · Q31MSQ1 mark · no negative· Easy

In the context of relational database normalization, which of the following statements is/are true?

  1. (A)It is always possible to obtain a dependency-preserving 3NF decomposition of a relation
  2. (B)It is always possible to obtain a dependency-preserving 1NF decomposition of a relation
  3. (C)It is not always possible to obtain a dependency-preserving BCNF decomposition of a relation
  4. (D)It is not always possible to obtain a dependency-preserving 2NF decomposition of a relation
Answer: A, B, C - show solution

3NF synthesis always yields a lossless, dependency-preserving decomposition (A true). Any relation is in 1NF already (atomic values), so the trivial decomposition preserves all dependencies (B true). BCNF decomposition is always lossless but may lose dependencies, e.g. R(A,B,C) with AB → C, C → B (C true). Since a 3NF dependency-preserving decomposition always exists and 3NF implies 2NF, a dependency-preserving 2NF decomposition always exists, so (D) is false. Answer: (A), (B), (C).

Concept: Dependency preservation is guaranteed up to 3NF and can fail only at BCNF. (D) is false because the 3NF result is also in 2NF.

GATE 2026 S1 · Q43MCQ2 marks · -2/3· Easy

Consider a relational database schema with two relations R(P, Q) and S(X, Y). Let E = {⟨u⟩ | ∃v ∃w (⟨u, v⟩ ∈ R ∧ ⟨v, w⟩ ∈ S)} be a tuple relational calculus expression. Which one of the following relational algebraic expressions is equivalent to E?

  1. (A)Π_P(R ⋈_(R.P = S.X) S)
  2. (B)Π_P(S ⋈_(S.X = R.Q) R)
  3. (C)Π_P(R ⋈_(R.P = S.Y) S)
  4. (D)Π_P(S ⋈_(S.Y = R.Q) R)
Answer: B - show solution

⟨u, v⟩ ∈ R binds u to P and v to Q. ⟨v, w⟩ ∈ S binds the same v to X. So we need R tuples whose Q value equals some S tuple's X value, and we output P. That is Π_P(R ⋈_(R.Q = S.X) S), and join is commutative, so Π_P(S ⋈_(S.X = R.Q) R). Answer: (B).

Concept: Translate shared variables into join conditions by position. The trap is joining on P (the projected attribute) or on S.Y (the existentially discarded w).

GATE 2026 S1 · Q65NAT2 marks · no negative· Easy

Consider a relational database schema with a relation R(A, B, C, D). If {A, B} and {A, C} are the only two candidate keys of the relation R, then the number of superkeys of relation R is ______. (answer in integer)

Answer: 6 - show solution

A superkey must contain a candidate key: it must include A and at least one of B, C. Choices for {B, C}: {B}, {C}, {B, C} (3 ways); D in or out (2 ways). Total 3 × 2 = 6: AB, AC, ABC, ABD, ACD, ABCD. Check by inclusion-exclusion: 2² + 2² - 2¹ = 6. Answer: 6.

Concept: Superkeys = supersets of some candidate key; count with inclusion-exclusion over the keys. Double-counting supersets of both AB and AC (ABC, ABCD) gives 8.

GATE 2026 S2 · Q15MCQ1 mark · -1/3· Easy

In the context of DBMS, consider the two sets T and S given below. T S I: Logical schema L: Views II: Physical schema M: File organization and indexes III: External schema N: Relations Which one of the following is the correct match from T to S?

  1. (A)I → L, II → M, III → N
  2. (B)I → M, II → L, III → N
  3. (C)I → N, II → M, III → L
  4. (D)I → N, II → L, III → M
Answer: C - show solution

In the three-schema architecture: the logical (conceptual) schema describes the relations; the physical schema describes storage - file organization and indexes; the external schema describes the views presented to users. So I → N, II → M, III → L. Answer: (C).

Concept: Three levels of data abstraction (ANSI/SPARC). The trap is mapping the external schema to relations instead of views.

GATE 2026 S2 · Q20MCQ1 mark · -1/3· Easy

Consider concurrent execution of two transactions T1 and T2 in a DBMS, both of which access a data object X. For these two transactions to not conflict on X, which one of the following statements must be true?

  1. (A)Both T1 and T2 only read X
  2. (B)T1 reads X and T2 writes X
  3. (C)T1 writes X and T2 reads X
  4. (D)Both T1 and T2 write X
Answer: A - show solution

Two operations on the same item by different transactions conflict if at least one of them is a write. Read-write, write-read and write-write all conflict. Only read-read does not. Answer: (A).

Concept: Definition of conflicting operations used in conflict serializability. The trap is thinking only write-write conflicts.

GATE 2026 S2 · Q42MCQ2 marks · -2/3· Moderate

In the context of schema normalization in relational DBMS, consider a set F of functional dependencies. The set of all functional dependencies implied by F is called the closure of F. To compute the closure of F, Armstrong's Axioms can be applied. Consider X, Y, and Z as sets of attributes over a relational schema. The three rules of Armstrong's Axioms are described as follows. Reflexivity: If Y ⊆ X, then X → Y Augmentation: If X → Y, then XZ → YZ for any Z Transitivity: If X → Y and Y → Z, then X → Z The additional rule of Union is defined as follows. Union: If X → Y and X → Z, then X → YZ It can be proved that the additional rule of Union is also implied by the three rules of Armstrong's Axioms. Listed below are four combinations of these three rules. Which one of these combinations is both necessary and sufficient for the proof?

  1. (A)Reflexivity, Augmentation, and Transitivity
  2. (B)Reflexivity and Augmentation
  3. (C)Transitivity
  4. (D)Augmentation and Transitivity
Answer: D - show solution

Augment X → Y with X: X → XY (since XX = X). Augment X → Z with Y: XY → YZ. Transitivity on X → XY and XY → YZ gives X → YZ. Only augmentation and transitivity are used, and neither alone suffices (transitivity cannot combine right-hand sides; augmentation cannot chain). Answer: (D).

Concept: The standard derivation of the union rule. The trap is (A): all three axioms are sufficient but reflexivity is not necessary.

GATE 2026 S2 · Q46MCQ2 marks · -2/3· Moderate

An index in a DBMS is said to be dense if an index entry appears for every search-key value in the indexed file. Otherwise it is called a sparse index. Consider the following two statements. S1: A hash index must be a dense index S2: A B+ tree index can be a sparse index Which one of the following options is correct?

  1. (A)Both S1 and S2 are true
  2. (B)Both S1 and S2 are false
  3. (C)S1 is true and S2 is false
  4. (D)S1 is false and S2 is true
Answer: A - show solution

S1: A hash index locates a record by hashing its exact key value; there is no ordering to let one entry cover a range of keys, so every search-key value must have an entry - it is a secondary-style dense index. True. S2: On a file sorted by the search key, a B+ tree can store one entry per data block (leaf entries point to blocks), which is a sparse index. True. Answer: (A).

Concept: Sparse indexing works only when the file is ordered on the key, so the index can point to the block where a key would lie. Hashing has no such order. The trap is assuming B+ trees must always be dense.

GATE 2025 · Q16MCQ1 mark · -1/3· Easy

If a relational decomposition is not dependency-preserving, which one of the following relational operators will be executed more frequently in order to maintain the dependencies?

  1. (A)Selection
  2. (B)Projection
  3. (C)Join
  4. (D)Set union
Answer: C - show solution

In a dependency-preserving decomposition, every functional dependency can be checked inside a single decomposed relation. If it is not preserved, some dependency X → Y spans attributes held in different relations, so to check it on every update the relations must be recombined - that is, joined - before the dependency can be verified. Hence joins are executed more often. Answer: (C) Join.

Concept: Dependency preservation means FDs can be enforced locally. The trap is choosing projection because decomposition itself is a projection; the extra cost of enforcement comes from rejoining.

GATE 2025 · Q17MCQ1 mark · -1/3· Easy

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) π_owner(Own ⋈ (σ_color="red"(Car ⋈ (σ_maker="ABC" Make)))) 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
Answer: C - show solution

Inside out: σ_maker="ABC"(Make) gives the models made by ABC. Joining with Car on model gives the cars of those models. σ_color="red" keeps only red ones, so we have red cars made by ABC. Joining with Own on serial attaches the owners of those cars, and π_owner returns the owners. Answer: (C) All owners of a red car made by ABC.

Concept: Reading nested selections and natural joins: selections are conjunctive (red AND ABC), not a union. Option (D) forgets the final projection is onto owner, and (B) invents a count condition.

GATE 2025 · Q33NAT1 mark · no negative· Easy

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. The number of rows returned by the query is ______ (Answer in integer)

SELECT L1.loan_number
FROM Loan L1
WHERE L1.amount > (SELECT MAX (L2.amount)
                   FROM Loan L2
                   WHERE L2.branch_name = 'SR Nagar');
Answer: 3 - show solution

Inner query: SR Nagar loans are 40000, 25000 and 65000, so MAX = 65000. Outer query keeps loans with amount > 65000: L11 (90000), L23 (80000), L25 (70000). L19 itself (65000) is not strictly greater. Rows returned = 3.

Concept: A scalar subquery with MAX, then a strict comparison. The trap is using >= (which would add L19) or comparing against the SR Nagar total instead of the maximum.

GATE 2025 · Q46MCQ2 marks · -2/3· Moderate

Consider a fact table in an OLAP application: Facts(D1, D2, val), where D1 and D2 are its dimension attributes and val is a dependent attribute. Suppose attribute D1 takes 3 values and D2 takes 2 values, and all combinations of these values are present in the table Facts. How many tuples are there in the result of the following query?

SELECT D1, D2, sum(val)
FROM Facts
GROUP BY CUBE (D1, D2);
  1. (A)1
  2. (B)6
  3. (C)9
  4. (D)12
Answer: D - show solution

CUBE(D1, D2) produces groupings for every subset of {D1, D2}: (D1, D2): 3 × 2 = 6 rows (D1): 3 rows (D2 shown as NULL) (D2): 2 rows (D1 shown as NULL) (): 1 grand-total row Total = 6 + 3 + 2 + 1 = 12. Answer: (D) 12.

Concept: CUBE over k attributes gives all 2ᵏ grouping sets; ROLLUP gives only the k + 1 hierarchical ones (here 10). The trap is counting just the 6 base groups.

GATE 2025 · Q56MSQ2 marks · no negative· Easy

Consider the following two relations, named Customer and Person, in a database: Which of the following statements is/are correct?

Person (
    aadhaar CHAR(12) PRIMARY KEY,
    name VARCHAR(32));
Customer (
    name VARCHAR(32),
    email VARCHAR(32) PRIMARY KEY,
    phone CHAR(10),
    aadhaar CHAR(12),
    FOREIGN KEY (aadhaar) REFERENCES Person(aadhaar));
  1. (A)aadhaar is a candidate key in the Customer relation
  2. (B)phone can be NULL in the Customer relation
  3. (C)aadhaar is a candidate key in the Person relation
  4. (D)aadhaar can be NULL in the Person relation
Answer: B, C - show solution

In Customer, aadhaar is only a foreign key with no UNIQUE constraint, so several customers (emails) may share one aadhaar; it is not a candidate key: (A) false. phone has no NOT NULL constraint, so it can be NULL: (B) true. In Person, aadhaar is the PRIMARY KEY, hence a candidate key: (C) true, and primary keys cannot be NULL: (D) false. Answer: (B), (C).

Concept: A foreign key need not be unique or non-null; a primary key is always unique and NOT NULL. The trap is assuming the referencing column inherits the key property of the referenced one.

GATE 2025 · Q57MSQ2 marks · no negative· Moderate

Consider a database relation R with attributes ABCDEFG, and having the following functional dependencies: A → BCEF E → DG BC → A Which of the following statements is/are correct?

  1. (A)A is the only candidate key of R
  2. (B)A, BC are the candidate keys of R
  3. (C)A, BC, E are the candidate keys of R
  4. (D)Relation R is not in Boyce-Codd Normal Form (BCNF)
Answer: B, D - show solution

A⁺ = A, B, C, E, F, then D, G from E: all of ABCDEFG, so A is a key. BC⁺ = B, C, A, then everything A gives: BC is a superkey; B⁺ = B and C⁺ = C, so BC is minimal - a candidate key. E⁺ = E, D, G only: not a key. D, F, G appear only on right sides, so any key must reach A; the candidate keys are exactly A and BC: (A), (C) false; (B) true. E → DG has a left side that is not a superkey, so R violates BCNF: (D) true. Answer: (B), (D).

Concept: Find keys with attribute closures and check minimality; BCNF requires every non-trivial FD's left side to be a superkey. The trap is missing BC as a key because BC → A is listed last.

GATE 2025 · Q62NAT2 marks · no negative· Moderate

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: π_branch_name, customer_name(Loan ⋈ Borrower) ÷ π_branch_name(Loan) where ⋈ denotes natural join. The number of tuples returned by the above relational algebra query is ______ (Answer in integer)

Answer: 1 - show solution

The division returns customers who have a loan at every branch. Branches: Banjara Hills, Kondapur, SR Nagar, Balanagar. Anand: Banjara Hills only. Ankita: SR Nagar. Gopal: SR Nagar. Sunil: Balanagar (L23), Kondapur (L25). Karteek: Banjara Hills (L11), Kondapur (L14), SR Nagar (L22), Balanagar (L23) - all four. Result: {Karteek}, so 1 tuple.

Concept: Relational division answers 'for all' queries. The trap is counting customers with loans at many branches (Sunil) or counting loans rather than distinct branches.

GATE 2025 S1 · Q15MCQ1 mark · -1/3· Easy

A schedule of three database transactions T1, T2, and T3 is shown. Ri(A) and Wi(A) denote read and write of data item A by transaction Ti, i = 1, 2, 3. The transaction T1 aborts at the end. Which other transaction(s) will be required to be rolled back? R1(X) W1(Y) R2(X) R2(Y) R3(Y) ABORT(T1)

  1. (A)Only T2
  2. (B)Only T3
  3. (C)Both T2 and T3
  4. (D)Neither T2 nor T3
Answer: C - show solution

T1 writes Y. Then T2 reads Y and T3 reads Y, both before T1 finishes - dirty reads of T1's uncommitted value. When T1 aborts, the value both read never existed, so both must be rolled back (cascading rollback). R2(X) reads X, which T1 only read, so it is harmless. Answer: Both T2 and T3 (C).

Concept: Cascading aborts come from reading uncommitted writes. The trap is focusing on X (read by T1 and T2) - read-read sharing causes no dependency.

GATE 2025 S1 · Q21MSQ1 mark · no negative· Moderate

Consider the following B⁺ tree with 5 nodes, in which a node can store at most 3 key values. The value 23 is now inserted in the B⁺ tree. Which of the following option(s) is/are CORRECT? Tree (as printed): Root: [6 | 12 | 19] Leaves, left to right: [1 | 4 | 3], [7 | 9 | 10], [13 | 15 | 17], [20 | 21 | 22]

  1. (A)None of the nodes will split.
  2. (B)At least one node will split and redistribute.
  3. (C)The total number of nodes will remain same.
  4. (D)The height of the tree will increase.
Answer: B, D - show solution

23 > 19, so it goes to the rightmost leaf [20, 21, 22], which is already full (3 keys). The leaf splits, e.g. into [20, 21] and [22, 23], and a separator (22) must be pushed into the root. The root [6, 12, 19] is also full, so it splits too, and a new root is created above the two halves. Nodes go from 5 to 8 and the height grows by one level. So (A) and (C) are false; (B) and (D) are true. Answer: (B), (D).

Concept: B⁺ tree insertion: a full leaf splits and pushes a key up; a full parent splits recursively, and a root split is the only way height increases. Every node on the path here is full.

GATE 2025 S1 · Q39MCQ2 marks · -2/3· Easy

Consider two relations describing teams and players in a sports league: - teams(tid, tname): tid, tname are team-id and team-name, respectively - players(pid, pname, tid): pid, pname, and tid denote player-id, player-name and the team-id of the player, respectively Which ONE of the following tuple relational calculus queries returns the name of the players who play for the team having tname as 'MI'?

  1. (A){ p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ p.tid = t.tid ∧ t.tname = 'MI') }
  2. (B){ p.pname | p ∈ teams ∧ ∃t (t ∈ players ∧ p.tid = t.tid ∧ t.tname = 'MI') }
  3. (C){ p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ t.tname = 'MI') }
  4. (D){ p.pname | p ∈ teams ∧ ∃t (t ∈ players ∧ t.tname = 'MI') }
Answer: A - show solution

p must range over players (it supplies pname), and there must exist a team t with the same tid whose tname is 'MI'. That is exactly (A). (B) and (D) range p over teams, which has no pname. (C) drops the join p.tid = t.tid, so it returns every player whenever an MI team exists. Answer: (A).

Concept: TRC joins need an explicit equality on the linking attribute. Missing the join condition gives all tuples when the existential is satisfiable.

GATE 2025 S1 · Q47MSQ2 marks · no negative· Easy

Consider a relational schema team(name, city, owner), with functional dependencies {name → city, name → owner}. The relation team is decomposed into two relations, t1(name, city) and t2(name, owner). Which of the following statement(s) is/are TRUE?

  1. (A)The relation team is NOT in BCNF.
  2. (B)The relations t1 and t2 are in BCNF.
  3. (C)The decomposition constitutes a lossless join.
  4. (D)The relation team is NOT in 3NF.
Answer: B, C - show solution

name → city, owner, so name is a key of team. Every FD has a superkey on the left, so team is in BCNF (and hence 3NF): (A) and (D) false. t1 and t2 are two-attribute relations with name as key: both in BCNF, (B) true. The common attribute name is a key of t1 (and t2), so the join is lossless: (C) true. Answer: (B), (C).

Concept: BCNF: every non-trivial FD's determinant is a superkey. Lossless binary decomposition: the shared attributes must be a key of one side. Decomposing an already-BCNF relation is allowed, just unnecessary.

GATE 2025 S1 · Q55NAT2 marks · no negative· Easy

Consider the following database tables of a sports league. player(pid, pname, age) team(tid, tname, city, cid) coach(cid, cname) members(pid, tid) An instance of the table and an SQL query are given. player: (1, Jasprit, 31), (2, Atharva, 24), (3, Ishan, 26), (4, Axar, 30) coach: (101, Ricky), (102, Mark), (103, Trevor) team: (10, MI, Mumbai, 102), (20, DC, Delhi, 101), (30, PK, Mohali, 103) members: (1, 10), (2, 30), (3, 10), (4, 20) The value returned by the given SQL query is ______. (Answer in integer)

SELECT MIN(P.age)
FROM player P
WHERE P.pid IN (
    SELECT M.pid
    FROM team T, coach C, members M
    WHERE C.cname = 'Mark'
          AND T.cid = C.cid
          AND M.tid = T.tid
    )
Answer: 26 - show solution

Mark has cid 102. The team with cid 102 is tid 10 (MI). Members of team 10: pids 1 and 3. Their ages: Jasprit 31, Ishan 26. MIN(age) = 26. Answer: 26.

Concept: Nested IN subquery with a three-way join. Trap: matching coach id to the wrong team or taking the minimum over all players (24).

GATE 2025 S2 · Q27MSQ1 mark · no negative· Moderate

An audit of a banking transactions system has found that on an earlier occasion, two joint holders of account A attempted simultaneous transfers of Rs. 10000 each from account A to account B. Both transactions read the same value, Rs. 11000, as the initial balance in A and were allowed to go through. B was credited Rs. 10000 twice. A was debited only once and ended up with a balance of Rs. 1000. Which of the following properties is/are certain to have been violated by the system?

  1. (A)Atomicity
  2. (B)Consistency
  3. (C)Isolation
  4. (D)Durability
Answer: B, C - show solution

Both transactions read A = 11000 before either wrote, and one debit overwrote the other: a lost update, so the interleaving was not equivalent to any serial order and Isolation was violated. The database ended with Rs. 20000 credited but only Rs. 10000 debited, so the invariant that transfers preserve total money broke: Consistency was violated (serially, the second transfer would have been refused for insufficient funds). Each transaction did all its own writes and the results persisted, so Atomicity and Durability are not certainly violated. Answer: (B) and (C).

Concept: Lost-update anomaly: a concurrency (isolation) failure that produces an inconsistent state. The trap is choosing atomicity because money went missing; each transaction itself completed fully.

GATE 2025 S2 · Q46MSQ2 marks · no negative· Moderate

Consider the following relational schema along with all the functional dependencies that hold on them. R1(A, B, C, D, E): {D → E, EA → B, EB → C} R2(A, B, C, D): {A → D, A → B, C → A} Which of the following statement(s) is/are TRUE?

  1. (A)R1 is in 3NF
  2. (B)R2 is in 3NF
  3. (C)R1 is NOT in 3NF
  4. (D)R2 is NOT in 3NF
Answer: C, D - show solution

R1: A and D appear on no right side, so both are in every key. AD+ = {A, D, E, B, C}, so AD is the only candidate key and the prime attributes are A, D. D → E: D is not a superkey and E is not prime, so R1 is not in 3NF. R2: C appears on no right side; C+ = {C, A, D, B}, so C is the only key and C is the only prime attribute. A → D: A is not a superkey and D is not prime (a transitive dependency C → A → D), so R2 is not in 3NF. Answer: (C) and (D).

Concept: 3NF requires every nontrivial X → Y to have X a superkey or Y prime. Find keys first using attributes that never appear on a right side; both schemas contain a dependency from a non-key to a non-prime attribute.

GATE 2025 S2 · Q53MSQ2 marks · no negative· Moderate

Consider the database transactions T1 and T2, and data items X and Y. T1: R1(X), W1(Y), R1(X), W1(X), COMMIT(T1) T2: W2(X), W2(Y), COMMIT(T2) Which of the schedule(s) is/are conflict serializable?

  1. (A)R1(X), W2(X), W1(Y), W2(Y), R1(X), W1(X), COMMIT(T2), COMMIT(T1)
  2. (B)W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
  3. (C)R1(X), W1(Y), W2(X), W2(Y), R1(X), W1(X), COMMIT(T1), COMMIT(T2)
  4. (D)W2(X), R1(X), W1(Y), W2(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
Answer: B - show solution

Conflicting pairs: T1's R1(X), R1(X), W1(X) with W2(X); W1(Y) with W2(Y). (A) R1(X) before W2(X): T1→T2; second R1(X) after W2(X): T2→T1. Cycle, not serializable. (B) W2(X) before both R1(X) and W1(X), W2(Y) before W1(Y): all edges T2→T1. Acyclic, equivalent to T2, T1. (C) R1(X) before W2(X): T1→T2; second R1(X) after W2(X): T2→T1. Cycle. (D) W2(X) before R1(X): T2→T1; W1(Y) before W2(Y): T1→T2. Cycle. Answer: (B).

Concept: Build the precedence graph from every conflicting pair (same item, different transactions, at least one write). The repeated R1(X) is the trap: a write by T2 between T1's two reads creates the back edge.

GATE 2025 S2 · Q54MSQ2 marks · no negative· Easy

Consider the following relational schema: Students (rollno: integer, name: string, age: integer, cgpa: real) Courses (courseno: integer, cname: string, credits: integer) Enrolled (rollno: integer, courseno: integer, grade: string) Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e., courseno) 1470?

  1. (A)SELECT S.name FROM Students S WHERE EXISTS (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);
  2. (B)SELECT S.name FROM Students S WHERE SIZEOF (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno) > 0;
  3. (C)SELECT S.name FROM Students S WHERE 0 < (SELECT COUNT(*) FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);
  4. (D)SELECT S.name FROM Students S NATURAL JOIN Enrolled E WHERE E.courseno = 1470;
Answer: A, C, D - show solution

(A) The correlated EXISTS subquery is true exactly when the student has an Enrolled row for 1470: correct. (B) SIZEOF is not an SQL function, so the query is invalid. (C) COUNT(*) of matching Enrolled rows greater than 0: correct. (D) Students and Enrolled share only rollno, so the natural join pairs each student with their enrollments; filtering courseno = 1470 returns the right names: correct. Answer: (A), (C), (D).

Concept: Several SQL forms express "exists a matching row": EXISTS, COUNT > 0, or a join. Check that a natural join uses only the intended common column, and spot non-standard functions.

GATE 2025 S2 · Q57NAT2 marks · no negative· Hard

In a B+-tree where each node can hold at most four key values, a root to leaf path consists of the following nodes: A = (49, 77, 83, -), B = (7, 19, 33, 44), C = (20*, 22*, 25*, 26*). The *-marked keys signify that these are data entries in a leaf. Assume that a pointer between keys k1 and k2 points to a subtree containing keys in [k1, k2), and that when a leaf is created, the smallest key in it is copied up into its parent. A record with key value 23 is inserted into the B+-tree. The smallest key value in the parent of the leaf that contains 25* is __________. (Answer in integer)

Answer: 33 - show solution

Leaf C is full, so inserting 23 splits {20, 22, 23, 25, 26} into two leaves, and the new leaf's smallest key (23 for a 2|3 split, 25 for a 3|2 split) is copied into B. B = (7, 19, 33, 44) is also full and becomes 5 keys, e.g. (7, 19, 23, 33, 44). An internal split pushes the middle key up to A: left node (7, 19), right node (33, 44), with 23 (or 25) moving to A. The leaf containing 25* covers keys from 23 (or 25) up to 33, so it hangs from the leftmost pointer of the right node (33, 44). Either split choice gives that parent, whose smallest key is 33. Answer: 33.

Concept: Leaf splits copy a key up, but internal splits move the middle key up without keeping it. The trap is assuming the separator stays in the leaf's parent, which would give 23 or 25.

GATE 2024 · Q26MCQ1 mark · -1/3· Easy

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)Π_name(Team) \ (Π_name(Defender) ∩ Π_name(Forward)) = ϕ
  2. (B)(Π_name(Defender) ∩ Π_name(Forward)) \ Π_name(Team) = ϕ
  3. (C)Π_name(Team) \ (Π_name(Defender) ∪ Π_name(Forward)) = ϕ
  4. (D)(Π_name(Defender) ∪ Π_name(Forward)) \ Π_name(Team) = ϕ
Answer: C - show solution

'Every Team name is in Defender or Forward' means Π_name(Team) ⊆ Π_name(Defender) ∪ Π_name(Forward). A subset test A ⊆ B is written A \ B = ϕ. So Π_name(Team) \ (Π_name(Defender) ∪ Π_name(Forward)) = ϕ. Option (A) uses ∩ (would demand both), and (B), (D) test the reverse inclusion. Answer: (C).

Concept: Expressing set containment with difference. The traps are 'either...or' mapped to intersection and getting the direction of the difference backwards.

GATE 2024 · Q31NAT1 mark · no negative· Easy

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 ID Name Raids RaidPoints 1 Arjun 200 250 2 Ankush 190 219 3 Sunil 150 200 4 Reza 150 190 5 Pratham 175 220 6 Gopal 193 215 Team City ID BidPoints Jaipur 2 200 Patna 3 195 Hyderabad 5 175 Jaipur 1 250 Patna 4 200 Jaipur 6 200 The SQL query described below is executed on this database. The number of rows returned by this query is ______.

SELECT *
FROM Raider, Team
WHERE Raider.ID=Team.ID AND City="Jaipur" AND
RaidPoints > 200;
Answer: 3 - show solution

The join condition pairs each Team row with its Raider. Jaipur rows have IDs 2, 1 and 6. Their RaidPoints are 219 (Ankush), 250 (Arjun) and 215 (Gopal), all greater than 200. So 3 rows are returned. Answer: 3.

Concept: Evaluating a join with selection predicates. The trap is filtering on BidPoints instead of RaidPoints, or treating > 200 as ≥ 200 (Sunil has exactly 200 but plays for Patna anyway).

GATE 2024 · Q46MSQ2 marks · no negative· Easy

Given the relational schema R = (U, V, W, X, Y, Z) and the set of functional dependencies: {U → V, U → W, WX → Y, WX → Z, V → X} Which of the following functional dependencies can be derived from the above set?

  1. (A)VW → YZ
  2. (B)WX → YZ
  3. (C)VW → U
  4. (D)VW → Y
Answer: A, B, D - show solution

Compute closures. (VW)⁺: start {V, W}; V → X adds X; WX → Y and WX → Z add Y, Z. So (VW)⁺ = {V, W, X, Y, Z}, which contains Y and Z but not U. Hence VW → YZ (A) and VW → Y (D) hold, VW → U (C) does not (no FD has U on the right). (B) WX → YZ follows from WX → Y and WX → Z by the union rule. Answer: (A), (B), (D).

Concept: Attribute closure decides FD implication. The trap is (C): nothing determines U, so U must be in every key.

GATE 2024 S1 · Q21MCQ1 mark · -1/3· Easy

In a B+ tree, the requirement of at least half-full (50%) node occupancy is relaxed for which one of the following cases?

  1. (A)Only the root node
  2. (B)All leaf nodes
  3. (C)All internal nodes
  4. (D)Only the leftmost leaf node
Answer: A - show solution

In a B+ tree every node except the root must be at least half full. The root may hold as few as one key (two children if internal), since it is created and removed as the tree grows and shrinks. Answer: (A) Only the root node.

Concept: The minimum-occupancy rule exempts only the root. The trap is thinking leaves are exempt.

GATE 2024 S1 · Q22MSQ1 mark · no negative· Easy

Which of the following statements about a relation R in first normal form (1NF) is/are TRUE ?

  1. (A)R can have a multi-attribute key
  2. (B)R cannot have a foreign key
  3. (C)R cannot have a composite attribute
  4. (D)R cannot have more than one candidate key
Answer: A, C - show solution

1NF only requires every attribute to be atomic (single-valued, not composite or multivalued). (A) True: a key may consist of several attributes. (B) False: 1NF says nothing about foreign keys. (C) True: a composite attribute is not atomic. (D) False: any number of candidate keys is allowed. Answer: (A), (C).

Concept: 1NF is purely about atomic values. The trap is reading key-related restrictions into 1NF.

GATE 2024 S1 · Q35NAT1 mark · no negative· Easy

Consider the following two relations, R(A,B) and S(A,C): R: A B S: A C 10 20 10 90 20 30 30 45 30 40 40 80 30 50 50 95 The total number of tuples obtained by evaluating the following expression σ_{B<C}(R ⋈_{R.A=S.A} S) is _________

Answer: 2 - show solution

Join on A: R(10,20) with S(10,90); R(30,40) with S(30,45); R(30,50) with S(30,45). R tuples with A = 20 and 50 have no match. Apply B < C: 20 < 90 yes, 40 < 45 yes, 50 < 45 no. Result has 2 tuples. Answer: 2.

Concept: Do the equi-join first, then filter. The trap is forgetting that A = 30 appears twice in R and produces two joined rows.

GATE 2024 S1 · Q44MSQ2 marks · no negative· Easy

The symbol → indicates functional dependency in the context of a relational database. Which of the following options is/are TRUE?

  1. (A)(X, Y) → (Z, W) implies X → (Z, W)
  2. (B)(X, Y) → (Z, W) implies (X, Y) → Z
  3. (C)((X, Y) → Z and W → Y) implies (X, W) → Z
  4. (D)(X → Y and Y → Z) implies X → Z
Answer: B, C, D - show solution

(A) False: a determinant cannot be shrunk; X alone need not determine Z, W. (B) True by decomposition. (C) True by pseudo-transitivity: W → Y gives XW → XY, and XY → Z, so XW → Z. (D) True by transitivity. Answer: (B), (C), (D).

Concept: Armstrong's axioms let you split the right side or augment the left, never drop attributes from the left. The trap is accepting (A).

GATE 2024 S1 · Q46MSQ2 marks · no negative· Moderate

Consider the following read-write schedule S over three transactions T1, T2, and T3, where the subscripts in the schedule indicate transaction IDs: S: r1(z); w1(z); r2(x); r3(y); w3(y); r2(y); w2(x); w2(y); Which of the following transaction schedules is/are conflict equivalent to S?

  1. (A)T1T2T3
  2. (B)T1T3T2
  3. (C)T3T2T1
  4. (D)T3T1T2
Answer: B, C, D - show solution

Conflicts on y: r3(y) before w2(y), w3(y) before r2(y), w3(y) before w2(y), all giving T3 → T2. T1 touches only z, which nobody else uses, and x is used only by T2. The precedence graph has the single edge T3 → T2, so any serial order with T3 before T2 is conflict equivalent: T1T3T2, T3T2T1, T3T1T2. Answer: (B), (C), (D).

Concept: Conflict-equivalent serial orders are the topological orders of the precedence graph. The trap is assuming T1 must come first because it starts first.

GATE 2024 S2 · Q19MCQ1 mark · -1/3· Easy

Once the DBMS informs the user that a transaction has been successfully completed, its effect should persist even if the system crashes before all its changes are reflected on disk. This property is called

  1. (A)durability
  2. (B)atomicity
  3. (C)consistency
  4. (D)isolation
Answer: A - show solution

The ACID property that guarantees committed changes survive failures (via the log and redo during recovery) is durability. Atomicity is all-or-nothing execution, consistency is preserving integrity constraints, isolation is non-interference of concurrent transactions. Answer: (A) durability.

Concept: Distinguishing the ACID properties. Durability is about committed work surviving crashes; atomicity is about undoing partial work.

GATE 2024 S2 · Q20MCQ1 mark · -1/3· Easy

In the context of owner and weak entity sets in the ER (Entity-Relationship) data model, which one of the following statements is TRUE?

  1. (A)The weak entity set MUST have total participation in the identifying relationship
  2. (B)The owner entity set MUST have total participation in the identifying relationship
  3. (C)Both weak and owner entity sets MUST have total participation in the identifying relationship
  4. (D)Neither weak entity set nor owner entity set MUST have total participation in the identifying relationship
Answer: A - show solution

A weak entity cannot be identified without its owner, so every weak entity must take part in the identifying relationship: total participation on the weak side. An owner may have no weak entities at all (an employee with no dependents), so its participation need not be total. Answer: (A).

Concept: Weak entity sets depend on an identifying owner, hence total participation (double line) on the weak side only.

GATE 2024 S2 · Q26MSQ1 mark · no negative· Moderate

Which of the following file organizations is/are I/O efficient for the scan operation in DBMS?

  1. (A)Sorted
  2. (B)Heap
  3. (C)Unclustered tree index
  4. (D)Unclustered hash index
Answer: A, B - show solution

A full scan must read every record. In sorted and heap files the records are packed into data pages that are read once each, about B I/Os for B pages. Scanning through an unclustered index fetches records in index order, jumping between data pages, which can cost one I/O per record plus the index pages; a hash index also leaves buckets partly empty. So only sorted and heap files are I/O efficient for a scan. Answer: (A), (B).

Concept: Scan cost depends on physical layout. Unclustered indexes help point or range lookups but make full scans expensive because of random page accesses.

GATE 2024 S2 · Q27MSQ1 mark · no negative· Easy

Which of the following statements about the Two Phase Locking (2PL) protocol is/are TRUE?

  1. (A)2PL permits only serializable schedules
  2. (B)With 2PL, a transaction always locks the data item being read or written just before every operation and always releases the lock just after the operation
  3. (C)With 2PL, once a lock is released on any data item inside a transaction, no more locks on any data item can be obtained inside that transaction
  4. (D)A deadlock is possible with 2PL
Answer: A, C, D - show solution

(A) True: every 2PL schedule is conflict serializable (equivalent to the order of lock points). (B) False: releasing right after each operation and locking again later violates the growing/shrinking rule. (C) True: that is the definition of 2PL. (D) True: two transactions each holding one lock and waiting for the other's lock deadlock under basic 2PL. Answer: (A), (C), (D).

Concept: 2PL guarantees serializability but not freedom from deadlock or cascading aborts. Statement B describes short-duration locking, which breaks 2PL.

GATE 2024 S2 · Q45MCQ2 marks · -2/3· Moderate

The relation schema, Person(pid, city), describes the city of residence for every person uniquely identified by pid. The following relational algebra operators are available: selection, projection, cross product, and rename. To find the list of cities where at least 3 persons reside, using the above operators, the minimum number of cross product operations that must be used is

  1. (A)1
  2. (B)2
  3. (C)3
  4. (D)4
Answer: B - show solution

With no aggregation, 'at least 3 persons' needs three distinct tuples of Person in the same city. Rename three copies P1, P2, P3 and form P1 × P2 × P3 (2 cross products), select P1.city = P2.city = P3.city with P1.pid ≠ P2.pid, P2.pid ≠ P3.pid, P1.pid ≠ P3.pid, and project city. With one cross product only two persons can be compared at once, which cannot certify three. Answer: (B) 2.

Concept: Counting to k without aggregation needs k copies of the relation, i.e. k − 1 cross products, with pairwise inequality on the key.

GATE 2024 S2 · Q56NAT2 marks · no negative· Moderate

A functional dependency F: X → Y is termed as a useful functional dependency if and only if it satisfies all the following three conditions: - X is not the empty set. - Y is not the empty set. - Intersection of X and Y is the empty set. For a relation R with 4 attributes, the total number of possible useful functional dependencies is ________

Answer: 50 - show solution

Each attribute goes to X, to Y, or to neither: 3⁴ = 81 assignments with X and Y disjoint. Remove those with X empty (each attribute in Y or neither: 2⁴ = 16) and those with Y empty (16), adding back the one with both empty: 81 − 16 − 16 + 1 = 50. Answer: 50.

Concept: Counting ordered pairs of disjoint non-empty subsets via 3ⁿ and inclusion-exclusion. Forgetting to add back the both-empty case gives 49.

GATE 2023 · Q16MCQ1 mark · -1/3· Easy

Which one of the options given below refers to the degree (or arity) of a relation in relational database systems?

  1. (A)Number of attributes of its relation schema.
  2. (B)Number of tuples stored in the relation.
  3. (C)Number of entries in the relation.
  4. (D)Number of distinct domains of its relation schema.
Answer: A - show solution

The degree (arity) of a relation is the number of attributes (columns) in its schema. The number of tuples (rows) is its cardinality. Answer: (A) Number of attributes of its relation schema.

Concept: Degree = number of attributes; cardinality = number of tuples. Swapping these two terms is the standard trap.

GATE 2023 · Q61NAT2 marks · no negative· Easy

Consider the following table named Student in a relational database. The primary key of this table is rollNum. rollNum name gender marks 1 Naman M 62 2 Aliya F 70 3 Aliya F 80 4 James M 82 5 Swati F 65 The SQL query below is executed on this database. The number of rows returned by the query is ________.

SELECT *
FROM Student
WHERE gender = 'F' AND
      marks > 65;
Answer: 2 - show solution

Female students: rollNum 2 (70), 3 (80), 5 (65). marks > 65 is strict, so Swati with 65 is excluded. Rows returned: rollNum 2 and 3. Duplicated names do not matter since SELECT * returns whole rows. Answer: 2.

Concept: Straightforward WHERE filtering; the traps are the strict inequality at 65 and wondering whether the duplicate name "Aliya" collapses rows (it does not without DISTINCT, and rows differ anyway).

GATE 2023 · Q62NAT2 marks · no negative· Moderate

Consider a database of fixed-length records, stored as an ordered file. The database has 25,000 records, with each record being 100 bytes, of which the primary key occupies 15 bytes (the other fields occupy 85 bytes). The data file is block-aligned in that each data record is fully contained within a block. The database is indexed by a primary index file, which is also stored as a block-aligned ordered file. Each index entry holds the primary key of a data block's anchor (first) record and a pointer to that block. Suppose the block size of the file system is 1024 bytes, and a pointer to a block occupies 5 bytes. The system uses binary search on the index file to search for a record with a given key. You may assume that a binary search on an index file of b blocks takes ⌈log2 b⌉ block accesses in the worst case. Given a key, the number of block accesses required to identify the block in the data file that may contain a record with the key, in the worst case, is ________.

Answer: 6 - show solution

Records per data block = floor(1024/100) = 10, so data blocks = 25000/10 = 2500. The primary (sparse) index has one entry per data block: 2500 entries of 15 + 5 = 20 bytes. Entries per index block = floor(1024/20) = 51, so index blocks = ceil(2500/51) = 50. Binary search on the index: ⌈log2 50⌉ = 6 block accesses, which identifies the data block. Answer: 6.

Concept: A primary index is sparse: one entry per data block, not per record. The question stops at identifying the block, so the extra data-block access (7) is not counted.

GATE 2022 · Q14MCQ1 mark · -1/3· Easy

In a relational data model, which one of the following statements is TRUE?

  1. (A)A relation with only two attributes is always in BCNF.
  2. (B)If all attributes of a relation are prime attributes, then the relation is in BCNF.
  3. (C)Every relation has at least one non-prime attribute.
  4. (D)BCNF decompositions preserve functional dependencies.
Answer: A - show solution

(A) True: with attributes {A, B}, any non-trivial FD is A→B or B→A, and its left side is then a key; with none, the key is AB. Either way every determinant is a superkey, so BCNF. (B) False: all-prime relations are in 3NF but can violate BCNF (e.g. R(A,B,C), AB→C, C→B). (C) False: a relation whose only key is all attributes has no non-prime attribute. (D) False: BCNF decomposition may lose dependencies. Answer: (A).

Concept: Two-attribute relations are always BCNF. The trap is (B), which guarantees only 3NF.

GATE 2022 · Q25MSQ1 mark · no negative· Moderate

Consider the following three relations in a relational database. Employee(eId, Name), Brand(bId, bName), Own(eId, bId) Which of the following relational algebra expressions return the set of eIds who own all the brands?

  1. (A)Π_eId(Π_eId,bId(Own) / Π_bId(Brand))
  2. (B)Π_eId(Own) − Π_eId((Π_eId(Own) × Π_bId(Brand)) − Π_eId,bId(Own))
  3. (C)Π_eId(Π_eId,bId(Own) / Π_bId(Own))
  4. (D)Π_eId((Π_eId(Own) × Π_bId(Own)) / Π_bId(Brand))
Answer: A, B - show solution

(A) Division of Own by all brand ids is exactly 'owns every brand'. (B) Π_eId(Own) × Π_bId(Brand) lists every (owner, brand) pair that should exist; subtracting Own leaves the missing pairs; their eIds are owners missing some brand; removing them leaves owners of all brands - the expansion of division. (C) Divides by brands that someone owns, so an unowned brand is ignored - wrong. (D) The cross product pairs every owner with every owned brand regardless of actual ownership - wrong. Answer: (A), (B).

Concept: R ÷ S = Π_X(R) − Π_X((Π_X(R) × S) − R). The trap is dividing by Π_bId(Own) instead of Brand.

GATE 2022 · Q31NAT1 mark · no negative· Easy

Consider a relation R(A, B, C, D, E) with the following three functional dependencies. AB → C; BC → D; C → E; The number of superkeys in the relation R is _____________.

Answer: 8 - show solution

A and B never appear on a right-hand side, so every key must contain both. AB⁺: AB → C, then BC → D, C → E, so AB⁺ = ABCDE and AB is the only candidate key. A superkey is any superset of AB: the remaining attributes C, D, E can each be in or out, giving 2³ = 8 superkeys. Answer: 8.

Concept: Attributes absent from every right side belong to every key. With a single candidate key of size k in n attributes, there are 2ⁿ⁻ᵏ superkeys.

GATE 2022 · Q39MCQ2 marks · -2/3· Moderate

Let Rᵢ(z) and Wᵢ(z) denote read and write operations on a data element z by a transaction Tᵢ, respectively. Consider the schedule S with four transactions. S: R₄(x) R₂(x) R₃(x) R₁(y) W₁(y) W₂(x) W₃(y) R₄(y) Which one of the following serial schedules is conflict equivalent to S?

  1. (A)T₁ → T₃ → T₄ → T₂
  2. (B)T₁ → T₄ → T₃ → T₂
  3. (C)T₄ → T₁ → T₃ → T₂
  4. (D)T₃ → T₁ → T₄ → T₂
Answer: A - show solution

Conflicting pairs (same item, different transactions, at least one write), in schedule order: on x - R₄(x) before W₂(x) gives T₄ → T₂; R₃(x) before W₂(x) gives T₃ → T₂. On y - R₁(y)/W₁(y) before W₃(y) gives T₁ → T₃; W₁(y) before R₄(y) gives T₁ → T₄; W₃(y) before R₄(y) gives T₃ → T₄. The precedence graph is acyclic with unique topological order T₁ → T₃ → T₄ → T₂. Answer: (A).

Concept: Build the precedence graph from conflicting operations and topologically sort it. The trap is missing W₃(y) → R₄(y), which forces T₃ before T₄.

GATE 2022 · Q56NAT2 marks · no negative· Moderate

Consider the relational database with the following four schemas and their respective instances. Student(sNo, sName, dNo) Dept(dNo, dName) Course(cNo, cName, dNo) Register(sNo, cNo) Student: (S01, James, D01), (S02, Rocky, D01), (S03, Jackson, D02), (S04, Jane, D01), (S05, Milli, D02) Dept: (D01, CSE), (D02, EEE) Course: (C11, DS, D01), (C12, OS, D01), (C21, DE, D02), (C22, PT, D02), (C23, CV, D03) Register: (S01, C11), (S01, C12), (S02, C11), (S03, C21), (S03, C22), (S03, C23), (S04, C11), (S04, C12), (S05, C11), (S05, C21) The number of rows returned by the SQL query below is___________.

SELECT * FROM Student AS S WHERE NOT EXIST
 (SELECT cNo FROM Course WHERE dNo = "D01"
     EXCEPT
  SELECT cNo FROM Register WHERE sNo = S.sNo)
Answer: 2 - show solution

The subquery lists D01 courses the student has NOT registered for; NOT EXISTS keeps students for whom that list is empty, i.e. students registered for every D01 course. D01 courses: C11, C12. S01 has C11 and C12: kept. S02 has only C11: dropped. S03 has neither: dropped. S04 has C11 and C12: kept. S05 has C11 and C21 (no C12): dropped. Rows returned = 2. Answer: 2.

Concept: NOT EXISTS (required EXCEPT taken) is SQL's relational division. The student's own department does not matter here, which is the usual trap.

GATE 2018 · Q21MCQ1 mark · -1/3· Easy

In an Entity-Relationship (ER) model, suppose R is a many-to-one relationship from entity set E1 to entity set E2. Assume that E1 and E2 participate totally in R and that the cardinality of E1 is greater than the cardinality of E2. Which one of the following is true about R?

  1. (A)Every entity in E1 is associated with exactly one entity in E2.
  2. (B)Some entity in E1 is associated with more than one entity in E2.
  3. (C)Every entity in E2 is associated with exactly one entity in E1.
  4. (D)Every entity in E2 is associated with at most one entity in E1.
Answer: A - show solution

Many-to-one from E1 to E2 means each E1 entity relates to at most one E2 entity; total participation of E1 makes it at least one, so exactly one (A true, B false). Since |E1| > |E2| and every E1 entity maps into E2, by pigeonhole some E2 entity is associated with more than one E1 entity, so (C) and (D) are false. Answer: (A).

Concept: Combining mapping cardinality (at most one) with total participation (at least one) gives exactly one. The trap is reading "many-to-one" backwards and picking (B).

GATE 2018 · Q22MCQ1 mark · -1/3· Easy

Consider the following two tables and four queries in SQL. Book (isbn, bname), Stock (isbn, copies) (isbn is the primary key of each table) Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?

Query 1:  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 Book 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 Book B FULL OUTER JOIN Stock S
          ON B.isbn = S.isbn;
  1. (A)Query 1
  2. (B)Query 2
  3. (C)Query 3
  4. (D)Query 4
Answer: D - show solution

The inner join returns the matching rows. The left outer join adds Book rows with no match (copies NULL); the right outer join adds Stock rows with no match (B.isbn NULL). The full outer join contains the matching rows plus both sets of unmatched rows, so it always contains the output of each of the other three. Answer: (D) Query 4.

Concept: FULL OUTER JOIN = INNER JOIN rows plus unmatched rows from both sides, so it is a superset of LEFT, RIGHT and INNER joins. The trap is choosing LEFT or RIGHT, which each miss the other side's unmatched rows.

GATE 2018 · Q51MCQ2 marks · -2/3· Moderate

Consider the relations r(A, B) and s(B, C), where s.B is a primary key and r.B is a foreign key referencing s.B. Consider the query Q: r ⋈ (σ_(B<5)(s)) Let LOJ denote the natural left outer-join operation. Assume that r and s contain no null values. Which one of the following queries is NOT equivalent to Q?

  1. (A)σ_(B<5)(r ⋈ s)
  2. (B)σ_(B<5)(r LOJ s)
  3. (C)r LOJ (σ_(B<5)(s))
  4. (D)σ_(B<5)(r) LOJ s
Answer: C - show solution

Q returns the r tuples with B < 5 joined with their s tuple. Because r.B is a foreign key into s, every r tuple has a matching s tuple, so r LOJ s = r ⋈ s. (A) Selection pushed past the join on the join attribute: equivalent. (B) r LOJ s = r ⋈ s, then select: equivalent. (D) σ_(B<5)(r) LOJ s = σ_(B<5)(r) ⋈ s: equivalent. (C) r LOJ σ_(B<5)(s) keeps every r tuple with B ≥ 5 too, padded with C = NULL, so it has extra rows: NOT equivalent. Answer: (C).

Concept: Foreign keys guarantee matches, so a left outer join from the referencing side behaves like a natural join, unless the referenced side is filtered first. The trap is assuming the filter position never matters in outer joins.

GATE 2018 · Q52MCQ2 marks · -2/3· Moderate

Consider the following four relational schemas. For each schema, all non-trivial functional dependencies are listed. The underlined attributes are the respective primary keys. Schema I: Registration (rollno, courses) primary key: rollno Field 'courses' is a set-valued attribute containing the set of courses a student has registered for. Non-trivial functional dependency: rollno → courses Schema II: Registration (rollno, courseid, email) primary key: (rollno, courseid) Non-trivial functional dependencies: rollno, courseid → email; email → rollno Schema III: Registration (rollno, courseid, marks, grade) primary key: (rollno, courseid) Non-trivial functional dependencies: rollno, courseid → marks, grade; marks → grade Schema IV: Registration (rollno, courseid, credit) primary key: (rollno, courseid) Non-trivial functional dependencies: rollno, courseid → credit; courseid → credit Which one of the relational schemas above is in 3NF but not in BCNF?

  1. (A)Schema I
  2. (B)Schema II
  3. (C)Schema III
  4. (D)Schema IV
Answer: B - show solution

I: a set-valued attribute violates 1NF, so it is not in 3NF. II: candidate keys are {rollno, courseid} and {email, courseid}. email → rollno has a non-superkey left side, so not BCNF, but rollno is a prime attribute, so 3NF holds. III: marks → grade is a transitive dependency of a non-prime attribute: not 3NF. IV: courseid → credit is a partial dependency: not even 2NF. Answer: (B) Schema II.

Concept: 3NF allows X → A with X not a superkey only when A is prime; BCNF does not. The classic 3NF-not-BCNF case is a non-key attribute determining part of a key. The trap is missing the second candidate key {email, courseid}.

GATE 2016 Set1 · Q31MCQ1 mark · -1/3· Easy

Which of the following is NOT a superkey in a relational schema with attributes V, W, X, Y, Z and primary key VY?

  1. (A)VXYZ
  2. (B)VWXZ
  3. (C)VWXY
  4. (D)VWXYZ
Answer: B - show solution

A superkey is any attribute set containing a key. With no other information, a set is guaranteed to be a superkey if it contains both V and Y. VXYZ, VWXY and VWXYZ all contain V and Y. VWXZ lacks Y. Answer: (B) VWXZ.

Concept: Superkey = superset of a candidate key. The trap is over-thinking about other dependencies; only containment of VY is guaranteed.

GATE 2016 Set1 · Q32MCQ1 mark · -1/3· Easy

Which one of the following is NOT a part of the ACID properties of database transactions?

  1. (A)Atomicity
  2. (B)Consistency
  3. (C)Isolation
  4. (D)Deadlock-freedom
Answer: D - show solution

ACID stands for Atomicity, Consistency, Isolation and Durability. Deadlock-freedom is a property of some concurrency-control protocols, not one of the ACID properties. Answer: (D).

Concept: Recall of the ACID acronym; the missing D is Durability, which the distractor tries to replace with Deadlock-freedom.

GATE 2016 Set1 · Q33MCQ1 mark · -1/3· Moderate

A database of research articles in a journal uses the following schema. (VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, YEAR, PRICE) The primary key is (VOLUME, NUMBER, STARTPAGE, ENDPAGE) and the following functional dependencies exist in the schema. (VOLUME, NUMBER, STARTPAGE, ENDPAGE) → TITLE (VOLUME, NUMBER) → YEAR (VOLUME, NUMBER, STARTPAGE, ENDPAGE) → PRICE The database is redesigned to use the following schemas. (VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, PRICE) (VOLUME, NUMBER, YEAR) Which is the weakest normal form that the new database satisfies, but the old one does not?

  1. (A)1NF
  2. (B)2NF
  3. (C)3NF
  4. (D)BCNF
Answer: B - show solution

Old schema: (VOLUME, NUMBER) → YEAR has a proper subset of the key determining a non-prime attribute, a partial dependency. So the old schema is in 1NF but not 2NF. New schemas: in the first, the full key determines TITLE and PRICE; in the second, (VOLUME, NUMBER) is the key and determines YEAR. Every determinant is a key, so both are in BCNF, hence also in 2NF. The weakest normal form satisfied by the new design but not by the old is 2NF. Answer: (B).

Concept: Partial dependencies violate 2NF. The trap is answering BCNF because the new design is in BCNF; the question asks for the weakest form that separates the two.

GATE 2016 Set1 · Q61MCQ2 marks · -2/3· Moderate

Consider the following two phase locking protocol. Suppose a transaction T accesses (for read or write operations), a certain set of objects {O₁, ..., Oₖ}. This is done in the following manner: Step 1. T acquires exclusive locks to O₁, ..., Oₖ in increasing order of their addresses. Step 2. The required operations are performed. Step 3. All locks are released. This protocol will

  1. (A)guarantee serializability and deadlock-freedom
  2. (B)guarantee neither serializability nor deadlock-freedom
  3. (C)guarantee serializability but not deadlock-freedom
  4. (D)guarantee deadlock-freedom but not serializability
Answer: A - show solution

All locks are acquired before any is released, so the protocol is two-phase locking (in fact conservative/strict), which guarantees conflict serializability. All transactions acquire locks in the same global order (increasing address). A wait-for cycle would require some transaction to hold a higher-addressed lock while waiting for a lower one, which the ordering forbids. So no deadlock can occur. Answer: (A).

Concept: 2PL gives serializability; a global lock ordering removes circular wait. The trap is recalling that basic 2PL can deadlock and missing the ordered acquisition.

GATE 2016 Set2 · Q31MCQ1 mark · -1/3· Easy

B+ Trees are considered BALANCED because

  1. (A)the lengths of the paths from the root to all leaf nodes are all equal.
  2. (B)the lengths of the paths from the root to all leaf nodes differ from each other by at most 1.
  3. (C)the number of children of any two non-leaf sibling nodes differ by at most 1.
  4. (D)the number of records in any two leaf nodes differ by at most 1.
Answer: A - show solution

B+ tree insertion and deletion split, merge or redistribute nodes and only grow or shrink the tree at the root, so every leaf is always at the same depth. That equal root-to-leaf path length is what "balanced" means here. Node occupancy is bounded (at least half full) but not within 1 of a sibling. Answer: (A).

Concept: B and B+ trees are perfectly height-balanced: all leaves at one level. The "differ by at most 1" option describes AVL trees, which is the trap.

GATE 2016 Set2 · Q32MCQ1 mark · -1/3· Easy

Suppose a database schedule S involves transactions T₁, ..., Tₙ. Construct the precedence graph of S with vertices representing the transactions and edges representing the conflicts. If S is serializable, which one of the following orderings of the vertices of the precedence graph is guaranteed to yield a serial schedule?

  1. (A)Topological order
  2. (B)Depth-first order
  3. (C)Breadth-first order
  4. (D)Ascending order of transaction indices
Answer: A - show solution

A schedule is conflict serializable exactly when its precedence graph is acyclic. Each edge Ti → Tj means Ti must come before Tj in an equivalent serial schedule, so any topological order of the graph gives a valid serial order. DFS or BFS order, or index order, can violate an edge. Answer: (A) Topological order.

Concept: Conflict serializability test: acyclic precedence graph, serial order = topological sort. Assuming T1, T2, ... index order is the trap.

GATE 2016 Set2 · Q61MCQ2 marks · -2/3· Moderate

Consider the following database schedule with two transactions, T₁ and T₂. S = r₂(X); r₁(X); r₂(Y); w₁(X); r₁(Y); w₂(X); a₁; a₂ where rᵢ(Z) denotes a read operation by transaction Tᵢ on a variable Z, wᵢ(Z) denotes a write operation by Tᵢ on a variable Z and aᵢ denotes an abort by transaction Tᵢ. Which one of the following statements about the above schedule is TRUE?

  1. (A)S is non-recoverable
  2. (B)S is recoverable, but has a cascading abort
  3. (C)S does not have a cascading abort
  4. (D)S is strict
Answer: C - show solution

Neither transaction reads a value written by the other: r₂(X), r₁(X), r₂(Y), r₁(Y) all read original values, since the only writes are w₁(X) and w₂(X) and no read follows them. With no dirty reads, aborting T₁ forces no other abort, so there is no cascading abort (and the schedule is trivially recoverable, ruling out A and B). It is not strict: w₂(X) overwrites X written by T₁ before T₁ commits or aborts. Answer: (C).

Concept: Recoverable, cascadeless and strict differ by what may follow an uncommitted write: a read (cascadeless forbids) or any read or write (strict forbids). A blind overwrite breaks strictness but not cascadelessness.

GATE 2016 Set2 · Q62NAT2 marks · no negative· Easy

Consider the following database table named water_schemes: scheme_no district_name capacity 1 Ajmer 20 1 Bikaner 10 2 Bikaner 10 3 Bikaner 20 1 Churu 10 2 Churu 20 1 Dungargarh 10 The number of tuples returned by the following SQL query is ______.

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
Answer: 2 - show solution

total: Ajmer 20, Bikaner 40, Churu 30, Dungargarh 10. total_avg = (20 + 40 + 30 + 10)/4 = 25. Districts with total ≥ 25: Bikaner and Churu. Answer: 2.

Concept: Group-wise aggregate, then an average of those aggregates. Averaging the raw capacities (100/7 ≈ 14.3) instead of the district totals gives 3, the trap.

GATE 2014 Set1 · Q31MCQ1 mark · -1/3· Easy

Consider the relation scheme R = (E, F, G, H, I, J, K, L, M, N) and the set of functional dependencies {{E, F} → {G}, {F} → {I, J}, {E, H} → {K, L}, {K} → {M}, {L} → {N}} on R. What is the key for R?

  1. (A){E, F}
  2. (B){E, F, H}
  3. (C){E, F, H, K, L}
  4. (D){E}
Answer: B - show solution

E, F and H never appear on the right side of any FD, so every key must contain all three. {E, F, H}⁺: EF → G; F → I, J; EH → K, L; K → M; L → N. Closure = {E, F, G, H, I, J, K, L, M, N} = R. So {E, F, H} is a key, and it is minimal since none of E, F, H can be derived. {E, F} misses H; {E, F, H, K, L} is a superkey but not minimal. Answer: (B) {E, F, H}.

Concept: Attributes absent from every right-hand side must be in every candidate key; then check the closure. The trap is choosing the non-minimal superkey in option C.

GATE 2014 Set1 · Q32MCQ1 mark · -1/3· Moderate

Given the following statements: S1: A foreign key declaration can always be replaced by an equivalent check assertion in SQL. S2: Given the table R(a, b, c) where a and b together form the primary key, the following is a valid table definition. Which one of the following statements is CORRECT?

CREATE TABLE S (
    a INTEGER,
    d INTEGER,
    e INTEGER,
    PRIMARY KEY (d),
    FOREIGN KEY (a) references R)
  1. (A)S1 is TRUE and S2 is FALSE.
  2. (B)Both S1 and S2 are TRUE.
  3. (C)S1 is FALSE and S2 is TRUE.
  4. (D)Both S1 and S2 are FALSE.
Answer: D - show solution

S2: a foreign key must reference the whole primary (or a unique) key of the referenced table. R's primary key is (a, b), but S declares FOREIGN KEY (a) references R, a single column, so the definition is invalid. S2 is FALSE. S1: a foreign key also carries referential actions (ON DELETE / ON UPDATE CASCADE, SET NULL) and is enforced when the referenced table changes; a CHECK constraint on the referencing table cannot express that (standard CHECK cannot even refer to other tables in most systems). So it cannot always be replaced. S1 is FALSE. Answer: (D) Both S1 and S2 are FALSE.

Concept: Foreign keys must match the full referenced key, and they are more than a static check. The trap is accepting S2 because column a exists in R - a partial key is not a valid reference target.

GATE 2014 Set3 · Q32MCQ1 mark · -1/3· Easy

A prime attribute of a relation scheme R is an attribute that appears

  1. (A)in all candidate keys of R.
  2. (B)in some candidate key of R.
  3. (C)in a foreign key of R.
  4. (D)only in the primary key of R.
Answer: B - show solution

By definition an attribute is prime if it is a member of at least one candidate key of R; otherwise it is non-prime. This is the notion 3NF uses. Answer: (B) in some candidate key of R.

Concept: Definition of prime attribute, used in 2NF and 3NF tests. The trap is option A (all candidate keys) or D (primary key only); any candidate key suffices.

GATE 2014 Set3 · Q40MCQ2 marks · -2/3· Moderate

Consider the relational schema given below, where eId of the relation dependent is a foreign key referring to empId of the relation employee. Assume that every employee has at least one associated dependent in the dependent relation. employee (empId, empName, empAge) dependent (depId, eId, depName, depAge) Consider the following relational algebra query: π_empId(employee) - π_empId(employee ⋈_(empId = eId) ∧ (empAge ≤ depAge) dependent) The above query evaluates to the set of empIds of employees whose age is greater than that of

  1. (A)some dependent.
  2. (B)all dependents.
  3. (C)some of his/her dependents.
  4. (D)all of his/her dependents.
Answer: D - show solution

The join pairs each employee with his/her own dependents (empId = eId) whose age is at least the employee's age. Its projection is the set of employees having at least one own dependent at least as old as themselves. Subtracting this from all employees leaves those for whom no own dependent has depAge ≥ empAge, i.e. the employee is older than every one of his/her dependents. Answer: (D) all of his/her dependents.

Concept: Set difference turns 'exists a counterexample' into 'for all'. The trap is option B: the join condition empId = eId restricts the comparison to the employee's own dependents, not all dependents.

GATE 2014 Set3 · Q64MCQ2 marks · -2/3· Easy

Consider the following relational schema: employee(empId, empName, empDept) customer(custId, custName, salesRepId, rating) salesRepId is a foreign key referring to empId of the employee relation. Assume that each employee makes a sale to at least one customer. What does the following query return?

SELECT empName
FROM employee E
WHERE NOT EXISTS (SELECT custId
                  FROM customer C
                  WHERE C.salesRepId = E.empId
                  AND C.rating <> 'GOOD');
  1. (A)Names of all the employees with at least one of their customers having a 'GOOD' rating.
  2. (B)Names of all the employees with at most one of their customers having a 'GOOD' rating.
  3. (C)Names of all the employees with none of their customers having a 'GOOD' rating.
  4. (D)Names of all the employees with all their customers having a 'GOOD' rating.
Answer: D - show solution

For each employee E, the subquery lists E's customers whose rating is not 'GOOD'. NOT EXISTS keeps E only when that list is empty, i.e. E has no customer with a non-GOOD rating. Since every employee has at least one customer, this means all of E's customers are rated 'GOOD'. Answer: (D).

Concept: NOT EXISTS over a negated condition expresses universal quantification. The trap is option C, which ignores the <> in the subquery.