GATE CS Databases PYQ with Solutions
Also searched as: GATE DBMS PYQ · GATE Database Management System PYQ · GATE SQL PYQ
All 48 Databases questions from every GATE Computer Science (CS/CSE) paper from 2021 to 2026, both sets where there were two, with the official answer key and a step-by-step solution. Databases carries about 7.3 marks per paper on average. Questions are grouped chapter-wise, newest paper first.
| 2026 | 2025 | 2024 | 2023 | 2022 | 2021 |
|---|---|---|---|---|---|
| 6 | 8.5 | 8 | 5 | 7 | 8 |
Databases: Relational Model & Normalization — GATE CS PYQ (17)
- GATE CS 2026 Set 1 · Q30Databasesmsq1 markLet and be the attributes of a relation in a relational schema. Let indicate functional dependency in the context of a relational database, where . Which of the following options is/are always true?
- A.If ( and ), then
- B.If , then ( or )
- C.If ( and ), then✓
- D.If , then✓
Open GATE CS 2026 Set 1 Q30 · discuss this question →Answer: C, D
Solution
Answer: C, D • (A) False: already follows from and says nothing about alone. • (B) False: a composite determinant does not have to split. Example: (roll, subject) → marks. • (C) True: augment to , and to , then take the union to get . • (D) True: by augmentation, adding attributes to the left side keeps the dependency. - A.
- GATE CS 2026 Set 1 · Q31Databasesmsq1 markIn the context of relational database normalization, which of the following statements is/are true?
- A.It is always possible to obtain a dependency-preserving 3NF decomposition of a relation✓
- B.It is always possible to obtain a dependency-preserving 1NF decomposition of a relation✓
- C.It is not always possible to obtain a dependency-preserving BCNF decomposition of a relation✓
- D.It is not always possible to obtain a dependency-preserving 2NF decomposition of a relation
Open GATE CS 2026 Set 1 Q31 · discuss this question →Answer: A, B, C
Solution
Answer: A, B, C • (A) True: the 3NF synthesis algorithm always gives a lossless, dependency-preserving decomposition. • (B) True: with atomic attributes nothing needs to be split, so all FDs are kept. • (C) True: the classic example is with . BCNF must split on , which loses . • (D) False: every 3NF decomposition is also in 2NF, and (A) says one always exists. - A.
- GATE CS 2026 Set 1 · Q65Databasesnat2 marksConsider a relational database schema with a relation . If and are the only two candidate keys of the relation , then the number of superkeys of relation is ______. (answer in integer)Open GATE CS 2026 Set 1 Q65 · discuss this question →
Answer: 6
Solution
Answer: 6 A superkey is any superset of a candidate key. Use inclusion–exclusion: • Supersets of AB: C and D are free, so . • Supersets of AC: B and D are free, so . • Supersets of both (contain ABC): D is free, so . Total : AB, AC, ABC, ABD, ACD, ABCD. - GATE CS 2026 Set 2 · Q42Databasesmcq2 marksIn the context of schema normalization, consider a set of functional dependencies whose closure is computed using Armstrong's Axioms: Reflexivity: if then ; Augmentation: if then ; Transitivity: if and then . The Union rule is: if and then . It can be proved that Union is implied by the three axioms. Which one of the following combinations is both necessary and sufficient for the proof?
- A.Reflexivity, Augmentation, and Transitivity
- B.Reflexivity and Augmentation
- C.Transitivity
- D.Augmentation and Transitivity✓
Open GATE CS 2026 Set 2 Q42 · discuss this question →Answer: D
Solution
Answer: (D) Proof of Union from , : 1. , i.e. (Augmentation). 2. (Augmentation). 3. and (Transitivity). Only Augmentation and Transitivity are used — Reflexivity is not needed — so (D) is necessary and sufficient. - A.
- GATE CS 2025 Set 1 · Q47Databasesmsq2 marksConsider a relational schema with functional dependencies . The relation is decomposed into and . Which of the following statement(s) is/are TRUE?
- A.The relation is NOT in BCNF.
- B.The relations and are in BCNF.✓
- C.The decomposition constitutes a lossless join.✓
- D.The relation is NOT in 3NF.
Open GATE CS 2025 Set 1 Q47 · discuss this question →Answer: B, C
Solution
Answer: (B) and (C) The only determinant is , and is the (candidate) key of . Every FD has a superkey on its left, so is in BCNF (hence also in 3NF). Therefore (A) and (D) are false. - (B) Each decomposed relation has as its key with FDs and respectively — both in BCNF. True. - (C) The common attribute is a key of both and , so the decomposition is lossless. True. - A.
- GATE CS 2025 Set 2 · Q46Databasesmsq2 marksConsider the schemas with all FDs that hold: 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?
- A.R1 is in 3NF
- B.R2 is in 3NF
- C.R1 is NOT in 3NF✓
- D.R2 is NOT in 3NF✓
Open GATE CS 2025 Set 2 Q46 · discuss this question →Answer: C, D
Solution
Answer: (C) and (D) R1: and appear on no RHS, so they are in every key; all → candidate key . Prime attributes . The FD has a non-superkey LHS and a non-prime RHS () → violates 3NF. So R1 is NOT in 3NF (C). R2: all → candidate key ; prime . The FD has non-superkey LHS () and non-prime RHS () → violates 3NF. So R2 is NOT in 3NF (D). Hence (A),(B) are false and (C),(D) are true. - A.
- GATE CS 2024 Set 1 · Q20Databasesmcq1 markLet S be: "Instructors teach courses. Students register for courses. Courses are allocated classrooms. Instructors guide students." Which ER diagram (i)-(iv) CORRECTLY represents S?

- A.(i)
- B.(ii)
- C.(iii)
- D.(iv)✓
Open GATE CS 2024 Set 1 Q20 · discuss this question →Answer: D
Solution
Answer: (D) (iv) S names exactly four relationships among four entity sets: Instructor-Teaches-Course, Student-Registration-Course, Course-Allocation-Classroom, and Instructor-Guides-Student. Diagram (iv) connects precisely these: Teaches (Instructor-Course), Registration (Student-Course), Allocation (Course-Classroom), and Guides (Instructor-Student). The other diagrams add or mismatch relationships (e.g. attach Registration/Projects to the wrong entities). - A.
- GATE CS 2024 Set 1 · Q22Databasesmsq1 markWhich statements about a relation R in first normal form (1NF) is/are TRUE?
- A.R can have a multi-attribute key✓
- B.R cannot have a foreign key
- C.R cannot have a composite attribute✓
- D.R cannot have more than one candidate key
Open GATE CS 2024 Set 1 Q22 · discuss this question →Answer: A, C
Solution
Answer: (A) and (C) 1NF requires every attribute to be atomic (no composite or multivalued attributes) -> (C) true. A relation can certainly have a key made of multiple attributes -> (A) true. 1NF says nothing forbidding foreign keys (B false) or multiple candidate keys (D false). - A.
- GATE CS 2024 Set 1 · Q44Databasesmsq2 marksWhich of the following about functional dependencies is/are TRUE?
- A.implies
- B.implies✓
- C.and implies✓
- D.and implies✓
Open GATE CS 2024 Set 1 Q44 · discuss this question →Answer: B, C, D
Solution
Answer: (B), (C) and (D) - (B) Decomposition (Armstrong): . TRUE. - (C) Pseudotransitivity: lets supply , so determines which determines . TRUE. - (D) Transitivity: . TRUE. - (A) FALSE: dropping from the left is not valid; alone need not determine . - A.
- GATE CS 2024 Set 2 · Q20Databasesmcq1 markIn the ER model with owner and weak entity sets, which statement is TRUE?
- A.The weak entity set MUST have total participation in the identifying relationship✓
- B.The owner entity set MUST have total participation in the identifying relationship
- C.Both weak and owner entity sets MUST have total participation
- D.Neither must have total participation
Open GATE CS 2024 Set 2 Q20 · discuss this question →Answer: A
Solution
Answer: (A) A weak entity has no key of its own and is existence-dependent on its owner, so it MUST participate totally in the identifying relationship. The owner need not have total participation. - A.
- GATE CS 2024 Set 2 · Q56Databasesnat2 marksA useful FD requires , , . For a relation R with 4 attributes, the number of possible useful FDs is ________Open GATE CS 2024 Set 2 Q56 · discuss this question →
Answer: 50
Solution
Answer: 50 Each attribute is independently placed in , in , or in neither choices, giving assignments. Subtract those with empty ( gets none: each attribute in or neither ) and empty (), then add back the all-neither case counted twice (): - GATE CS 2023 · Q16Databasesmcq1 markWhich one refers to the degree (arity) of a relation in relational database systems?
- A.Number of attributes of its relation schema.✓
- B.Number of tuples stored in the relation.
- C.Number of entries in the relation.
- D.Number of distinct domains of its relation schema.
Open GATE CS 2023 Q16 · discuss this question →Answer: A
Solution
Answer: (A) Number of attributes of its relation schema The degree (arity) of a relation is the number of attributes (columns) in its schema. The number of tuples is the cardinality, not the degree. - A.
- GATE CS 2022 · Q14Databasesmcq1 markIn the relational data model, which one of the following statements is TRUE?
- A.A relation with only two attributes is always in BCNF.✓
- B.If all attributes of a relation are prime, then the relation is in BCNF.
- C.Every relation has at least one non-prime attribute.
- D.BCNF decompositions preserve functional dependencies.
Open GATE CS 2022 Q14 · discuss this question →Answer: A
Solution
Answer: (A) A relation with only two attributes is always in BCNF A two-attribute relation can only have FDs of the form , , both, or none — in every case the determinant is a superkey, so is in BCNF. (B) false (all-prime does not guarantee BCNF); (C) false (a relation can be all-key); (D) false (BCNF decomposition may lose dependency preservation). - A.
- GATE CS 2022 · Q31Databasesnat1 markConsider a relation with FDs , , . The number of superkeys in is __________.Open GATE CS 2022 Q31 · discuss this question →
Answer: 8
Solution
Answer: 8 With FDs , , on : and never appear on a right side, so they are in every key. (via and ), so is the only candidate key. Superkeys all supersets of - GATE CS 2021 Set 1 · Q43Databasesmcq2 marksConsider the relation with the following functional dependencies.Consider the decomposition of the relation into the constituent relations according to the following two decomposition schemes.Which one of the following options is correct?
- A.is a lossless decomposition, but is a lossy decomposition.✓
- B.is a lossy decomposition, but is a lossless decomposition.
- C.Both and are lossless decompositions.
- D.Both and are lossy decompositions.
Open GATE CS 2021 Set 1 Q43 · discuss this question →Answer: A
Solution
Testing each decomposition with the chase/common-attribute test, joins back to losslessly, while loses information (the split has no FD linking it back), so is lossy. - A.
- GATE CS 2021 Set 2 · Q16Databasesmcq1 markConsider the following statements and about the relational data model. : A relation scheme can have at most one foreign key. : A foreign key in a relation scheme cannot be used to refer to tuples of . Which one of the following choices is correct?
- A.Both and are true
- B.is true and is false
- C.is false and is true
- D.Both and are false✓
Open GATE CS 2021 Set 2 Q16 · discuss this question →Answer: D
Solution
A relation can declare several foreign keys, so is false. A foreign key may be self-referencing (refer to tuples of the same relation ), so is false. - A.
- GATE CS 2021 Set 2 · Q50Databasesmsq2 marksSuppose the following functional dependencies hold on a relation with attributes and :Which of the following functional dependencies can be inferred from the above functional dependencies?
- A.✓
- B.
- C.✓
- D.✓
Open GATE CS 2021 Set 2 Q50 · discuss this question →Answer: A, C, D
Solution
From we get (C) and , hence (D). Also , so (A). But needs as well, so (B) cannot be inferred. - A.
Databases: Transaction Management — GATE CS PYQ (11)
- GATE CS 2026 Set 2 · Q20Databasesmcq1 markConsider concurrent execution of two transactions and in a DBMS, both of which access a data object . For these two transactions to not conflict on , which one of the following statements must be true?
- A.Both and only read✓
- B.reads and writes
- C.writes and reads
- D.Both and write
Open GATE CS 2026 Set 2 Q20 · discuss this question →Answer: A
Solution
Answer: (A) Two operations on the same object conflict if at least one of them is a write (read-write, write-read, write-write all conflict). They do not conflict only when both are reads. - A.
- GATE CS 2025 Set 1 · Q15Databasesmcq1 markA schedule of three database transactions , , and is shown. and denote read and write of data item by transaction , . The transaction aborts at the end. Which other transaction(s) will be required to be rolled back?
- A.Only
- B.Only
- C.Both and✓
- D.Neither nor
Open GATE CS 2025 Set 1 Q15 · discuss this question →Answer: C
Solution
Answer: (C) Both and writes with and later aborts, so every transaction that read the uncommitted value of performs a dirty read and must be rolled back (cascading rollback). - reads after → read dirty data → roll back . - also reads (whose last writer is , since never wrote ) → read dirty data → roll back . Hence both and must be rolled back. - A.
- GATE CS 2025 Set 2 · Q27Databasesmsq1 markAn audit found that two joint holders of account attempted simultaneous transfers of Rs. 10000 each from to . Both transactions read the same initial balance Rs. 11000 and both were allowed to go through. was credited Rs. 10000 twice, but was debited only once, ending with Rs. 1000. Which of the following properties is/are certain to have been violated?
- A.Atomicity
- B.Consistency✓
- C.Isolation✓
- D.Durability
Open GATE CS 2025 Set 2 Q27 · discuss this question →Answer: B, C
Solution
Answer: (B) and (C) This is the classic lost-update anomaly from uncontrolled concurrency: - Isolation (C): the two transactions ran concurrently without proper isolation — each read the same stale balance, so one update was lost. Violated. - Consistency (D of ACID — here option B): money was created/destroyed ( gained 20000 but lost only 10000), so the database integrity ("total money conserved") is broken. Violated. - Atomicity and Durability are about all-or-nothing execution and persistence after commit; nothing here indicates those were violated. - A.
- GATE CS 2025 Set 2 · Q53Databasesmsq2 marksTransactions T1: R1(X) W1(Y) R1(X) W1(X) COMMIT, and T2: W2(X) W2(Y) COMMIT, over data items X, Y. Which of the schedule(s) is/are conflict serializable?
- A.R1(X), W2(X), W1(Y), W2(Y), R1(X), W1(X), COMMIT(T2), COMMIT(T1)
- B.W2(X), R1(X), W2(Y), W1(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)✓
- C.R1(X), W1(Y), W2(X), W2(Y), R1(X), W1(X), COMMIT(T1), COMMIT(T2)
- D.W2(X), R1(X), W1(Y), W2(Y), R1(X), COMMIT(T2), W1(X), COMMIT(T1)
Open GATE CS 2025 Set 2 Q53 · discuss this question →Answer: B
Solution
Answer: (B) Build the precedence (serialization) graph for each schedule; conflict serializable iff it is acyclic. - (B): W2(X) before R1(X) and before W1(X) → ; W2(Y) before W1(Y) → . No conflict puts before . Graph has only → acyclic → conflict serializable (order ). ✓ - (A): R1(X) before W2(X) gives , while W2(X) before later W1(X) gives → cycle. Not serializable. - (C): W1(Y) before W2(Y) gives , and W2(X) before W1(X) gives → cycle. Not serializable. - (D): W2(X) before R1(X) gives , and W1(Y) before W2(Y) gives → cycle. Not serializable. - A.
- GATE CS 2024 Set 1 · Q46Databasesmsq2 marksSchedule . Which serial schedule(s) is/are conflict equivalent to S?
- A.
- B.✓
- C.✓
- D.✓
Open GATE CS 2024 Set 1 Q46 · discuss this question →Answer: B, C, D
Solution
Answer: (B), (C) and (D) Precedence graph from the conflicts: on , precedes and , giving . touches only (no conflict with others), so it is unconstrained. The only edge is . Valid serial orders (topological sorts) are any with before and anywhere: , , -> options (B), (D), (C). Option (A) puts before , violating . - A.
- GATE CS 2024 Set 2 · Q19Databasesmcq1 markOnce a transaction is reported complete, its effect persists even if the system crashes before changes reach disk. This property is
- A.durability✓
- B.atomicity
- C.consistency
- D.isolation
Open GATE CS 2024 Set 2 Q19 · discuss this question →Answer: A
Solution
Answer: (A) durability Durability guarantees that the effects of a committed transaction survive subsequent failures (via logging/recovery). - A.
- GATE CS 2024 Set 2 · Q27Databasesmsq1 markWhich statements about the 2PL protocol is/are TRUE?
- A.2PL permits only serializable schedules✓
- B.With 2PL, a transaction locks just before every operation and releases just after
- C.Once a lock is released in a transaction, no more locks can be obtained in that transaction✓
- D.A deadlock is possible with 2PL✓
Open GATE CS 2024 Set 2 Q27 · discuss this question →Answer: A, C, D
Solution
Answer: (A), (C) and (D) 2PL guarantees conflict-serializable schedules (A). Its defining rule is a growing phase then a shrinking phase: once any lock is released, no new lock may be acquired (C). 2PL can still deadlock (D). (B) is false — that describes a non-2PL lock-just-around-each-operation discipline, which violates the two-phase rule. - A.
- GATE CS 2022 · Q39Databasesmcq2 marksSchedule . Which serial schedule is conflict equivalent to S?
- A.✓
- B.
- C.
- D.
Open GATE CS 2022 Q39 · discuss this question →Answer: A
Solution
Answer: (A) Build the precedence graph from conflicting operations (same item, at least one write). Resolving the edges on and (e.g. before gives ; before and gives ; etc.) yields an acyclic graph whose topological order is . - A.
- GATE CS 2021 Set 1 · Q23Databasesmsq1 markSuppose a database system crashes again while recovering from a previous crash. Assume checkpointing is not done by the database either during the transactions or during recovery. Which of the following statements is/are correct?
- A.The same undo and redo list will be used while recovering again.✓
- B.The system cannot recover any further.
- C.All the transactions that are already undone and redone will not be recovered again.
- D.The database will become inconsistent.
Open GATE CS 2021 Set 1 Q23 · discuss this question →Answer: A
Solution
Without checkpointing, recovery restarts from the beginning of the log and recomputes the same undo and redo lists. Recovery operations are idempotent, so the system recovers correctly — only (A) is correct. - A.
- GATE CS 2021 Set 1 · Q42Databasesmcq2 marksLet and denote read and write operations respectively on a data item by a transaction . Consider the following two schedules.Which one of the following options is correct?
- A.is conflict serializable, and is not conflict serializable.
- B.is not conflict serializable, and is conflict serializable.✓
- C.Both and are conflict serializable.
- D.Neither nor is conflict serializable.
Open GATE CS 2021 Set 1 Q42 · discuss this question →Answer: B
Solution
Drawing precedence graphs: has a cycle between and (conflicts on and in opposite order), so it is not conflict serializable. has an acyclic precedence graph (), so it is conflict serializable. - A.
- GATE CS 2021 Set 2 · Q42Databasesmcq2 marksLet be the following schedule of operations of three transactions and in a relational database system:Consider the statements P and Q below: P: is conflict-serializable. Q: If commits before finishes, then is recoverable. Which one of the following choices is correct?
- A.Both P and Q are true
- B.P is true and Q is false✓
- C.P is false and Q is true
- D.Both P and Q are false
Open GATE CS 2021 Set 2 Q42 · discuss this question →Answer: B
Solution
The precedence graph of is acyclic, so is conflict-serializable (P true). reads after writes ; if commits before , the schedule is not recoverable (Q false). - A.
Databases: File Organization & Indexing — GATE CS PYQ (9)
- GATE CS 2026 Set 2 · Q15Databasesmcq1 markIn the context of DBMS, consider the two sets and given below.
Which one of the following is the correct match from to ?T S I: Logical schema L: Views II: Physical schema M: File organization and indexes III: External schema N: Relations- A.I – L, II – M, III – N
- B.I – M, II – L, III – N
- C.I – N, II – M, III – L✓
- D.I – N, II – L, III – M
Open GATE CS 2026 Set 2 Q15 · discuss this question →Answer: C
Solution
Answer: (C) In the three-level (ANSI/SPARC) architecture: the logical/conceptual schema describes the relations (); the physical schema describes file organization and indexes (); the external schema describes user views (). Hence I–N, II–M, III–L. - A.
- GATE CS 2026 Set 2 · Q46Databasesmcq2 marksAn 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 tree index can be a sparse index Which one of the following options is correct?
- A.Both S1 and S2 are true✓
- B.Both S1 and S2 are false
- C.S1 is true and S2 is false
- D.S1 is false and S2 is true
Open GATE CS 2026 Set 2 Q46 · discuss this question →Answer: A
Solution
Answer: (A) S1 is true: a hash index computes a bucket from a search-key value, so it must have an entry for every search-key value present — it cannot be sparse. S2 is true: on a file clustered/sorted on the search key, a tree can store one entry per block (a sparse index). Hence both are true. - A.
- GATE CS 2025 Set 1 · Q21Databasesmsq1 markConsider the shown tree with 5 nodes, in which a node can store at most 3 key values. The value 23 is now inserted in the tree. Which of the following option(s) is/are CORRECT?

- A.None of the nodes will split.
- B.At least one node will split and redistribute.✓
- C.The total number of nodes will remain same.
- D.The height of the tree will increase.✓
Open GATE CS 2025 Set 1 Q21 · discuss this question →Answer: B, D
Solution
Answer: (B) and (D) The rightmost leaf is already full (max 3 keys). Inserting 23 gives → overflow, so this leaf splits and a separator key is copied up to the root. The root is (also full). Adding the copied-up key makes it → the root overflows and splits too, creating a new root. A new root means the height increases. So (B) a split/redistribution happens, and (D) the height increases. (A) is false, and (C) is false because the node count rises from 5 to 7. - A.
- GATE CS 2025 Set 2 · Q57Databasesnat2 marksIn a B+ tree where each node holds at most four keys, a root-to-leaf path is: A = (49, 77, 83, -), B = (7, 19, 33, 44), C = (20*, 22*, 25*, 26*). A pointer between keys and points to a subtree with keys in ; when a leaf is created, its smallest key is copied up. A record with key 23 is inserted. The smallest key value in the parent of the leaf that contains 25* is __________. (Answer in integer)Open GATE CS 2025 Set 2 Q57 · discuss this question →
Answer: 33
Solution
Answer: 33 Inserting 23 into the full leaf makes — overflow. Split into and , copying up (smallest of the right leaf) to parent . becomes — overflow. A 5-key internal node splits with the middle key pushed up to , leaving left part and right part . The leaf containing is , whose parent is the right internal node . Its smallest key value is . - GATE CS 2024 Set 1 · Q21Databasesmcq1 markIn a B+ tree, the requirement of at least half-full (50%) node occupancy is relaxed for which case?
- A.Only the root node✓
- B.All leaf nodes
- C.All internal nodes
- D.Only the leftmost leaf node
Open GATE CS 2024 Set 1 Q21 · discuss this question →Answer: A
Solution
Answer: (A) Only the root node Every node except the root must be at least half full. The root is exempt: it may have as few as one key (two children), or in a single-node tree, even fewer. - A.
- GATE CS 2024 Set 2 · Q26Databasesmsq1 markWhich file organization(s) is/are I/O efficient for the scan operation?
- A.Sorted✓
- B.Heap✓
- C.Unclustered tree index
- D.Unclustered hash index
Open GATE CS 2024 Set 2 Q26 · discuss this question →Answer: A, B
Solution
Answer: (A) and (B) Scanning reads all records sequentially. A Sorted file and a Heap file store records contiguously, so a full scan reads pages sequentially and is I/O efficient. Unclustered indexes (tree or hash) point to records scattered across pages, so scanning through them causes random I/O and is inefficient. - A.
- GATE CS 2023 · Q62Databasesnat2 marksA primary-indexed ordered file has 25,000 fixed-length records of 100 bytes (primary key 15 bytes). Block size 1024 bytes, block pointer 5 bytes. Binary search on the index takes ceil(log2 b) accesses for b index blocks. The worst-case block accesses to find the block possibly containing a key is __________
Open GATE CS 2023 Q62 · discuss this question →Answer: 6
Solution
Answer: 6 Records per data block , so data blocks . A primary (sparse) index has one entry per data block; each index entry bytes, so entries per index block . Index blocks . Binary search block accesses. - GATE CS 2021 Set 1 · Q33Databasesnat1 markA relation in a relational database has 1200 tuples. The attribute has integer values ranging from 6 to 20, and the attribute has integer values ranging from 1 to 20. Assume that the attributes and are independently distributed. The estimated number of tuples in the output of is ______.Open GATE CS 2021 Set 1 Q33 · discuss this question →
Answer: 205 to 820
Solution
With (15 values) and (20 values), and . Using inclusion–exclusion on the estimate gives about 819–820 tuples. (The official GATE key accepted either 819–820 or 205.) - GATE CS 2021 Set 2 · Q31Databasesnat1 markA data file consisting of 1,50,000 student-records is stored on a hard disk with block size of 4096 bytes. The data file is sorted on the primary key RollNo. The size of a record pointer for this disk is 7 bytes. Each student-record has a candidate key attribute called ANum of size 12 bytes. Suppose an index file with records consisting of two fields, ANum value and the record pointer to the corresponding student record, is built and stored on the same disk. Assume that the records of the data file and index file are not split across disk blocks. The number of blocks in the index file is ______.Open GATE CS 2021 Set 2 Q31 · discuss this question →
Answer: 698
Solution
Index record size bytes; records per block . Since ANum is a candidate key, the index is dense with 150000 entries, needing blocks.
Databases: Relational Algebra & TRC — GATE CS PYQ (6)
- GATE CS 2026 Set 1 · Q43Databasesmcq2 marksConsider a relational database schema with two relations and . Let be a tuple relational calculus expression. Which one of the following relational algebraic expressions is equivalent to ?
- A.
- B.✓
- C.
- D.
Open GATE CS 2026 Set 1 Q43 · discuss this question →Answer: B
Solution
Answer: (B) Map the variables: in , is and is . In , the same is . So the join condition is , and the output is : . Join order does not matter. - A.
- GATE CS 2025 Set 1 · Q39Databasesmcq2 marksConsider two relations describing and : - - Which ONE of the following tuple relational calculus queries returns the name of the players who play for the team having as 'MI'?
- A.✓
- B.
- C.
- D.
Open GATE CS 2025 Set 1 Q39 · discuss this question →Answer: A
Solution
Answer: (A) We want player names, so must range over (eliminating (B),(D)). We must link the player's team to a tuple named 'MI', which requires the join condition and . Option (C) drops the join , so it would return every player's name as long as some 'MI' team exists — wrong. Only (A) correctly joins the player to the 'MI' team. - A.
- GATE CS 2024 Set 1 · Q35Databasesnat1 markRelations and . The number of tuples from is _________Open GATE CS 2024 Set 1 Q35 · discuss this question →
Answer: 2
Solution
Answer: 2 Join on :Tuples with : and -> 2 tuples.A=10: (10,20)x(10,90) -> B=20,C=90 : 20<90 YES A=30: (30,45),(30,50) x (30,40),(30,50) (45,40) no ; (45,50) YES ; (50,40) no ; (50,50) no - GATE CS 2024 Set 2 · Q45Databasesmcq2 marksPerson(pid, city). Using selection, projection, cross product, rename, the minimum number of cross-product operations to find cities where at least 3 persons reside is
- A.1
- B.2✓
- C.3
- D.4
Open GATE CS 2024 Set 2 Q45 · discuss this question →Answer: B
Solution
Answer: (B) 2 To require three distinct persons in the same city, we need three copies of Person joined on equal city with distinct pids. Combining three renamed copies needs 2 cross-product (join) operations: , then select equal cities and pairwise-distinct pids, then project the city. - A.
- GATE CS 2022 · Q25Databasesmsq1 markRelations Employee(eId,Name), Brand(bId,bName), Own(eId,bId). Which relational algebra expression returns the set of eIds who own ALL the brands?
- A.✓
- B.✓
- C.
- D.
Open GATE CS 2022 Q25 · discuss this question →Answer: A, B
Solution
Answer: (A) and (B) "Owns all brands" is relational division. (A) expresses it directly: , projected on . (B) is the standard "division via difference" formulation: , which returns exactly the employees linked to every brand. Both are correct. - A.
- GATE CS 2021 Set 1 · Q37Databasesmcq2 marksThe following relation records the age of 500 employees of a company, where empNo (indicating the employee number) is the key:Consider the following relational algebra expression:What does the above expression generate?
- A.Employee numbers of only those employees whose age is the maximum.
- B.Employee numbers of only those employees whose age is more than the age of exactly one other employee.
- C.Employee numbers of all employees whose age is not the minimum.✓
- D.Employee numbers of all employees whose age is the minimum.
Open GATE CS 2021 Set 1 Q37 · discuss this question →Answer: C
Solution
The join pairs an employee with any other employee of smaller age. An employee appears in the result iff there exists someone younger, i.e. the employee's age is not the minimum. - A.
Databases: SQL Queries — GATE CS PYQ (5)
- GATE CS 2025 Set 1 · Q55Databasesnat2 marksConsider the database tables (instances shown) and the SQL query. The value returned by the query is ______. (Answer in integer)
player coach team members pid pname age cid cname tid tname city cid pid tid 1 Jasprit 31 101 Ricky 10 MI Mumbai 102 1 10 2 Atharva 24 102 Mark 20 DC Delhi 101 2 30 3 Ishan 26 103 Trevor 30 PK Mohali 103 3 10 4 Axar 30 4 20SELECT 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 )Open GATE CS 2025 Set 1 Q55 · discuss this question →Answer: 26
Solution
Answer: 26 - Coach 'Mark' has . - Team with is MI (). - Members of team : (Jasprit) and (Ishan). - Their ages: Jasprit , Ishan . - GATE CS 2025 Set 2 · Q54Databasesmsq2 marksSchema: Students(rollno,name,age,cgpa), Courses(courseno,cname,credits), Enrolled(rollno,courseno,grade). Which of the following is/are correct SQL to retrieve the names of students enrolled in courseno 1470?
- A.SELECT S.name FROM Students S WHERE EXISTS (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);✓
- B.SELECT S.name FROM Students S WHERE SIZEOF (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno) > 0;
- C.SELECT S.name FROM Students S WHERE 0 < (SELECT COUNT(*) FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);✓
- D.SELECT S.name FROM Students S NATURAL JOIN Enrolled E WHERE E.courseno = 1470;✓
Open GATE CS 2025 Set 2 Q54 · discuss this question →Answer: A, C, D
Solution
Answer: (A), (C) and (D) - (A) CorrelatedEXISTSsubquery returns students having a matching enrollment in course 1470. Correct. - (C)0 < (SELECT COUNT(*) ...)is true exactly when a matching enrollment exists. Correct. - (D)Students NATURAL JOIN Enrolledjoins on the common attributerollno; filteringcourseno = 1470gives the enrolled students' names. Correct. - (B)SIZEOFis not a valid SQL operator. Incorrect. - A.
- GATE CS 2023 · Q61Databasesnat2 marksFor the Student table (rows: 1 Naman M 62, 2 Aliya F 70, 3 Aliya F 80, 4 James M 82, 5 Swati F 65), the query
SELECT * FROM Student WHERE gender='F' AND marks>65returns __________ rowsOpen GATE CS 2023 Q61 · discuss this question →Answer: 2
Solution
Answer: 2 Female students: Aliya(70), Aliya(80), Swati(65). Of these, marks : Aliya(70) and Aliya(80). Swati(65) is not . So 2 rows. - GATE CS 2022 · Q56Databasesnat2 marksSchemas: Student(sNo,sName,dNo), Dept(dNo,dName), Course(cNo,cName,dNo), Register(sNo,cNo). The query
SELECT * FROM Student AS S WHERE NOT EXISTS (SELECT cNo FROM Course WHERE dNo='D01' EXCEPT SELECT cNo FROM Register WHERE sNo=S.sNo)returns __________ rows (students registered for every D01 course).Open GATE CS 2022 Q56 · discuss this question →Answer: 2
Solution
Answer: 2 The query uses the "NOT EXISTS ... EXCEPT" pattern to find students who are registered for every course offered by department D01 (relational division). Evaluating against the given instance, exactly 2 students satisfy this, so 2 rows are returned. - GATE CS 2021 Set 2 · Q41Databasesmcq2 marksThe relation scheme stores employee information, where
empIdis the key anddeptIdis the department to which the employee is assigned. Each employee is assigned to exactly one department.
Consider the SQL query:emp(empId, name, gender, salary, deptId)The above query gives, for each department in the company, the number of female employees whose salary is greater than the average salary of:select deptId, count(*) from emp where gender = "female" and salary > (select avg(salary) from emp) group by deptId;- A.employees in the department.
- B.employees in the company.✓
- C.female employees in the department.
- D.female employees in the company.
Open GATE CS 2021 Set 2 Q41 · discuss this question →Answer: B
Solution
The subquery(select avg(salary) from emp)is uncorrelated and computes the average salary over all employees in the company, so the comparison is against the company-wide average. - A.
Take a Databases chapter-wise test
Pick any chapters and attempt their PYQs with a timer in the GATE interface, with instant analysis — free.
Create free account →