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?
- (A)AD, ED and CD are the only candidate keys of R.
- (B)AD and ED are the only candidate keys of R.
- (C)A, E and CD are the only candidate keys of R.
- (D)A and CD are the only candidate keys of R.
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.
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?
- (A)Inserting records into relation r
- (B)Deleting records from relation s
- (C)Deleting records from relation r
- (D)Inserting records into relation s
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.
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)
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.
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?
- (A)5
- (B)8
- (C)3 and 5
- (D)3, 5 and 8
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.
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?
- (A)Two rows (P1, R1, 2) and (P1, R1, 5)
- (B)Three rows (P1, R1, 2), (P1, R1, 5) and (P2, R2, 6)
- (C)One row (P1, R1, 2)
- (D)Zero rows
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.
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?
- (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
- (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
- (C)SELECT B.EmpID, B.TeamSize FROM (SELECT EmpID, COUNT(TeamID) AS TeamSize FROM Employee GROUP BY EmpID) AS B
- (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
(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.
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)
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.
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)
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.
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)
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.
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?
- (A)If ({P, Q} → {R} and {P} → {R}), then {Q} → {R}
- (B)If {P, Q} → {R}, then ({P} → {R} or {Q} → {R})
- (C)If ({P} → {R} and {Q} → {S}), then {P, Q} → {R, S}
- (D)If {P} → {R}, then {P, Q} → {R}
(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.
In 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
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.
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?
- (A)Π_P(R ⋈_(R.P = S.X) S)
- (B)Π_P(S ⋈_(S.X = R.Q) R)
- (C)Π_P(R ⋈_(R.P = S.Y) S)
- (D)Π_P(S ⋈_(S.Y = R.Q) R)
⟨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).
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)
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.
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?
- (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
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.
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?
- (A)Both T1 and T2 only read X
- (B)T1 reads X and T2 writes X
- (C)T1 writes X and T2 reads X
- (D)Both T1 and T2 write X
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.
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?
- (A)Reflexivity, Augmentation, and Transitivity
- (B)Reflexivity and Augmentation
- (C)Transitivity
- (D)Augmentation and Transitivity
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.
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?
- (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
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.
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?
- (A)Selection
- (B)Projection
- (C)Join
- (D)Set union
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.
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?
- (A)All owners of a red car, a car made by ABC, or a red car made by ABC
- (B)All owners of more than one car, where at least one car is red and made by ABC
- (C)All owners of a red car made by ABC
- (D)All red cars made by ABC
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.
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');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.
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);
- (A)1
- (B)6
- (C)9
- (D)12
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.
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));- (A)aadhaar is a candidate key in the Customer relation
- (B)phone can be NULL in the Customer relation
- (C)aadhaar is a candidate key in the Person relation
- (D)aadhaar can be NULL in the Person relation
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.
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?
- (A)A is the only candidate key of R
- (B)A, BC are the candidate keys of R
- (C)A, BC, E are the candidate keys of R
- (D)Relation R is not in Boyce-Codd Normal Form (BCNF)
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.
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)
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.
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)
- (A)Only T2
- (B)Only T3
- (C)Both T2 and T3
- (D)Neither T2 nor T3
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.
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]
- (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.
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.
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'?
- (A){ p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ p.tid = t.tid ∧ t.tname = 'MI') }
- (B){ p.pname | p ∈ teams ∧ ∃t (t ∈ players ∧ p.tid = t.tid ∧ t.tname = 'MI') }
- (C){ p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ t.tname = 'MI') }
- (D){ p.pname | p ∈ teams ∧ ∃t (t ∈ players ∧ t.tname = 'MI') }
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.
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?
- (A)The relation team is NOT in BCNF.
- (B)The relations t1 and t2 are in BCNF.
- (C)The decomposition constitutes a lossless join.
- (D)The relation team is NOT in 3NF.
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.
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
)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).
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?
- (A)Atomicity
- (B)Consistency
- (C)Isolation
- (D)Durability
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.
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?
- (A)R1 is in 3NF
- (B)R2 is in 3NF
- (C)R1 is NOT in 3NF
- (D)R2 is NOT in 3NF
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.
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?
- (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)
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.
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?
- (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;
(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.
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)
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.
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?
- (A)Π_name(Team) \ (Π_name(Defender) ∩ Π_name(Forward)) = ϕ
- (B)(Π_name(Defender) ∩ Π_name(Forward)) \ Π_name(Team) = ϕ
- (C)Π_name(Team) \ (Π_name(Defender) ∪ Π_name(Forward)) = ϕ
- (D)(Π_name(Defender) ∪ Π_name(Forward)) \ Π_name(Team) = ϕ
'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.
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;
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).
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?
- (A)VW → YZ
- (B)WX → YZ
- (C)VW → U
- (D)VW → Y
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.
In a B+ tree, the requirement of at least half-full (50%) node occupancy is relaxed for which one of the following cases?
- (A)Only the root node
- (B)All leaf nodes
- (C)All internal nodes
- (D)Only the leftmost leaf node
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.
Which of the following 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
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.
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 _________
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.
The symbol → indicates functional dependency in the context of a relational database. Which of the following options is/are TRUE?
- (A)(X, Y) → (Z, W) implies X → (Z, W)
- (B)(X, Y) → (Z, W) implies (X, Y) → Z
- (C)((X, Y) → Z and W → Y) implies (X, W) → Z
- (D)(X → Y and Y → Z) implies X → Z
(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).
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?
- (A)T1T2T3
- (B)T1T3T2
- (C)T3T2T1
- (D)T3T1T2
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.
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
- (A)durability
- (B)atomicity
- (C)consistency
- (D)isolation
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.
In the context of owner and weak entity sets in the ER (Entity-Relationship) data model, which one of the following statements 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 in the identifying relationship
- (D)Neither weak entity set nor owner entity set MUST have total participation in the identifying relationship
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.
Which of the following file organizations is/are I/O efficient for the scan operation in DBMS?
- (A)Sorted
- (B)Heap
- (C)Unclustered tree index
- (D)Unclustered hash index
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.
Which of the following statements about the Two Phase Locking (2PL) protocol is/are TRUE?
- (A)2PL permits only serializable schedules
- (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
- (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
- (D)A deadlock is possible with 2PL
(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.
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
- (A)1
- (B)2
- (C)3
- (D)4
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.
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 ________
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.
Which one of the options given below refers to the degree (or 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.
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.
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;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).
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 ________.
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.
In a 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 attributes, then the relation is in BCNF.
- (C)Every relation has at least one non-prime attribute.
- (D)BCNF decompositions preserve functional dependencies.
(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.
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?
- (A)Π_eId(Π_eId,bId(Own) / Π_bId(Brand))
- (B)Π_eId(Own) − Π_eId((Π_eId(Own) × Π_bId(Brand)) − Π_eId,bId(Own))
- (C)Π_eId(Π_eId,bId(Own) / Π_bId(Own))
- (D)Π_eId((Π_eId(Own) × Π_bId(Own)) / Π_bId(Brand))
(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.
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 _____________.
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.
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?
- (A)T₁ → T₃ → T₄ → T₂
- (B)T₁ → T₄ → T₃ → T₂
- (C)T₄ → T₁ → T₃ → T₂
- (D)T₃ → T₁ → T₄ → T₂
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₄.
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)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.
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?
- (A)Every entity in E1 is associated with exactly one entity in E2.
- (B)Some entity in E1 is associated with more than one entity in E2.
- (C)Every entity in E2 is associated with exactly one entity in E1.
- (D)Every entity in E2 is associated with at most one entity in E1.
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).
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;- (A)Query 1
- (B)Query 2
- (C)Query 3
- (D)Query 4
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.
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?
- (A)σ_(B<5)(r ⋈ s)
- (B)σ_(B<5)(r LOJ s)
- (C)r LOJ (σ_(B<5)(s))
- (D)σ_(B<5)(r) LOJ s
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.
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?
- (A)Schema I
- (B)Schema II
- (C)Schema III
- (D)Schema IV
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}.
Which of the following is NOT a superkey in a relational schema with attributes V, W, X, Y, Z and primary key VY?
- (A)VXYZ
- (B)VWXZ
- (C)VWXY
- (D)VWXYZ
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.
Which one of the following is NOT a part of the ACID properties of database transactions?
- (A)Atomicity
- (B)Consistency
- (C)Isolation
- (D)Deadlock-freedom
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.
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?
- (A)1NF
- (B)2NF
- (C)3NF
- (D)BCNF
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.
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
- (A)guarantee serializability and deadlock-freedom
- (B)guarantee neither serializability nor deadlock-freedom
- (C)guarantee serializability but not deadlock-freedom
- (D)guarantee deadlock-freedom but not serializability
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.
B+ Trees are considered BALANCED because
- (A)the lengths of the paths from the root to all leaf nodes are all equal.
- (B)the lengths of the paths from the root to all leaf nodes differ from each other by at most 1.
- (C)the number of children of any two non-leaf sibling nodes differ by at most 1.
- (D)the number of records in any two leaf nodes differ by at most 1.
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.
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?
- (A)Topological order
- (B)Depth-first order
- (C)Breadth-first order
- (D)Ascending order of transaction indices
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.
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?
- (A)S is non-recoverable
- (B)S is recoverable, but has a cascading abort
- (C)S does not have a cascading abort
- (D)S is strict
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.
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.capacitytotal: 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.
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?
- (A){E, F}
- (B){E, F, H}
- (C){E, F, H, K, L}
- (D){E}
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.
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)- (A)S1 is TRUE and S2 is FALSE.
- (B)Both S1 and S2 are TRUE.
- (C)S1 is FALSE and S2 is TRUE.
- (D)Both S1 and S2 are FALSE.
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.
A prime attribute of a relation scheme R is an attribute that appears
- (A)in all candidate keys of R.
- (B)in some candidate key of R.
- (C)in a foreign key of R.
- (D)only in the primary key of R.
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.
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
- (A)some dependent.
- (B)all dependents.
- (C)some of his/her dependents.
- (D)all of his/her dependents.
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.
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');- (A)Names of all the employees with at least one of their customers having a 'GOOD' rating.
- (B)Names of all the employees with at most one of their customers having a 'GOOD' rating.
- (C)Names of all the employees with none of their customers having a 'GOOD' rating.
- (D)Names of all the employees with all their customers having a 'GOOD' rating.
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.