For attributes P,Q,R,S, assess: A PQ→R and P→R imply Q→R; B PQ→R implies P→R or Q→R; C P→R and Q→S imply PQ→RS; D P→R implies PQ→R.
Select all that apply
Answer & solution
Official answer: C, D
Step through it (4 parts)
Givens and goal
For attributes P,Q,R,S, assess: A PQ→R and P→R imply Q→R; B PQ→R implies P→R or Q→R; C P→R and Q→S imply PQ→RS; D P→R implies PQ→R.
Approach
Prove valid implications with agreement of tuples or Armstrong’s axioms, and refute invalid ones with small relations.
Step-by-step solution
1. To prove D, take two tuples agreeing on both P and Q. They agree on P, so P→R forces agreement on R. Adding an attribute to the determinant cannot invalidate a dependency. Thus D is true. 2. To prove C, two tuples agreeing on PQ agree on P and therefore R; they also agree on Q and therefore S. Hence they agree on RS, establishing PQ→RS. This is augmentation followed by union. 3. A is false. Consider the rows (P,Q,R,S)=(0,0,0,0) and (1,0,1,0). P uniquely determines R, and PQ also determines R. However the same Q=0 occurs with both R=0 and R=1, so Q→R fails. There is no “cancellation” rule for determinant attributes. 4. B is false. Use four rows with S fixed at 0 and R=P XOR Q:
P Q R S
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 0
Every PQ pair has one R, so PQ→R holds. Holding only P fixed allows two R values, and holding only Q fixed does likewise. Neither individual dependency holds. 5. Therefore only C and D are always true. One relation satisfying the premises and violating the conclusion is sufficient to disprove each proposed universal inference.
Choose the true normalization claims: A dependency-preserving 3NF decomposition is always possible; B dependency-preserving 1NF decomposition is always possible; C dependency-preserving BCNF decomposition is not always possible; D dependency-preserving 2NF decomposition is not always possible.
Select all that apply
Answer & solution
Official answer: A, B, C
Givens and goal
Choose the true normalization claims: A dependency-preserving 3NF decomposition is always possible; B dependency-preserving 1NF decomposition is always possible; C dependency-preserving BCNF decomposition is not always possible; D dependency-preserving 2NF decomposition is not always possible.
Approach
Use the constructive 3NF existence result for weaker forms, and a specific dependency set to demonstrate the BCNF limitation.
Step-by-step solution
1. The 3NF synthesis construction can always produce a dependency-preserving 3NF decomposition for a relation and its functional dependencies. It starts from a minimal cover, groups appropriate determinants with their dependents, and includes a candidate-key relation if needed for losslessness. Thus A is true. 2. Since a relation in 3NF also satisfies 2NF and 1NF, the same dependency-preserving decomposition supplies existence witnesses for both lower normal forms. Hence B is true and the assertion of possible failure at 2NF in D is false. 3. BCNF does not always permit dependency preservation. For an explicit witness, consider R(A,B,C) with AB → C and C → B. Its candidate keys are AB and AC. The dependency C → B violates BCNF because C does not determine A. 4. Any BCNF decomposition must use proper subrelations rather than retaining all of ABC. Among proper subrelations, the only essential nontrivial projected dependency is C → B on BC; the projections on AB and AC contain no nontrivial dependencies. Thus the union of all available proper projections cannot imply AB → C: under that union, the closure of AB never acquires C. No collection of those BCNF components can preserve the original dependencies. This proves C.
Common error: A lossless BCNF decomposition does not automatically preserve every dependency. Losslessness and dependency preservation are separate requirements.
In the BCNF witness, AB is a key by AB→C, and AC is a key because C→B. Neither A alone nor B alone nor C alone determines all three attributes. A lossless split into BC and AC can preserve C→B, but the dependency AB→C cannot then be checked from the projected dependencies without reconstructing the join. This illustrates the difference between lossless data reconstruction and local enforcement of dependencies.
Translating existential joins into relational algebra
Relational Algebra & Calculus
Tap to enlarge
Relations are R(P,Q) and S(X,Y). The query returns u whenever there exist v,w with (u,v) in R and (v,w) in S. Select the equivalent projection/join expression. The alternatives join P to X, Q to X, P to Y, or Q to Y, and all project P.
Your answer
Answer & solution
Official answer: B
Givens and goal
Relations are R(P,Q) and S(X,Y). The query returns u whenever there exist v,w with (u,v) in R and (v,w) in S. Select the equivalent projection/join expression. The alternatives join P to X, Q to X, P to Y, or Q to Y, and all project P.
Approach
Map each quantified variable to its relation attribute, use the repeated variable as the join equality, and project the requested output coordinate.
Step-by-step solution
1. Membership (u,v)∈R means u=R.P and v=R.Q. Membership (v,w)∈S means v=S.X and w=S.Y. 2. The same variable v occurs in both tuples, so qualifying tuple pairs must satisfy R.Q=S.X. This is the equijoin condition; neither R.P nor S.Y is the repeated coordinate. 3. After joining, the query asks only for u. Since u is R.P, project attribute P from the join. Thus the expression is π_P(R ⋈_(R.Q=S.X) S). 4. Option B writes the operands in the reverse order, π_P(S ⋈_(S.X=R.Q) R), which is equivalent for this inner equijoin and projection. Therefore select B. 5. For example, R containing (a,7) and S containing (7,b) must produce a. The two 7 values are the ones that need to match. Joins equating P with X, P with Y, or Q with Y would impose a different condition. The existential variables v and w disappear from the output through projection; ordinary relational algebra uses set semantics here.
R has four attributes A,B,C,D. Its only candidate keys are {A,B} and {A,C}. Count all superkeys.
Answer & solution
Official answer: 6
Givens and goal
R has four attributes A,B,C,D. Its only candidate keys are {A,B} and {A,C}. Count all superkeys.
Approach
Every superset of a candidate key is a superkey; count both superset families and subtract their overlap.
Step-by-step solution
1. A candidate key is a minimal superkey. Adding attributes preserves the ability to identify a tuple, so every set containing AB or AC is a superkey. 2. For AB, the remaining attributes C and D may each be included or omitted independently, giving 2²=4 supersets: AB,ABC,ABD,ABCD. 3. For AC, optional attributes B and D similarly give AC,ABC,ACD,ABCD, again four. 4. A set counted in both families must contain AB∪AC=ABC. Its only optional attribute is D, so the overlap is {ABC,ABCD}, of size 2. 5. Inclusion-exclusion gives 4+4−2=6. The six distinct superkeys are AB,AC,ABC,ABD,ACD,ABCD. 6. There are no others: from any superkey one can repeatedly remove unnecessary attributes until a minimal superkey, hence a candidate key, remains. The premise says the only such minima are AB and AC, so every superkey must contain at least one of them. D need not belong to a candidate key to occur in larger superkeys.
Match I logical schema, II physical schema, III external schema with L views, M file organization and indexes, N relations. Options: 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.
Your answer
Answer & solution
Official answer: C
Givens and goal
Match I logical schema, II physical schema, III external schema with L views, M file organization and indexes, N relations. Options: 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.
Approach
Distinguish what is stored logically, how it is stored, and what a user sees.
Step-by-step solution
1. The logical schema describes database structure at the relation level: tables, attributes, and their logical relationships. It therefore matches N, relations. 2. The physical schema describes storage choices such as file layout and indexes. Those choices determine access paths without changing the logical relation definitions, so II matches M. 3. An external schema is a view of data exposed to a particular user or application. It may hide attributes or combine relations. Hence III matches L. 4. The resulting matching I-N,II-M,III-L is C. For example, a payroll view can remain unchanged while a new B+ tree index is added; this illustrates why external and physical descriptions are separate levels.
Two distinct concurrent transactions T1 and T2 both access object A. Which access pattern avoids a conflict on A? A both only read; B T1 reads,T2 writes; C T1 writes,T2 reads; D both write.
Your answer
Answer & solution
Official answer: A
Givens and goal
Two distinct concurrent transactions T1 and T2 both access object A. Which access pattern avoids a conflict on A? A both only read; B T1 reads,T2 writes; C T1 writes,T2 reads; D both write.
Approach
Apply the same-object, different-transaction, at-least-one-write definition.
Step-by-step solution
1. Two operations conflict when they are from different transactions, access the same data item, and at least one is a write. The first two conditions are already given here. 2. Two reads do not change the object. Swapping their order does not change either observed value, so read-read is the nonconflicting pair. 3. In read-write or write-read, swapping order can change the value read. In write-write, it can change which written value remains. Hence B, C, and D all contain a conflict. 4. Therefore all accesses by both transactions to A must be reads, giving A. This local absence of conflict on A does not establish that the complete transactions have no conflicts on other objects.
Deriving the union rule for functional dependencies
Functional Dependencies & Keys
Tap to enlarge
Armstrong rules are reflexivity (Y⊆X implies X→Y), augmentation (X→Y implies XZ→YZ), and transitivity. To derive union, X→Y and X→Z imply X→YZ, which listed rule set is necessary and sufficient? A all three; B reflexivity+augmentation; C transitivity; D augmentation+transitivity.
Your answer
Answer & solution
Official answer: D
Givens and goal
Armstrong rules are reflexivity (Y⊆X implies X→Y), augmentation (X→Y implies XZ→YZ), and transitivity. To derive union, X→Y and X→Z imply X→YZ, which listed rule set is necessary and sufficient? A all three; B reflexivity+augmentation; C transitivity; D augmentation+transitivity.
Approach
Construct a proof that does not use reflexivity, then rule out the smaller listed alternatives.
Step-by-step solution
1. Augment the premise X→Y with X. Because attribute-set union is idempotent, XX=X; this gives X→XY. 2. Augment the premise X→Z with Y. This gives XY→ZY, which is XY→YZ because attribute-set union is commutative. 3. Apply transitivity to X→XY and XY→YZ to obtain X→YZ. Thus augmentation and transitivity suffice, with no application of reflexivity. 4. Transitivity alone cannot generally introduce a new combined right-hand-side set. For singleton distinct attributes X={x},Y={y},Z={z}, the two premises x→y and x→z provide no chain yielding x→yz. 5. Reflexivity and augmentation without transitivity also do not generally combine two premises. Starting from x→y, augmentation by z yields xz→yz, not x→yz; starting from x→z and adding y yields xy→yz. Removing the added left-side attribute requires a further inference not available in those two rules. 6. The minimal listed combination for the general derivation is D. This necessity concerns the rule schema for arbitrary attribute sets, not special cases where Y or Z is already contained in another set.
An index is dense if it has an entry for every search-key value in its indexed file; otherwise it is sparse. S1: a hash index must be dense. S2: a B+ tree index can be sparse. Options: A both true; B both false; C only S1; D only S2.
Your answer
Answer & solution
Official answer: A
Givens and goal
An index is dense if it has an entry for every search-key value in its indexed file; otherwise it is sparse. S1: a hash index must be dense. S2: a B+ tree index can be sparse. Options: A both true; B both false; C only S1; D only S2.
Approach
Ask whether omitted keys can be found from an ordered boundary entry.
Step-by-step solution
1. In the standard hash-index model, searching key k uses h(k) to locate its bucket and then the relevant search-key entry. Hash values do not arrange keys in sorted order, so an entry for a nearby smaller key does not identify where an omitted key belongs. 2. Consequently the search-key index must represent every indexed value: S1 is true under the problem’s dense/sparse definition. A bucket directory is a different structure from the entries for the indexed search-key values. 3. For an ordered data file, a B+ tree can hold just one boundary key per data block. Searching for k finds the appropriate boundary and follows its pointer, then scans that block for k. Most individual keys need not appear in the index. 4. This is a valid sparse B+ tree index, establishing S2. A B+ tree can also be dense, but the statement only says can be sparse. 5. Thus A is correct. Sparseness relies on the supporting ordered-file organization; a sparse boundary index over arbitrary unordered records would not provide this search guarantee.
A database schedule is R1(X), W1(Y), R2(X), R2(Y), R3(Y), followed by ABORT(T1). No intervening commit or write is shown. Which other transactions must roll back? A only T2; B only T3; C both T2 and T3; D neither.
Your answer
Answer & solution
Official answer: C
Step through it (8 steps)
Approach: Track reads of a value produced by an uncommitted transaction; read-read overlap alone is not a rollback dependency. W1(Y) installs T1’s new value of Y. R2(Y) occurs after that write and before T1 commits, so T2 reads an uncommitted value from T1. R3(Y) sees the same value because no intervening write to Y is shown; T3 also depends on T1. When T1 aborts, its write to Y must be undone. Both dependent transactions have computed using a value that cannot be retained, so both must roll back. This is a cascading rollback and gives C. The reads R1(X) and R2(X) do not establish a dirty-read dependency because neither transaction writes X in this schedule. The important issue is which transaction produced the value read, not simply whether two transactions access the same data item.
A pictured B+ tree has a root with keys [6,12,19] and four leaf children, shown left to right as [1,4,3], [7,9,10], [13,15,17], [20,21,22]. Each node holds at most three keys, and there are five nodes initially. Insert 23 using ordinary B+ tree insertion. Which statements hold? A no node splits; B at least one node splits and redistributes; C node count stays unchanged; D height increases. The unsorted first leaf [1,4,3] is reproduced literally, not silently repaired.
Select all that apply
Answer & solution
Official answer: B, D
Approach: Follow the insertion path and propagate any overflow upward. Because 23 exceeds the largest root separator, it routes to the rightmost leaf [20,21,22]. Adding it produces four keys in a node whose capacity is three. This leaf must split into two leaves under the ordinary insertion algorithm; for example its data can be distributed as [20,21] and [22,23]. A separator for the new leaf is inserted into the parent. The parent is the root and is already full with three keys. Its overflow requires an internal-node split and a new root above the split pieces. Thus the height increases by one. B and D are true, while A and C are false. The usual allocation adds one leaf, one internal node and one new root, raising five nodes to eight. the printed first leaf is unsorted, so the figure is not literally a valid B+ tree. Separator conventions also are not fully specified. The intended overflow argument uses the unaffected rightmost branch and assumes a valid initial tree apart from the diagram defect. The official B;D answer is preserved, with that limitation explicit.
Relations are teams(tid,tname) and players(pid,pname,tid). Return names of players on a team named MI. A {p.pname | p∈players ∧ ∃t(t∈teams ∧ p.tid=t.tid ∧ t.tname='MI')}; B the same expression but p∈teams and t∈players; C the expression in A without p.tid=t.tid; D the expression in B without p.tid=t.tid. Which is correct?
Your answer
Answer & solution
Official answer: A
Approach: Translate the desired result into tuple bindings, a join predicate, a selection predicate and a projected attribute. A returned name must come from a player tuple, so bind p to players. There must exist a team tuple t whose id equals the player’s team id, giving t∈teams and p.tid=t.tid. The selected team must have t.tname='MI'. Project p.pname from precisely those player tuples. These requirements combine exactly as A. B and D bind p to teams even though teams has no pname attribute, and bind t to players even though players has no tname attribute. They are not correctly typed for the supplied schemas. C has the right bindings but omits the join. If any team is called MI, its existential condition becomes true for every player, including players on other teams. That illustrates why a selection on team name does not replace the relationship connecting a player to that team.
Schema team(name,city,owner) has dependencies name→city and name→owner, and is decomposed into t1(name,city),t2(name,owner). Select true statements: A team is not BCNF; B both components are BCNF; C the join is lossless; D team is not 3NF.
Select all that apply
Answer & solution
Official answer: B, C
Step through it (4 parts)
Approach: Find the key, check the determinants of nontrivial dependencies, then use the binary lossless-join criterion. The closure of {name} contains name, city and owner, so name is a key of team. All nontrivial given dependencies, and their relevant nontrivial consequences, have a determinant containing that key. Therefore team is BCNF. Since BCNF implies 3NF, A and D are false. In t1, name determines city; in t2, name determines owner. Thus name is also a key of each component and both are BCNF, making B true. The common attribute set is t1∩t2={name}. It determines all attributes of t1 and also all attributes of t2. In particular it satisfies the binary lossless-join condition that the intersection determine one component. Therefore joining the projections cannot create spurious combinations for any original instance satisfying the dependencies, making C true. Select B,C. Decomposition is not needed to fix a normal-form violation here; it is nevertheless lossless, and the listed dependencies are also retained in the separate components.
Tables: player(pid,pname,age) has (1,Jasprit,31),(2,Atharva,24),(3,Ishan,26),(4,Axar,30). coach(cid,cname) has (101,Ricky),(102,Mark),(103,Trevor). team(tid,tname,city,cid) has (10,MI,Mumbai,102),(20,DC,Delhi,101),(30,PK,Mohali,103). members(pid,tid) has (1,10),(2,30),(3,10),(4,20). Evaluate SELECT MIN(P.age) FROM player P WHERE P.pid IN (SELECT M.pid FROM team T,coach C,members M WHERE C.cname='Mark' AND T.cid=C.cid AND M.tid=T.tid).
Answer & solution
Official answer: 26
Approach: Evaluate the inner join and filter to get a set of player IDs, then apply the outer aggregate only to those players. The condition C.cname='Mark' selects coach row cid=102. Joining on T.cid=C.cid selects team tid=10, because that is the team coached by 102. Joining membership on M.tid=T.tid then selects the rows (1,10) and (3,10), so the subquery returns player IDs {1,3}. The outer WHERE P.pid IN (...) retains Jasprit, age 31, and Ishan, age 26. MIN over those two ages is 26, which is the returned value. Atharva’s age 24 is smaller overall but belongs to team 30 coached by Trevor; the predicate removes that row before MIN is computed. Axar likewise belongs to team 20 coached by Ricky. This demonstrates why aggregating over the entire player table before applying the team/coach restriction would be incorrect.
Two joint holders simultaneously transfer ₹10000 each from account A to B. Both transactions read A's initial balance as ₹11000 and are allowed to finish. B receives two ₹10000 credits, but A is debited only once and ends at ₹1000. Which ACID properties are certainly violated? Options: A. atomicity; B. consistency; C. isolation; D. durability.
Select all that apply
Answer & solution
Official answer: B, C
A typical interleaving is: T1 reads A=11000; T2 reads A=11000; each computes 11000−10000=1000; T1 writes A=1000 and T2 overwrites it with the same value. Both credits to B survive. This is a lost update.
Isolation fails because the result is not equivalent to executing the two valid transfers serially. After the first transfer, a serial second transaction would observe A=1000, not the original 11000; it could be rejected for insufficient funds or, if overdraft were permitted, debit to −9000. Neither serial behavior produces the reported one-debit/two-credit result.
Consistency also fails: A decreases by only 10000 while B increases by 20000, so the transfer has created 10000 of aggregate balance rather than conserving it. Atomicity need not fail: both transactions may have executed all their own read/write steps and committed, with the race occurring between otherwise complete transactions. Durability is about retaining committed results despite later failures, and no such loss after a failure is described. Thus only B and C are certain.
Relations have the following complete sets of functional dependencies: R1(A,B,C,D,E): D→E, EA→B, EB→C. R2(A,B,C,D): A→D, A→B, C→A. Select true assertions: A. R1 is in 3NF; B. R2 is in 3NF; C. R1 is not in 3NF; D. R2 is not in 3NF.
Select all that apply
Answer & solution
Official answer: C, D
Step through it (2 parts)
For 3NF, every nontrivial dependency X→Y must have X a superkey or each right-hand attribute prime, meaning it belongs to some candidate key. Identify the keys before applying this test.
In R1, A and D never appear on any right-hand side, so neither can be obtained from other attributes and every key must contain both. Compute (AD)+: start with A,D; D→E adds E; EA→B adds B; EB→C adds C. Thus AD determines all five attributes and is the unique candidate key. Only A,D are prime. The dependency D→E violates 3NF: D+=DE is not a superkey and E is nonprime. Hence R1 is not in 3NF.
In R2, C never appears on a right-hand side and must belong to every key. C→A, followed by A→D and A→B, gives C+=ABCD, so C alone is the unique candidate key. A is not a superkey, since A+=ABD lacks C, and D,B are nonprime. Either A→D or A→B therefore violates 3NF. R2 is not in 3NF either. Select C,D.
R_i(V) and W_i(V) denote transaction i reading/writing item V; C_i is its commit. Select all conflict-serializable schedules. A. R1(X),W2(X),W1(Y),W2(Y),R1(X),W1(X),C2,C1. B. W2(X),R1(X),W2(Y),W1(Y),R1(X),C2,W1(X),C1. C. R1(X),W1(Y),W2(X),W2(Y),R1(X),W1(X),C1,C2. D. W2(X),R1(X),W1(Y),W2(Y),R1(X),C2,W1(X),C1.
Select all that apply
Answer & solution
Official answer: B
Step through it (4 schedules)
Construct a precedence graph with vertices T1,T2. Two operations conflict when they are in different transactions, access the same item, and at least one is a write. An earlier conflicting operation from Ti followed by one from Tj creates edge Ti→Tj. The schedule is conflict-serializable exactly when this graph is acyclic.
In A, the first R1(X) precedes W2(X), giving T1→T2. The later R1(X), and also W1(X), follow W2(X), giving T2→T1. There is a cycle. C has the same two conflicting directions on X, so it also fails.
In B, W2(X) precedes both reads and the write of X by T1. On Y, W2(Y) precedes W1(Y). Thus all intertransaction conflicts point T2→T1; there is no reverse edge. This is conflict-equivalent to serial order T2 followed by T1.
In D, the X conflicts point T2→T1, but W1(Y) precedes W2(Y), adding T1→T2 and creating a cycle. Commit positions do not remove conflicts or make a cyclic precedence graph acyclic. Select B only. Conflict serializability is a property distinct from whether an interleaving satisfies a particular recovery or locking protocol.
Schema: Students(rollno,name,age,cgpa), Courses(courseno,cname,credits), Enrolled(rollno,courseno,grade). Primary keys are Students.rollno, Courses.courseno, and the composite Enrolled(rollno,courseno). Which SQL queries retrieve names of students enrolled in course 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;
Select all that apply
Answer & solution
Official answer: A, C, D
A's correlated subquery considers enrollment rows for the current student's rollno and the requested course. EXISTS is true exactly when at least one such row exists, so A returns the desired name.
C tests the same correlated set. COUNT(*) returns a scalar count, including zero when no enrollment matches. The condition 0<count is therefore equivalent to existence, so C is also valid. B tries to use SIZEOF(subquery), which is not the standard SQL operator for counting a query result; COUNT(*) is the relevant aggregate.
For D, the only shared attribute name between Students and Enrolled is rollno, so NATURAL JOIN equates those roll numbers. Filtering the joined row by courseno=1470 selects enrolled students and projecting S.name gives their names. Thus D is the intended third valid query; Courses is unnecessary because the required course number is already stored in Enrolled.
The source marks (rollno,courseno) as Enrolled's composite primary key, so at most one enrollment can match a given student and course. D therefore has the same per-student-row multiplicity as A/C. Different students may share a name, and none of these queries removes such duplicate names. Without the composite-key constraint, a join could repeat a name per matching enrollment, but that is not the stated schema. The correct selection is A,C,D.
A B+ tree node holds at most four keys. One root-to-leaf path is A=(49,77,83,−), B=(7,19,33,44), C=(20*,22*,25*,26*), where stars mark leaf data entries. A pointer between separators k1,k2 covers [k1,k2), and a newly created leaf copies its smallest key into its parent. Insert key 23. What is the smallest separator key in the parent of the resulting leaf that contains 25*?
Answer & solution
Official answer: 33
The insertion belongs in C because 19≤23<33. Its sorted data entries become [20*,22*,23*,25*,26*], exceeding the four-key limit, so C splits. With a 2/3 split, the leaves are [20*,22*] and [23*,25*,26*], and separator 23 is copied up. With a 3/2 split, they are [20*,22*,23*] and [25*,26*], and separator 25 is copied up. Let k be that copied separator, either 23 or 25.
B was already full. After receiving k, its ordered separators are [7,19,k,33,44], so B must split as well. For an internal-node split, the middle separator k is promoted to A rather than kept as a key in either split internal node. The left internal node retains [7,19], and the right retains [33,44]. The leaf holding 25* is on the right side of k and is a child of this right internal node.
Consequently its parent's smallest stored key is 33, even though that parent has a leftmost child whose values can be smaller than 33. A had spare capacity, so receiving k causes no further split. The unspecified 2/3 versus 3/2 leaf convention does not change the requested answer: 33.
Choose the ER diagram for: instructors teach courses; students register for courses; courses receive classrooms; instructors guide students. Rectangles denote entities and diamonds denote relationships. A diagram (i) uses a Student diamond and Registration rectangle. B diagram (ii) uses a Projects entity in place of Student. C diagram (iii) directly links Classroom to Course while its Allocation diamond is attached only to Course. D diagram (iv) has entities Instructor, Course, Student, Classroom and relationships Teaches(Instructor,Course), Registration(Student,Course), Allocation(Course,Classroom), Guides(Instructor,Student).
Your answer
Answer & solution
Official answer: D
Approach: Identify the objects first, then check the two endpoint entities of each relationship. 1. The four object categories are Instructor, Course, Student and Classroom. These must be entity rectangles. The verbs or associations become relationship diamonds: Teaches, Registration, Allocation and Guides. 2. Teaches must connect Instructor to Course; Registration must connect Student to Course; Allocation must connect Course to Classroom; Guides must connect Instructor to Student. Diagram (iv) satisfies all four requirements. 3. Diagram (i) interchanges the semantic roles of Student and Registration, using the wrong kinds of symbols. Diagram (ii) introduces Projects instead of the specified Student entity. 4. Diagram (iii) has a direct Classroom–Course edge and does not connect Classroom through Allocation; the named allocation relationship is therefore not properly represented. Answer: D. The specification does not give cardinality constraints such as one-to-many, so there is no need to invent them when selecting the diagram.
Which claims about a relation R in first normal form are true? A R may 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.
Select all that apply
Answer & solution
Official answer: A, C
Approach: First normal form concerns the form of attribute values, not the number of columns in a key or the number of valid identifiers. 1. In the usual relational model, a 1NF relation stores one atomic value in each attribute position. An undivided composite attribute, such as an Address object containing separate Street and City components, must be represented using suitable atomic columns. Thus C is true in the intended terminology. 2. Several individually atomic columns can together uniquely identify a row. For example, (StudentID,CourseID) can be a key of an enrollment relation. This is a composite key, not a composite attribute, so A is true. 3. A foreign key simply constrains values to reference another relation. It is compatible with atomic values, so B is false. 4. Different columns or column sets may each identify rows uniquely. First normal form does not forbid multiple candidate keys, so D is false. Answer: A and C.
R(A,B) has rows (10,20),(20,30),(30,40),(30,50),(50,95). S(A,C) has rows (10,90),(30,45),(40,80). Join R and S on equal A values, then keep rows with B<C. How many tuples remain?
Answer & solution
Official answer: 2
Approach: First match rows using the join condition, then test the selection condition for each resulting pair. 1. At A=10, R's B=20 matches S's C=90. The equijoin row is (R.A,B,S.A,C)=(10,20,10,90), and 20<90 is true. Below, write the equal A columns once as shorthand (A,B,C). 2. At A=30, there are two R rows and one S row. They produce (30,40,45) and (30,50,45). The first passes 40<45; the second fails 50<45. 3. R's A=20 and A=50 rows find no matching S row. S's A=40 row finds no R partner. An ordinary inner equijoin does not retain these unmatched rows. 4. The join therefore creates three tuples, of which exactly two survive the B<C filter. Answer: 2. Repeated A values in R must not be collapsed: each matching row contributes its own joined tuple before selection.
Prove functional dependencies and refute a converse
Functional Dependencies & Keys
Tap to enlarge
Which functional-dependency implications are valid? A XY→ZW implies X→ZW. B XY→ZW implies XY→Z. C XY→Z and W→Y imply XW→Z. D X→Y and Y→Z imply X→Z. Concatenated letters denote attribute sets.
Select all that apply
Answer & solution
Official answer: B, C, D
Step through it (4 parts)
Approach: Treat a functional dependency as a guarantee that equality on its left side forces equality on its right side. Use Armstrong-style inference or a concrete counterexample. 1. A is false: dropping a determinant attribute can lose information. Consider rows (X,Y,Z,W)=(0,0,0,0) and (0,1,1,1). Their XY values differ, so XY→ZW holds, but equal X values have different ZW values, violating X→ZW. 2. B is true by decomposition. If equal XY forces both Z and W to agree, it certainly forces Z alone to agree. 3. C is true. From equal XW, we have equal W, hence equal Y by W→Y. We now have equal XY, which forces equal Z by XY→Z. Equivalently, the closure of XW contains Y and then Z. 4. D is the transitivity rule: agreement on X gives agreement on Y, then on Z. Answer: B, C and D. Decomposing the right-hand side is valid; arbitrarily decomposing the left-hand side is not.
The schedule is r1(z); w1(z); r2(x); r3(y); w3(y); r2(y); w2(x); w2(y), where subscripts name transactions. Which serial schedules are conflict equivalent? A T1 T2 T3; B T1 T3 T2; C T3 T2 T1; D T3 T1 T2.
Select all that apply
Answer & solution
Official answer: B, C, D
Step through it (10 steps)
Approach: Only operations from different transactions on the same data item, with at least one write, impose conflict-order constraints. 1. Transaction T1 touches only z. Neither T2 nor T3 uses z, so T1 has no conflicts with the others and may appear anywhere in a serial order. 2. Only T2 accesses x, so x creates no intertransaction constraint. 3. On y, T3's read and write precede T2's read and write. Conflicting pairs include w3(y) before r2(y), w3(y) before w2(y), and r3(y) before w2(y). Each demands the same precedence edge T3→T2. 4. A conflict-equivalent serial order must therefore put T3 before T2, with T1 free. The valid orders are T1 T3 T2, T3 T2 T1, and T3 T1 T2. Answer: B, C and D. Option A reverses the y-conflict order. Merely knowing that the precedence graph is acyclic establishes serializability; enumerating its topological orders identifies the actual choices.
A DBMS has told the user a transaction succeeded. Its effect must survive a crash even if all changed data pages have not reached disk. Which ACID property is this? A durability; B atomicity; C consistency; D isolation.
Your answer
Answer & solution
Official answer: A
Approach: Identify which guarantee applies after successful commit.
1. Derivation. Durability guarantees that the effect of an acknowledged committed transaction survives a crash, typically through durable logging and recovery even if data pages have not yet been flushed. Atomicity is all-or-nothing execution, consistency concerns integrity constraints, and isolation concerns interference. Answer A.
2. Explanation and checks. Durability need not mean that every modified database page is already stored in its final disk location. A sufficiently durable commit record and log can permit recovery to redo committed changes after restart. Atomicity instead prevents partial effects of an unsuccessful transaction; isolation controls interactions among simultaneous transactions. Consistency concerns preservation of the database constraints when transactions execute correctly. The decisive words here are successful completion and persistence after a crash.
In an ER model, what participation in an identifying relationship is mandatory? A total participation of the weak entity set; B total participation of the owner entity set; C both sets must participate totally; D neither must.
Your answer
Answer & solution
Official answer: A
Approach: Distinguish the dependent entity from the entity that supplies its identity.
1. Derivation. A weak entity needs its identifying owner relationship to determine its identity; every weak entity therefore participates. An owner may exist with no dependent weak entity unless a separate application constraint requires one. Thus total participation is mandatory for the weak entity set only, option A.
2. Explanation and checks. For example, a dependent identified by an employee identifier together with a dependent-name discriminator cannot exist in this model without an employee owner. However an employee can have no dependents and still have its own identity. “Total participation” means every entity in that set appears in the relationship; it does not mean every possible owner–dependent pair is related. Thus mandatory dependence flows from weak entity to owner, not in both directions.
Which file organizations are I/O-efficient for scanning all records? A sorted file; B heap file; C unclustered tree index; D unclustered hash index.
Select all that apply
Answer & solution
Official answer: A, B
Approach: Optimize for reading the entire data set, not for retrieving a few qualifying records.
1. Derivation. A full scan of a sorted file or a heap file reads the data pages sequentially, usually once each. Scanning through an unclustered index can chase record pointers to many scattered data pages, causing repeated/random I/O. Thus the I/O-efficient file organizations for the full scan are A, B; a selective index lookup is a different workload.
2. Explanation and checks. For a data file occupying B pages, scanning the file in its physical order takes about B page reads whether the records have a sorted order or an arbitrary heap order. An unclustered index does not group the data records in index traversal order, so neighboring index entries may point to different pages and cause random accesses or rereads. The index also has its own pages to read. Selectivity can make an index attractive for lookup, but that is absent in a full scan.
Which statements about two-phase locking are true? A it permits only serializable schedules; B every operation locks just before and releases immediately after; C after the first lock release a transaction can acquire no new lock; D deadlock can occur.
Select all that apply
Answer & solution
Official answer: A, C, D
Approach: Apply the no-new-locks-after-release rule and distinguish serializability from progress.
1. Derivation. Two-phase locking first acquires locks and then, after the first release, only releases locks. The no-new-locks shrinking-phase rule proves C. Ordering transactions by their lock points proves conflict serializability, hence A. It does not release every lock immediately after each operation, and deadlock is possible: T1 holds X and waits for Y while T2 holds Y and waits for X. Thus A, C, D.
2. Explanation and checks. The growing phase permits acquisition but no release; the shrinking phase permits release but no acquisition. The instant at which a transaction acquires its final lock is its lock point; ordering transactions by such points is consistent with every conflicting dependency, giving a serial order. Holding X while waiting for Y and holding Y while waiting for X obey the growing-phase rule, so 2PL can still deadlock. Releasing each lock immediately, as B claims, would prevent later acquisitions and is not the general protocol.
Witness three distinct residents with two products
Relational Algebra & Calculus
Tap to enlarge
Person(pid,city) has a unique pid per person. Using only selection, projection, cross product and rename, how many cross-product operations are minimally required to find cities with at least three residents? A 1; B 2; C 3; D 4.
Your answer
Answer & solution
Official answer: B
Approach: Introduce one independently chosen tuple for each person that must be witnessed.
1. Derivation. Rename three copies P1, P2, P3 of Person and take their product using two binary cross products. Select equal cities and pairwise distinct pids, then project the city. This identifies exactly cities with at least three residents. With only one cross product, selection/projection/rename can expose at most two independently chosen source tuples, which cannot witness a third distinct person. Thus the minimum is 2, option B, in the stated algebra without aggregation or other operators.
2. Explanation and checks. Write P1×P2×P3 as (P1×P2)×P3. Select P1.city=P2.city=P3.city and P1.pid≠P2.pid, P1.pid≠P3.pid, P2.pid≠P3.pid, then project P1.city. All three inequalities are necessary to prevent a two-person city from reusing one person. Rename, selection and projection do not introduce an additional independently chosen resident. This lower-bound argument assumes the stated relational algebra expression model, not a materialized intermediate relation supplied from outside the expression.
Count disjoint nonempty sides of a functional dependency
Functional Dependencies & Keys
Tap to enlarge
On a schema of four attributes, call X→Y useful when X and Y are both nonempty and X∩Y=∅. How many different such dependencies are possible?
Answer & solution
Official answer: 50
Approach: Assign each attribute to the left side, right side, or neither, then exclude empty sides.
1. Derivation. For each of four attributes choose membership in X, membership in Y, or neither: 3⁴ assignments enforce disjointness. Exclude assignments with X empty (2⁴) and Y empty (2⁴), then restore the all-neither assignment counted twice. The number is 3⁴−2⁴−2⁴+1=81−16−16+1=50. This counts possible syntactic dependencies, not dependencies that necessarily hold on a particular instance.
2. Explanation and checks. An alternative count chooses the size k of X: sum from k=1 to 3 of C(4,k)(24−k−1). For k=1 there are 4×7=28 choices; k=2 gives 6×3=18; k=3 gives 4×1=4, totaling 50. X→Y and Y→X are different dependencies because direction matters. Multiattribute right sides are allowed by the definition; restricting Y to a single attribute would answer a different question.
What is a relation's degree or arity? A number of attributes; B number of tuples; C number of entries; D number of distinct attribute domains.
Your answer
Answer & solution
Official answer: A
The degree or arity of a relation is its number of attributes/columns. Its number of tuples is its cardinality, and multiple attributes may share a domain. Therefore A.
Teaching detail. For example, a Student relation with columns rollNum, name, gender, marks has degree 4 whether it contains zero rows or a million rows. Its cardinality changes when rows are inserted, but its arity changes only if the schema's attribute count changes. Two columns can share the same domain, such as two integer-valued attributes, so counting distinct domains can undercount attributes. “Entries” is not the precise schema-level definition sought here.
Student rows (rollNum,name,gender,marks) are (1,Naman,M,62),(2,Aliya,F,70),(3,Aliya,F,80),(4,James,M,82),(5,Swati,F,65); rollNum is primary key. How many rows does SELECT * FROM Student WHERE gender='F' AND marks>65 return?
Answer & solution
Official answer: 2
The condition requires both female gender and marks strictly greater than 65. Roll numbers 2 and 3 qualify, with marks 70 and 80. Swati has exactly 65 and is excluded; the other two rows are male. The two Aliya rows remain distinct because their roll numbers differ, and SELECT * does not deduplicate them. The result contains 2 rows.
Teaching detail. Evaluate the conjunction row by row: row 1 fails gender, row 2 passes both predicates, row 3 passes both, row 4 fails gender despite high marks, and row 5 fails the strict greater-than test. The primary key identifies records by rollNum, not by name, so equal names do not imply one record. SQL's ordinary SELECT is not SELECT DISTINCT; moreover even DISTINCT over all columns would keep the two qualifying rows because both roll numbers and marks differ. Only the number of qualifying rows is requested.
An ordered file has 25,000 unspanned records of 100 bytes, including a 15-byte primary key. Blocks hold 1024 bytes. A sparse primary index has one anchor key and 5-byte block pointer per data block, with unspanned entries. Binary search on b index blocks costs ceil(log2 b) accesses by stipulation. How many accesses identify the candidate data block, without reading that block?
Answer & solution
Official answer: 6
Each data block holds floor(1024/100)=10 unspanned records, so 25000 records occupy 2500 blocks. The sparse primary index has one anchor entry per data block. Each entry occupies 15+5=20 bytes, so an index block holds floor(1024/20)=51 entries and the index needs ceil(2500/51)=50 blocks. By the expressly given search-cost rule, identifying the data-block pointer costs ceil(log2 50)=6 block accesses. Reading that data block would add one more, but the question asks only to identify it.
Teaching detail. Unspanned storage requires rounding at each level before progressing. A block cannot store 10.24 records, so 24 bytes remain unused after its ten full records. Similarly an index block stores 51 complete 20-byte entries, leaving four bytes. There are 2500 data-block anchors, not 25,000 record-level entries, because the index is sparse. Since 49·51=2499, a fiftieth index block is necessary for the final anchor. With 32<50≤64, the stated ceiling-logarithm search rule yields six accesses, excluding the data fetch.
Which relational-model statement is true under the intended textbook interpretation? A every two-attribute relation is BCNF; B all attributes prime implies BCNF; C every relation has a nonprime attribute; D BCNF decompositions preserve functional dependencies. Discuss any needed qualification.
Your answer
Answer & solution
Official answer: A
Our answer: A under the nonempty-determinant convention
With two attributes A, B and nonempty determinants, the only potentially nontrivial dependencies are A→B and B→A; either determinant is a key. Thus the relation is BCNF, intended A. All-prime attributes do not suffice: R(A, B, C) with AB→C and C→B has keys AB and AC but violates BCNF. BCNF decomposition need not preserve all dependencies. Literal qualification: empty determinants are legal in general FD theory. If ∅→A holds in R(A, B) while B varies, ∅ is not a superkey, so this binary relation is not BCNF. Official A therefore needs the usual exclusion of constant-column dependencies, which the prompt does not state.
BCNF requires every determinant of a nontrivial functional dependency to be a superkey. For the three-attribute counterexample, AB and AC each determine all attributes, so all attributes are prime, but C alone determines B without determining A. This also illustrates why “prime” is weaker than the BCNF determinant condition. Keep the empty-determinant exception separate from the intended exam convention.
Given Employee(eId,Name), Brand(bId,bName), Own(eId,bId), select expressions returning owners of every brand. Define O=π_eId,bId(Own), E=π_eId(Own), B=π_bId(Brand), H=π_bId(Own). Options: A π_eId(O÷B); B E−π_eId((E×B)−O); C π_eId(O÷H); D π_eId((E×H)÷B).
Select all that apply
Answer & solution
Official answer: A,B
Our answer: A,B under the standard division candidate universe
A divides the employee-brand pairs by all brand IDs. B starts with employee IDs occurring in Own and removes those with at least one missing pair from the Cartesian product with Brand. These are the standard equivalent formulations of relational division. C divides only by brands that someone owns, potentially omitting unowned brands; D manufactures ownership pairs by a Cartesian product. Thus A, B. Boundary qualification: both A and B use π_eId(Own), not all rows of Employee, as their candidate universe. If Brand is empty and “all brands” is interpreted vacuously for every Employee, employees absent from Own are omitted. The intended nonempty-brand/owner-universe reading should be kept explicit.
For B, E×B enumerates every required owner-brand pair, and subtracting O finds missing ownerships. Projecting to eId identifies failures, which are subtracted from E. For C, one brand absent from all Own tuples is a counterexample: division by H ignores it. D can claim someone owns a brand merely because another employee owns it.
For R(A,B,C,D,E), dependencies are AB→C, BC→D, C→E. How many superkeys exist?
Answer & solution
Official answer: 8
Step through it (3 steps)
A and B never appear on a dependency’s right side, so every key and superkey must include both. AB determines C, then BC determines D, and C determines E; hence AB is a key. All superkeys are AB with any subset of {C, D, E}, giving 2³=8.
Compute (AB)+: begin {A,B}; AB→C adds C; BC→D adds D; C→E adds E. No set lacking A or B can obtain it from these FDs, proving AB is the unique minimal key. The eight superkeys are AB,ABC,ABD,ABE,ABCD,ABCE,ABDE,ABCDE.
With Ri(z),Wi(z) denoting transaction i's reads/writes, schedule S is R4(x),R2(x),R3(x),R1(y),W1(y),W2(x),W3(y),R4(y). Choose a conflict-equivalent serial order: A 1,3,4,2; B 1,4,3,2; C 4,1,3,2; D 3,1,4,2.
Your answer
Answer & solution
Official answer: A
Step through it (10 steps)
Conflicts on x give T4→T2 and T3→T2. Conflicts on y give T1→T3, T1→T4 and T3→T4. Their topological order is T1, T3, T4, T2, option A. Read-read pairs add no edges.
The precedence graph can be drawn as T1→T3→T4→T2, with additional T1→T4 and T3→T2 edges. Each edge enforces the same relative ordering of conflicting operations in a serial schedule. Since this chain orders all four transactions, the topological order is unique.
Student(sNo,sName,dNo): (S01,James,D01),(S02,Rocky,D01),(S03,Jackson,D02),(S04,Jane,D01),(S05,Milli,D02). Dept: (D01,CSE),(D02,EEE). Course(cNo,cName,dNo): (C11,DS,D01),(C12,OS,D01),(C21,DE,D02),(C22,PT,D02),(C23,CV,D03). Register pairs: S01:C11,C12; S02:C11; S03:C21,C22,C23; S04:C11,C12; S05:C11,C21. Count rows returned by 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 printed spelling/quotes are retained to expose the source syntax issue.
Answer & solution
Official answer: 2
The intended NOT EXISTS test succeeds when the set of D01 courses minus the student's registered courses is empty. The D01 course set is {C11, C12}. Therefore the intended query returns 2 student rows. Source syntax discrepancy: the printed SQL says NOT EXIST, missing the final S, and uses typographic double quotes around D01. Executable standard SQL needs NOT EXISTS and a single-quoted character literal. The official numeric answer assumes these obvious syntax repairs; the literal printed statement is not valid standard SQL.
The missing-D01-course sets are S01:∅, S02:{C12}, S03:{C11,C12}, S04:∅, S05:{C12}. NOT EXISTS accepts only empty sets. A student’s own department is not a filter in the outer query; only coverage of the D01 courses matters.
A database crashes again while recovering from a previous crash. No checkpoints are taken during transactions or recovery. Select correct statements in the intended basic recovery model. A the same undo and redo lists are used on restarting recovery; B further recovery is impossible; C transactions already undone/redone will not be recovered again; D the database becomes inconsistent.
Select all that apply
Answer & solution
Official answer: A
Our answer: A in the basic repeated undo/redo model
Without a new checkpoint or changed transaction-completion history, restarting recovery analyzes the same log to identify the same committed and uncommitted transactions. Undo/redo actions are designed to be idempotent, so a second crash does not make recovery impossible or inherently inconsistent. Thus A in the intended basic log-recovery model. An implementation with compensation log records may track already completed recovery work more precisely; the answer is not a universal claim that every recovery algorithm literally repeats an unchanged physical work list.
Redo reapplies logged updates for transactions whose effects must survive; undo removes effects of incomplete transactions. Idempotence means redo(redo(state))=redo(state), with corresponding safe repeated undo semantics. A crash can leave only a prefix of recovery finished, so a correct recovery design cannot assume that restarting itself destroys consistency. No new checkpoint is available to certify that the earlier log prefix can be ignored. More elaborate logging of recovery work is precisely the qualification already retained above.
A database relation r(A,B) is stated to contain 1200 tuples. A takes integer values 6 through 20 and B values 1 through 20; A and B are independently distributed. Estimate the output count of σ[(A>10) OR (B=18)](r). The source does not explicitly assume uniform distributions and its tuple count exceeds the distinct-pair domain size.
Answer & solution
Official answer: 819 to 820 OR 205
Our answer: 820 under uniform bag estimation; official also accepts 205
Under uniform independent attribute estimates, P(A>10)=10/15 and P(B=18)=1/20. Inclusion-exclusion gives selection fraction 10/15+1/20−(10/15)(1/20)=41/60. Multiplying by 1200 gives 820. The official key also accepts 205, which is the number of distinct qualifying pairs in the full 15×20 value grid: 200 pairs with A>10 plus 5 additional pairs with B=18. Both official alternatives are preserved exactly. Premise issues: independence alone does not imply uniform marginals, and a mathematical set relation with only these two finite-domain attributes can have at most 300 distinct tuples, not 1200. The820 estimate therefore uses bag/count statistics and uniformity assumptions; 205 corresponds to the distinct-pair grid, not 1200 distinct source tuples.
There are 15 A-values and 20 B-values. Ten A-values (11 through 20) pass A>10, while one B-value passes B=18. The overlap must be subtracted because OR counts a tuple satisfying both only once. Under the full-grid model there are 10×20+15×1−10×1=205 qualifying pairs out of 300, so the selectivity is 205/300=41/60. Applying that fraction to the stated 1200 rows yields 820. These are distinct interpretations, not two different arithmetic roundings of one count.
empAge(empNo,age) stores ages of 500 employees, with empNo a key. Evaluate π_empNo(empAge ⋈_[age>age1] ρ_[empNo1,age1](empAge)). A employee numbers with maximum age only; B those older than exactly one other employee; C all those whose age is not minimum; D all those with minimum age.
Your answer
Answer & solution
Official answer: C
The renamed second copy supplies another employee’s age. The theta join retains a first-copy employee whenever some other row has a strictly smaller age. Projecting empNo therefore returns exactly employees whose age is not the minimum. Minimum-age ties are all excluded. Thus C.
The join is existential after projection: an employee appears if there exists any employee of smaller age. An employee of minimum age has no such witness and is excluded, even if multiple employees tie for minimum. For ages 20,20,30,40 the output contains the 30- and 40-year-old employee numbers. The 40-year-old has several witnesses, but set projection removes duplicates; it is not restricted to 'exactly one' younger employee.
Similar questions10 more → · asked again: GATE 2007, Q64
Transactions & Concurrency Control
Tap to enlarge
Let ri(z),wi(z) denote reads/writes by transaction Ti. S1=r1(x),r1(y),r2(x),r2(y),w2(y),w1(x). S2=r1(x),r2(x),r2(y),w2(y),r1(y),w1(x). Which schedules are conflict-serializable? A S1 only; B S2 only; C both; D neither.
Your answer
Answer & solution
Official answer: B
Step through it (2 schedules)
In S1, r1(y) before w2(y) gives T1→T2, while r2(x) before w1(x) gives T2→T1, creating a cycle. In S2, w2(y) before r1(y) and r2(x) before w1(x) both give only T2→T1. Therefore S1 is not conflict-serializable while S2 is, equivalent to T2 thenT1. Answer B.
Only different transactions accessing the same item, with at least one write, create precedence edges. Reads of x by both transactions do not conflict. In S1, y imposes T1 before T2 whereas x imposes T2 before T1, making a directed cycle. Moving r1(y) after w2(y) in S2 reverses the y constraint; all constraints now agree. An acyclic precedence graph is the necessary and sufficient test for conflict serializability.
R(P,Q,S,T,X,Y,Z,W) has FDs PQ→X, P→YX, Q→Y, Y→ZW. D1 decomposes it into (P,Q,S,T),(P,T,X),(Q,Y),(Y,Z,W). D2 decomposes it into (P,Q,S),(T,X),(Q,Y),(Y,Z,W). Which is correct? A D1 lossless/D2 lossy; B D1 lossy/D2 lossless; C both lossless; D both lossy.
Your answer
Answer & solution
Official answer: A
Step through it (2 parts)
For D1, join PQST with PTX on PT: P→X makes PT a key of PTX, so this step is lossless. Join QY using Q→Y, then YZW using Y→ZW; both steps are lossless. D2 separates TX from every other component, leaving no common attribute to reconnect it. A concrete legal relation can contain two rows with distinct P, Q, S, T, X, Y, Z, W values; all listed FDs hold, but joining its D2 projections pairs each TX row with either other-part row, creating spurious tuples. Thus D1 is lossless and D2 lossy, A.
For D1, add projections in the order PQST,PTX,QY,YZW. Their intersections with the accumulated schema are PT,Q,Y respectively, each determining all attributes of the new projection via P→X,Q→Y,Y→ZW. The binary lossless-join criterion applies at each step. For D2 use two original tuples (p1,q1,s1,t1,x1,y1,z1,w1) and (p2,q2,s2,t2,x2,y2,z2,w2) with every subscripted value distinct. All FDs hold, yet the join contains (p1,q1,s1,t2,x2,y1,z1,w1), which was not an original tuple.
Relational model statements: S1 a relation schema has at most one foreign key; S2 a foreign key in R cannot refer to tuples of R itself. A both; B only S1; C only S2; D neither.
Your answer
Answer & solution
Official answer: D
A relation can have several foreign keys, for example managerId and departmentId. It can also reference itself, as managerId referencing another employee in the same employee relation. Both proposed restrictions are false, D.
A concrete schema is Employee(id,managerId,deptId), where managerId references Employee(id) and deptId references Department(id). It simultaneously refutes both claims. A foreign key enforces referenced-key membership; it does not impose a one-foreign-key limit or require a different relation name.
150000 student records sorted by primary key RollNo. Secondary candidate key ANum uses 12 bytes; record pointers 7 bytes. Index records contain ANum and corresponding record pointer. Blocks are 4096 bytes and records cannot straddle blocks. Find index block count.
Answer & solution
Official answer: 698
The secondary candidate-key index is dense, with one entry per student. Each entry needs 12+7=19 bytes. With no split entries, each 4096-byte block holds floor(4096/19)=215 entries. Thus ceil(150000/215)=698 blocks.
ANum is not the ordering key of the data file, so a sparse primary index with one entry per data block is not applicable. Packing permits 215 complete 19-byte entries per block because 216 require 4104 bytes. There are 697 full blocks holding 149855 entries and 145 entries in a final block.
Schema emp(empId,name,gender,salary,deptId), key empId, each employee in one department. Query: select deptId,count(*) from emp where gender="female" and salary>(select avg(salary) from emp) group by deptId. Counts female employees above which mean? A employees in department; B employees in company; C women in department; D women in company.
Your answer
Answer & solution
Official answer: B
The uncorrelated subquery averages salary across the entire emp relation, with no gender or department filter. The outer query counts female employees above that company-wide average, grouped by department. Thus B. Departments with no qualifying rows are omitted rather than returned with count 0. The printed double-quoted female is understood as an intended string literal; standard SQL uses single quotes, while double quotes ordinarily delimit identifiers.
The inner SELECT has no reference to the outer row, so its scalar mean is computed over all emp rows. The gender test is outside it and does not restrict that mean. GROUP BY affects the final count, not the subquery's population. This distinction separates all four options.
Schedule R1(Y),R1(X),R2(Z),R1(Y),W1(X),R2(Z),W2(Y),R3(X),W3(Z). P: conflict-serializable. Q: if T3 commits before T1 finishes, schedule is recoverable. A both; B only P; C only Q; D neither.
Your answer
Answer & solution
Official answer: B
Step through it (2 schedules)
On Y, R1(Y) precedes W2(Y), giving T1→T2. On X, W1(X) precedes R3(X), giving T1→T3. On Z, R2(Z) precedes W3(Z), giving T2→T3. This acyclic graph has serial orderT1, T2, T3, so P is true. T3 reads X written by T1; committing T3 before T1 finishes violates recoverability. Hence Q is false and B holds.
Conflicts require the same data item, distinct transactions, and at least one write. Repeated reads of Z do not introduce a reverse edge. Serializability and recoverability are distinct: an acyclic precedence graph controls equivalent ordering of operations, whereas a reads-from dependency requires the writer to commit before its reader commits.
On U(P,Q,R,S,T), dependencies P→QR and RS→T hold. Which follow? A PS→T; B R→T; C P→R; D PS→Q.
Select all that apply
Answer & solution
Official answer: A; C; D
Step through it (4 parts)
P→QR gives P→R and P→Q by decomposition. With PS, derive R and retain S, then RS→T gives PS→T; also PS→Q follows by augmentation and decomposition. Starting only from R yields closure{R}, so R→T is not implied. Therefore A, C, D.
Attribute closure of PS starts {P,S}, then adds Q,R using P→QR, then T using RS→T, giving all five attributes. Closure of P is {P,Q,R}, and closure of R is only {R}. The latter is a complete test of nonimplication: no listed dependency can fire from R alone, so S cannot be conjured merely because it appears beside R in RS→T.
Catalogue(sno,pno,cost) has rows (S1,P1,150),(S1,P2,50),(S1,P3,100),(S2,P4,200),(S2,P5,250),(S3,P1,250),(S3,P2,150),(S3,P5,300),(S3,P4,250), primary key (sno,pno). Suppliers has primary key sno and one row each: S1/Royal furniture/Delhi, S2/Balaji furniture/Bangalore, S3/Premium furniture/Chennai. Parts has primary key pno: P1/Table/Wood, P2/Chair/Wood, P3/Table/Steel, P4/Almirah/Steel, P5/Almirah/Wood. Count rows returned by: SELECT s.sno, s.sname FROM Suppliers s, Catalogue c WHERE s.sno=c.sno AND cost > (SELECT AVG(cost) FROM Catalogue WHERE pno='P4' GROUP BY pno); Options: A 4; B 5; C 0; D 2.
Your answer
Answer & solution
Official answer: A
Worked explanation
Evaluate the uncorrelated scalar subquery once. Filtering pno=P4 leaves prices 200 and 250, so its one group has average 225. Apply the outer strict comparison to every Catalogue row; prices 250,250,300,250 survive. The supplier primary key makes each surviving row join with exactly one supplier row, so the join neither loses nor multiplies them. Projection returns S2 once and S3 three times. SQL SELECT uses bag semantics unless DISTINCT is requested; it does not automatically collapse those repeated S3 names. The Parts table is not referenced by this query and cannot affect the count.
Derivation and answer
The P4 rows have costs 200 and 250, so the subquery returns 225. Catalogue costs greater than 225 occur at(S2, P5),(S3, P1),(S3, P5),(S3, P4): four rows. The supplier join preserves all four and SELECT has no DISTINCT, so repeated S3 output rows remain. Answer 4, A.
In an ER diagram, which symbol denotes the supporting many-to-one relationship for a weak entity? A double/bold diamond; B double/bold rectangle; C double/bold oval; D oval with underlined identifier.
Your answer
Answer & solution
Official answer: A
Worked explanation
In Chen notation, shape and border encode different information. A rectangle denotes an entity, an oval an attribute, and a diamond a relationship. A double rectangle marks a weak entity whose identity depends on an owner. The supporting identifying relationship is correspondingly the double diamond. A double oval normally represents a multivalued attribute, and underlining an attribute name indicates key information, not a relationship. Because the question asks about the relationship rather than the weak entity itself, A rather than B is required.
Derivation and answer
The identifying relationship connecting a weak entity to its owner is shown by a double-bordered diamond in the standard Chen ER notation. A double rectangle denotes the weak entity itself. Thus A.
R is in 3NF but not BCNF. Which must hold? A a nontrivial FD X→A has nonsuperkey X and prime A; B such an FD has nonprime A and X not a proper subset of any key; C such an FD has nonprime A and X a proper subset of some key; D some cell is a set rather than atomic.
Your answer
Answer & solution
Official answer: A
Worked explanation
For each nontrivial dependency X→A, BCNF requires X to be a superkey. 3NF allows an exception when A is prime, meaning A belongs to at least one candidate key. Because R is not BCNF, at least one dependency violates its determinant requirement. Because R still is 3NF, that violating dependency must meet the prime-attribute exception. This proves A directly. Whether X is or is not a proper subset of a key cannot make a nonprime right-hand side acceptable to 3NF when X is not a superkey. Option D contradicts the ordinary atomic-relation setting.
Derivation and answer
Failure of BCNF guarantees a nontrivial FD X→A with X not a superkey. Since3NF still holds, its permitted exception forces A to be prime, belonging to some candidate key. Thus A. The nonprime alternatives violate 3NF, and set-valued cells violate the assumed first normal form.
Read the following schedule equivalents left to right; Ri(X),Wi(X) belong to transaction i. Both commits follow the listed operations in order C1,C2. Original: R1(A),R2(B),W2(B),R1(C),R2(D),W1(D),W2(C),W1(B),C1,C2. Which is conflict equivalent? A R2(B),W2(B),R2(D),R1(A),R1(C),W1(D),W1(B),W2(C),C1,C2. B R1(A),R1(C),W1(D),W1(B),R2(B),W2(B),R2(D),W2(C),C1,C2. C R1(A),R1(C),W1(D),R2(B),W2(B),R2(D),W1(B),W2(C),C1,C2. D R2(B),W2(B),R2(D),W2(C),R1(A),R1(C),W1(D),W1(B),C1,C2.
Your answer
Answer & solution
Official answer: A
Step through it (5 schedules)
Worked explanation
Two operations conflict exactly when they belong to different transactions, access the same item, and at least one writes. There is no cross-transaction access to A. On B, both R2(B) and W2(B) precede W1(B). On D, R2(D) precedes W1(D). On C, R1(C) precedes W2(C). Those four pairwise orders are the complete test, independent of where unrelated reads move. A preserves all four and each transaction’s internal order. B reverses the B and D orders; C reverses only the D order among these; D reverses C. The precedence graph contains both T2→T1 and T1→T2, so the original is not conflict-serializable, but it can still have a conflict-equivalent nonserial schedule. Do not confuse these two questions.
Derivation and answer
The original intertransaction conflict orders are R2(B)<W1(B), W2(B)<W1(B), R2(D)<W1(D), and R1(C)<W2(C). OptionA preserves all four. B reverses the B andD conflicts; C reverses theD conflict; D reverses theC conflict. Thus A.
A B+ tree indexes one million records on a disk with 4 KB blocks. Search keys are 12 bytes and tree/disk pointers 8 bytes. Initially no index node or record is cached; each record fits in one disk block. Find the minimum disk accesses to retrieve any record in the conventional separate-record layout.
Answer & solution
Official answer: 4
Worked explanation
An internal node with m child pointers has m−1 separating keys. Its bytes are 8m+12(m−1)=20m−12, at most 4096. Thus m≤205.4 and maximum fanout is 205 (206 would require 4108 bytes). A leaf key/record-pointer pair takes 20 bytes, so it holds at most 204 pairs; adding an 8-byte next-leaf pointer still permits 204. Two index levels, root and leaves, hold at most 205×204=41820 entries and cannot cover one million. Three levels have capacity 205²×204=8573100, enough. A lookup must read one node per level, then follow the leaf’s record pointer to a separate data block. Three index reads plus one data read give four. The calculation concerns minimum height, not arbitrarily sparse trees.
Derivation and answer
With4KB=4096 bytes, an internal node with m child pointers and m−1 keys needs 8m+12(m−1)≤4096, giving maximum fanout 205. A leaf holds up to 204 key/record-pointer pairs even with one 8-byte next-leaf pointer. A root plus leaves can address at most 205*204=41820 records, below one million. Three index levels can address 205*205*204=8573100 records, so the minimum tree has three levels. With nothing cached, fetch root, internal node and leaf, then the separate record block: 4 disk accesses. This is the conventional separate-record B+ index layout; the record itself is not stored inline in the leaf.
Serializability under strict 2PL and Thomas’s rule
Transactions & Concurrency Control
Tap to enlarge
Assess two claims: I strict two-phase locking generates conflict-serializable and recoverable schedules; II timestamp ordering with Thomas's Write Rule can generate view-serializable schedules that are not conflict-serializable. Choices: A I only; B II only; C both; D neither.
Your answer
Answer & solution
Official answer: C
Method: separate the ordering guarantee of locking from the weaker observational guarantee allowed by ignoring obsolete writes.
1. In two-phase locking, a transaction first acquires locks and then releases them; it cannot acquire a new lock after releasing one. Ordering transactions by their lock points yields an order consistent with their conflicting operations. Hence 2PL gives conflict serializability. 2. Strict 2PL additionally retains exclusive locks until commit or abort. A second transaction cannot read a value written by the first before that writer commits, so it cannot commit while depending on an uncommitted writer. This prevents cascading dirty reads and implies recoverability. Thus I is true. 3. Thomas's Write Rule modifies timestamp ordering: if a proposed write is older than an already recorded write timestamp, and the relevant read-timestamp check does not require abort, that obsolete write can be ignored. It need not replace the newer value. 4. Ignoring such a write can preserve every transaction's observed reads and the appropriate final writes even where the logical ordering of conflicting write requests cannot be rearranged by conflict-equivalent swaps. View serializability preserves those observations and final writers, whereas conflict serializability imposes the stronger pairwise-operation ordering condition. Thus Thomas's rule can admit view-serializable schedules beyond conflict serializability, making II true.
Result: C, both statements. Recoverability and serializability are distinct properties; the first follows here from strict locking, not merely from conflict serializability alone.
Which statement about a B+ tree index is incorrect? A it is height-balanced; B non-leaf nodes have pointers to data records; C each node's keys are sorted; D each leaf has a pointer to the next leaf.
Your answer
Answer & solution
Official answer: B
Method: distinguish routing information in internal nodes from data entries at leaves.
1. A B+ tree keeps all leaves at the same depth, giving a balanced search height. Thus A describes the standard structure correctly. 2. An internal node contains separator keys and child-node pointers. Comparing a search key against the separators chooses the child subtree that may contain the record. Those pointers lead to more index nodes, not directly to the table's data records. 3. Data entries or record references occur at the leaves. Therefore B assigns a leaf responsibility to non-leaf nodes and is the incorrect statement. 4. Sorted keys let a node determine the correct child or locate the leaf entry, so C is correct. Linking leaves supports ordered scans and range queries without repeatedly returning to the root, so D is the usual leaf-link property; the last leaf's next pointer is null.
Result: B. This leaf-focused record organization is a key distinction between a B+ tree and a B-tree variant that may keep records in internal nodes.
On X(P,Q,R,S), F={QR→S, R→P, S→Q}. Decompose X into Y(P,R) and Z(Q,R,S). Test I: both components are BCNF; II: the decomposition is lossless and dependency preserving. Options A both, B I only, C II only, D neither.
Your answer
Answer & solution
Official answer: C
Step through it (3 parts)
1. BCNF requires the determinant of every nontrivial functional dependency to be a superkey. In Y, R→P gives R+={R,P}, so R is a key and Y is in BCNF. 2. In Z, S→Q still holds. But S+ within Z is only {S,Q}; no dependency derives R. Thus S is not a superkey and this nontrivial dependency violates BCNF. Statement I is false. 3. Dependency preservation asks whether enforcing dependencies locally suffices for the original F. R→P can be checked in Y; QR→S and S→Q can both be checked in Z. All original dependencies survive, so preservation holds. 4. For a binary decomposition, losslessness follows if the intersection functionally determines either component. Y∩Z={R}, and R→PR means the intersection determines Y. Joining valid projections therefore introduces no spurious tuples. 5. Both parts of II hold, so II alone is true: C. Losslessness and dependency preservation are distinct tests; neither implies that every resulting relation must satisfy BCNF.
Student rows (Roll_no,Student_name) are (1,Amit),(2,Priya),(3,Vinit),(4,Rohan),(5,Smita). Performance rows (Roll_no,Subject_code,Marks) are (1,A,86),(1,B,95),(1,C,90),(2,A,89),(2,C,92),(3,C,80). Student key is Roll_no and Performance key is (Roll_no,Subject_code). Query: SELECT S.Student_name, sum(P.Marks) FROM Student S, Performance P WHERE P.Marks>84 GROUP BY S.Student_name. How many rows result?
Answer & solution
Official answer: 5
1. Read the actual WHERE clause before inferring the intended relationship. It contains P.Marks>84 but no condition S.Roll_no=P.Roll_no. Listing both tables in FROM therefore forms their Cartesian product, not a join on the similarly named columns. 2. Five Performance rows pass the filter: marks 86,95,90,89,92. The 80-mark row is excluded. Each of the five Student rows pairs with every one of these five surviving rows, yielding 25 intermediate rows. 3. GROUP BY S.Student_name partitions those rows by the five distinct student names. Each group has five rows and the same marks sum: 86+95+90+89+92=452. 4. The result is (Amit,452), (Priya,452), (Vinit,452), (Rohan,452), (Smita,452), in unspecified order. Hence the requested row count is 5. 5. Rohan and Smita are included even though they have no Performance records: the query never correlates a performance with its owner. Primary keys do not automatically add a join predicate. Adding that missing predicate would answer a different query and must not be silently done.
Relations: P(X,Y,Z)={(X1,Y1,Z1),(X1,Y1,Z2),(X2,Y2,Z2),(X2,Y4,Z4)}; Q(X,Y,T)={(X2,Y1,2),(X1,Y2,5),(X1,Y1,6),(X3,Y3,1)}; R(Y,V)={(Y1,V1),(Y3,V2),(Y2,V3),(Y2,V2)}. Count tuples in π_X(σ_{P.Y=R.Y and R.V=V2}(P×R)) − π_X(σ_{Q.Y=R.Y and Q.T>2}(Q×R)).
Answer & solution
Official answer: 1
1. Evaluate the two projected sets separately before subtracting them. The left selection is an equality join on Y with the additional restriction R.V=V2. 2. Restricting R to V2 leaves (Y3,V2) and (Y2,V2). P has no Y3 tuple and has exactly one Y2 tuple, (X2,Y2,Z2). Thus the left join contributes X2 and its projection is {X2}. P's Y1 and Y4 rows fail the selection. 3. On the right, first keep Q rows with T>2: (X1,Y2,5) and (X1,Y1,6). The rows with T=2 and T=1 are excluded by the strict inequality. 4. The surviving Y2 row matches two R rows, with V3 and V2; the Y1 row matches (Y1,V1). These three join tuples all carry X1. Relational-algebra projection removes duplicates, so the right projected set is {X1}, not three copies of X1. 5. Set difference keeps left-side tuples absent from the right side: {X2}−{X1}={X2}. The result contains exactly 1 tuple. 6. Difference is directional and is not subtraction of the two row counts. Also, relational algebra uses set projection here; SQL without DISTINCT would require separate attention to bag semantics.
R is a many-to-one relation E1→E2. Both entity sets participate totally and |E1|>|E2|. Which holds? A each E1 entity has exactly one E2 partner; B some E1 entity has multiple E2 partners; C each E2 entity has exactly one E1 partner; D each E2 entity has at most one E1 partner.
Your answer
Answer & solution
Official answer: A
Method
Treat the relation as a mapping from E1 into E2. “Many-to-one” imposes an upper bound of one on each E1 entity’s partners, and “total participation” imposes a lower bound of one. Together they force exactly one. On the E2 side total participation makes the map surjective, while the larger source cardinality invokes the pigeonhole principle: at least one E2 entity receives two or more partners.
Solution
Many-to-one permits at most one E2 target per E1 entity. Total participation of E1 supplies at least one, hence exactly one. Total participation of E2 and |E1|>|E2| ensure some E2 target has multiple preimages, not exactly one each. Thus A.
For Book(isbn,bname) and Stock(isbn,copies), all queries select B.isbn,S.copies and join on equal isbn. Queries 1–4 respectively use INNER, LEFT OUTER, RIGHT OUTER and FULL OUTER JOIN. Which result necessarily contains the other three? A 1; B 2; C 3; D 4.
Your answer
Answer & solution
Official answer: D
Method
Divide possible output rows into matched pairs, unmatched Book rows and unmatched Stock rows. An inner join emits only the first group. A left join additionally emits unmatched Book rows with null Stock columns; a right join analogously preserves unmatched Stock rows. A full join includes all three groups. Even after the common projection, every row generated by a narrower join still occurs in the full join, with at least the same multiplicity.
Solution
The full outer join includes every matched pair plus all unmatched rows from each side padded by nulls. The inner and either one-sided outer join produce subsets of those rows after the same projection. Thus Query4, D; this remains a superset under SQL bag multiplicities.
Relations r(A,B),s(B,C) have no nulls; s.B is primary and r.B foreign key to s.B. Q=r⋈σ_(B<5)(s). Which differs? A σ_(B<5)(r⋈s); B σ_(B<5)(r LOJ s); C r LOJ σ_(B<5)(s); D σ_(B<5)(r) LOJ s.
Your answer
Answer & solution
Official answer: C
Method
An enforced non-null foreign key means each r tuple initially has exactly one matching s tuple. Consequently an unfiltered left outer join has no unmatched left tuples and behaves like an inner join. Applying the filter on r first also guarantees all its retained tuples match. Filtering only the right input before an outer join changes this: left tuples whose matches were filtered out still survive with null extension. This is why moving a predicate across an outer join requires more care than across an inner join.
Solution
Every r tuple has a matching s tuple by the non-null foreign key. Thus the unfiltered natural left join equals the inner join, and filtering B<5 before or after it gives the same matched rows. In C, filtering s first removes matches for r rows with B≥5, but the left join preserves those r rows with null-extended C. Q discards them instead. For example r={(a, 6)}, s={(6, c)} makes Q empty while option C retains(a, 6, NULL). Hence C alone is not equivalent.
Schemas: I R(rollno,courses), courses set-valued, rollno→courses; II R(rollno,courseid,email), rollno,courseid→email and email→rollno; III R(rollno,courseid,marks,grade), rollno,courseid→marks,grade and marks→grade; IV R(rollno,courseid,credit), rollno,courseid→credit and courseid→credit. Which is 3NF but not BCNF? A I; B II; C III; D IV.
Your answer
Answer & solution
Official answer: B
Step through it (4 parts)
Method
BCNF requires every nontrivial dependency’s determinant to be a superkey. 3NF allows a second possibility: its right-hand attribute is prime, meaning it belongs to some candidate key. For II, email together with courseid determines rollno and all attributes, while rollno together with courseid determines email. Neither email nor rollno alone determines courseid. Thus email→rollno violates BCNF but is permitted by 3NF because rollno is prime.
Solution
In schema II, candidate keys are {rollno, courseid} and {email, courseid}. All three attributes are prime, so each listed dependency satisfies 3NF. But email→rollno has a determinant that is not a superkey, violating BCNF. Schema I has a set-valued non-atomic attribute under the intended 1NF definition. Schema III has marks→grade with a non-superkey determinant and non-prime right side; schema IV has the analogous courseid→credit violation. Hence only schema II, B. The listed nontrivial dependencies are understood as a generating set, rather than literally excluding dependencies implied by them.
R(V,W,X,Y,Z) has dependencies V→W, VW→X, Y→VX, Y→Z. Choose an irreducible equivalent set. A {V→W,V→X,Y→V,Y→Z}; B {V→W,W→X,Y→V,Y→Z}; C {V→W,V→X,Y→V,Y→X,Y→Z}; D {V→W,W→X,Y→V,Y→X,Y→Z}.
Your answer
Answer & solution
Official answer: A
Step through it (7 steps)
1. First split Y→VX into Y→V and Y→X, so every right-hand side is a singleton.
2. From V→W, knowing V gives both V and W; VW→X then gives X. Therefore W is extraneous in the left side of VW→X, and we replace it by V→X.
3. Now Y→X is implied by Y→V and V→X and can be removed. None of V→W,V→X,Y→V,Y→Z follows from the other three. This is A; C is equivalent but not irreducible.
EMP(EmpId,EmpName,DeptName) has rows with IDs 1 through 13, names XYA through XYM, and departments AA,AA,AA,AA,AB,AB,AB,AC,AC,AC,AD,AD,AE respectively. The source SQL is: SELECT AVG(EC.Num) FROM EC WHERE (DeptName, Num) IN (SELECT DeptName, COUNT(EmpId) AS EC(DeptName, Num) FROM EMP GROUP BY DeptName) Find its output. This unusual source syntax is retained; the solution distinguishes the intended aggregate from the literal SQL.
Answer & solution
Official answer: 2.6
Our answer: 2.6 under intended grouped-table query
1. For the intended group operation, collect all rows with equal DeptName. The counts are AA:4, AB:3, AC:3, AD:2, AE:1.
2. AVG must average these five group counts, not average EmpId values or take an ungrouped COUNT. Their sum is 13, so the average is 13/5=2.6.
3. That derives the official intended numeric answer, but not an execution of the literal SQL. EC is not introduced as a proper relation/CTE, and AS EC(DeptName,Num) is not a valid ordinary COUNT alias. A corrected query must define EC before SELECT AVG(Num) FROM EC.
EMP(EmpId,EmpName,DeptId), DEPT(DeptName,DeptId); EMP.DeptId may be NULL. Which tuple-calculus queries are safe? I {t | ∃u∈EMP (t[EmpName]=u[EmpName] ∧ ∀v∈DEPT (t[DeptId]≠v[DeptId]))} II {t | ∃u∈EMP (t[EmpName]=u[EmpName] ∧ ∃v∈DEPT (t[DeptId]≠v[DeptId]))} III {t | ∃u∈EMP (t[EmpName]=u[EmpName] ∧ ∃v∈DEPT (t[DeptId]=v[DeptId]))} A I and II; B I and III; C II and III; D all three. No range restriction t∈EMP is printed.
Your answer
Answer & solution
Official answer: D
Our answer: Only III under unrestricted-domain TRC; official D under active-domain restriction
1. Safety requires finite results independent of arbitrary values outside the database. The free result tuple t is not explicitly restricted to EMP; only t.EmpName is equated to an employee name in I and II.
2. Use one employee Alice with DeptId 1 and one department with DeptId 1. For every value z outside the database, t=(Alice,z) satisfies I: z differs from every department ID. It also satisfies II because the existing department ID 1 differs from z. Infinitely many z are possible in an unrestricted domain.
3. III instead equates t.EmpName to an EMP name and t.DeptId to a DEPT ID, bounding both fields by finite stored values. Therefore only III is classically safe, but that option is missing. Official D requires an unstated finite active-domain interpretation. Allowing NULL in EMP neither binds t nor removes the counterexample.
1. Selection finds the rows for SA, then projection removes the student column. Thus T1 is the three-course set {CA,CB,CC}.
2. Relational division returns each student who is paired with every course in T1. Extra courses do not disqualify a student.
3. SA,SC,SD,SF contain all three. SB lacks CA; SE lacks CC. Thus T2 consists of four student names, so the answer is 4. The number of qualifying enrolment rows is not what division returns.
In an ER model, entity types A and B are related by R, which has no attributes of its own. When can the relational table for R be merged into A? A:R is one-to-many and A participates totally. B:one-to-many and A participates partially. C:many-to-one and A participates totally. D:many-to-one and A participates partially. Cardinalities are read from A to B.
Your answer
Answer & solution
Official answer: C
Our answer: C under nonnullable merge convention
1. Merging R into A means representing an A entity's partner by storing a B key in its row, instead of using a separate relationship row. A single such field can represent at most one B partner for each A. Thus the appropriate direction is many A entities to one B entity, not one A to many B entities.
2. Under the conventional null-free merge rule, every A must have a partner so that each A row has a valid B key. Total participation provides this guarantee. These two conditions yield the intended option C.
3. The wording leaves a modeling caveat: with nullable foreign keys, an A that does not participate can use NULL, so many-to-one with partial participation, D, can also be represented in A. Official C is retained under the nonnullable conventional criterion rather than treating D as impossible in SQL generally.
T1(P,Q) contains (2,2),(3,8),(7,3),(5,8),(6,9),(8,5),(9,8). T2(R,S) contains (2,2),(8,3),(3,2),(9,7),(5,7),(7,2). P and R are their primary keys. T1.Q references T2.R with ON DELETE CASCADE and ON UPDATE CASCADE. T2.S references T1.P with ON DELETE SET NULL and ON UPDATE CASCADE. Delete (3,8) from T1. How many additional T1 records must be deleted?
Answer & solution
Official answer: 0.0
Our answer: 0
1. Follow the incoming foreign-key references to the deleted key P=3. In T2, only row (R=8,S=3) references this value through S. Its specified action is ON DELETE SET NULL, so it becomes (8,NULL).
2. Crucially, this action neither deletes the T2 row nor changes its primary key R=8. The references from T1.Q to T2.R remain valid, including Q=8 values in other T1 rows.
3. T1's ON DELETE CASCADE would apply if a referenced T2 row were deleted; that has not happened. Nor has a referenced primary key been updated. Thus no cascade returns to T1 and the number of additional deletions is 0. A change to a foreign-key field is not automatically a change to the key referenced by the opposite table.
Transactions are T1:r1(X),w1(X),r1(Y),w1(Y) and T2:r2(Y),w2(Y),r2(Z),w2(Z). Here r and w denote read and write operations. How many order-preserving interleavings of the eight operations are conflict serializable?
Answer & solution
Official answer: 54.0
Our answer: 54
1. Each schedule is an interleaving of four operations from each transaction, so there are C(8,4)=70 candidates. Only Y is shared; read/write or write/write pairs on Y create precedence-graph edges. A schedule is serializable precisely when it does not create edges in both directions.
2. For order T1→T2, w1(Y) must precede r2(Y). Since these are respectively the last T1 and first T2 operations, this requires the single serial schedule 11112222, where digits identify transactions.
3. For order T2→T1, w2(Y) must precede r1(Y): the second 2 must occur before the third 1. Count its complement, third 1 before second 2. If the third 1 occurs at position 3, the prefix is 111 and the last 1 has 5 possible positions. If it occurs at position 4, the first three positions contain two 1s and one 2 in 3 arrangements, and the final 1 has 4 positions. The complement has 5+12=17 schedules, so this serial order has 70-17=53.
4. The two acyclic cases are disjoint, yielding 1+53=54. This counts conflict serializability, not only the two fully serial schedules. Independent enumeration of all 70 order-preserving interleavings confirms the count.
top_scorer(player,country,goals) rows: Klose,Germany,16; Ronaldo,Brazil,15; G Müller,Germany,14; Fontaine,France,13; Pelé,Brazil,12; Klinsmann,Germany,11; Kocsis,Hungary,11; Batistuta,Argentina,10; Cubillas,Peru,10; Lato,Poland,10; Lineker,England,10; T Müller,Germany,10; Rahn,Germany,10. Query: SELECT ta.player FROM top_scorer AS ta WHERE ta.goals > ALL (SELECT tb.goals FROM top_scorer AS tb WHERE tb.country='Spain') AND ta.goals > ANY (SELECT tc.goals FROM top_scorer AS tc WHERE tc.country='Germany'). How many tuples result?
Answer & solution
Official answer: 7.0
Our answer: 7
1. The Spain subquery returns no rows. A comparison quantified by ALL over an empty set is true, because there is no counterexample. Hence the first predicate eliminates none of the outer rows.
2. The Germany subquery returns goals 16,14,11,10,10. The >ANY condition requires exceeding at least one of them, so with these non-NULL values it is equivalent to goals>10, not goals>16.
3. Seven rows have goal counts above 10: 16,15,14,13,12,11,11. They yield Klose,Ronaldo,G Müller,Fontaine,Pelé,Klinsmann,Kocsis, so the result has 7 tuples. The query does not say DISTINCT, but these seven selected player values are distinct anyway. Empty ALL and empty ANY behave differently.
A relational schema has attributes V,W,X,Y,Z and primary key VY. Which choice is NOT a superkey? A: VXYZ. B: VWXZ. C: VWXY. D: VWXYZ. No other functional dependencies are specified; distinguish the intended answer from what the premise alone guarantees.
Your answer
Answer & solution
Official answer: B
Our answer: B is not guaranteed; literal insufficiency of dependencies
A, C, D contain the given primary key VY and are therefore superkeys. B=VWXZ omits Y, so it is the only set not guaranteed to be a superkey by that key alone, intended B. However a primary key does not exclude other candidate keys: adding X→Y would make B a superkey too while VY can remain minimal. No complete FD set is supplied, so the literal assertion that B is not a superkey needs the implicit assumption that no other dependency determines Y.
A superkey determines every attribute; any superset of a known key is therefore automatically a superkey. This immediately verifies A,C,D. Under only the supplied key dependency VY→VWX YZ, closure of VWXZ lacks Y, giving intended B. But “primary” means the chosen candidate key, not the only candidate key. If X→Y is additionally valid, VWXZ closes to all attributes. Keeping this caveat prevents a multiple-choice convention from being taught as a false database theorem.
Which is NOT an ACID transaction property? A: Atomicity. B: Consistency. C: Isolation. D: Deadlock-freedom.
Your answer
Answer & solution
Official answer: D
ACID expands to Atomicity, Consistency, Isolation and Durability. Deadlock freedom is a concurrency/liveness property, not an ACID component. Thus D.
Atomicity means all-or-nothing effects; consistency preserves the database's declared constraints; isolation controls interactions among concurrent transactions; durability preserves committed results. A locking implementation can satisfy these properties while occasionally encountering a deadlock, provided it detects and resolves that deadlock by aborting a transaction. Thus deadlock-freedom is a separate liveness guarantee rather than the missing fourth letter of ACID, which is durability.
An article relation has attributes Volume,Number,StartPage,EndPage,Title,Year,Price. Its primary key K is (Volume,Number,StartPage,EndPage), with FDs K→Title, (Volume,Number)→Year, K→Price. It is decomposed into (Volume,Number,StartPage,EndPage,Title,Price) and (Volume,Number,Year). What is the weakest normal form the new database satisfies but the old one does not? A:1NF. B:2NF. C:3NF. D:BCNF.
Your answer
Answer & solution
Official answer: B
Step through it (3 parts)
The old relation has a partial dependency (Volume, Number)→Year from a proper subset of the composite key to a nonprime attribute, violating 2NF. Splitting off(Volume, Number, Year) removes it; under the supplied FDs both resulting determinants are keys. The weakest newly satisfied form is 2NF, B, although the new schemas also satisfy higher forms under these dependencies.
Second normal form forbids a nonprime attribute from depending on only part of a candidate key. Year violates precisely this condition because Volume and Number are a proper subset of K. In the new Year relation, that pair is the whole key, so its dependency is no longer partial. In the other relation, Title and Price depend on its full key. The word weakest is decisive: even if BCNF also holds under the stated FDs,2NF is the first level crossed.
A transaction accessing objects O1,...,Ok first obtains exclusive locks on all of them in increasing memory-address order, then performs its operations, then releases all locks. The same protocol is followed by every transaction. What is guaranteed? A:serializability and deadlock-freedom. B:neither. C:serializability only. D:deadlock-freedom only.
Your answer
Answer & solution
Official answer: A
Acquiring all exclusive locks before releasing any is two-phase locking, ensuring conflict serializability. Every transaction acquires locks in the same increasing object-address order. A circular wait would force a strict sequence of increasing addresses to return to its starting address, impossible. The protocol is therefore also deadlock-free, A.
The growing phase contains every lock acquisition, and the shrinking phase contains only releases, so this is stronger than ordinary two-phase locking and ensures conflict serializability. The common global address order prevents cycles in the wait-for graph: following a chain of waits requires strictly increasing lock addresses. Serializability alone would not prevent deadlock in arbitrary two-phase locking, so both parts of the argument are needed. Locking exclusively for reads is conservative but does not invalidate either guarantee.
B+ trees are balanced because: A all root-to-leaf path lengths equal; B those lengths differ by at most 1; C child counts of nonleaf siblings differ by at most 1; D record counts of leaves differ by at most 1.
Your answer
Answer & solution
Official answer: A
Every B+ tree leaf is at the same level. Consequently every root-to-leaf path has the same length, A. Occupancy counts may differ much more than one while still meeting the minimum/maximum occupancy constraints.
Balanced here describes tree height, not identical node fill. A root-to-leaf search examines the same number of tree levels whichever key range it follows. Option B is a weaker consequence of equality, but A states the defining stronger invariant. The intended single-choice answer should not be read as making the weaker inequality mathematically false.
Build a schedule’s precedence graph with transactions as vertices and conflicts as directed edges. If the schedule is “serializable,” which vertex order guarantees a serial schedule? A topological; B depth-first; C breadth-first; D increasing transaction index. Explain the intended meaning of serializable.
Your answer
Answer & solution
Official answer: A
Our answer: A under conflict-serializability interpretation
An acyclic precedence graph admits a topological order, and placing transactions in that order respects every conflicting pair, yielding a conflict-equivalent serial schedule. Thus A. The word serializable must mean conflict-serializable here: view-serializable schedules can have cyclic conflict graphs (for example blind writes w1(X), w2(X), w1(X)), so a topological order need not exist under that broader meaning.
An edge Ti→Tj says a conflicting operation of Ti precedes one of Tj and that order must be preserved. A topological sort respects every such edge; ordinary traversal orders need not. For example an edge T2→T1 rules out increasing index order. Graph acyclicity is both necessary and sufficient for conflict serializability, not for every broader serializability notion.
Schedule S=r2(X);r1(X);r2(Y);w1(X);r1(Y);w2(X);a1;a2, where r,w,a mean read,write,abort. A nonrecoverable; B recoverable but cascading abort; C no cascading abort; D strict.
Your answer
Answer & solution
Official answer: C
Step through it (10 steps)
Every read occurs before the other transaction has written the read item, so neither transaction reads uncommitted data from the other. There is therefore no read-dependency requiring a cascading abort, C. The two explicit aborts do not themselves establish a cascade. The schedule is recoverable (neither commits prematurely), but not strict because w2(X) overwrites uncommitted w1(X).
Dirty reads, dirty writes and recoverability are different conditions. Here r2(X),r1(X) occur before w1(X), and neither transaction writes Y, so all reads see previously committed values. But w2(X) occurs before T1 aborts, a dirty write, ruling out strictness. Two transactions aborting in the same schedule need not have a causal read-dependency cascade.
water_schemes(scheme_no,district_name,capacity) rows: (1,Ajmer,20),(1,Bikaner,10),(2,Bikaner,10),(3,Bikaner,20),(1,Churu,10),(2,Churu,20),(1,Dungargarh,10). Printed pseudocode: with total(name,capacity) as select district_name,sum(capacity) from water_schemes group by district_name; with total_avg(capacity) as select avg(capacity) from total; select name from total,total_avg where total.capacity≥total_avg.capacity. How many output tuples under the intended CTE interpretation? The printed text repeats WITH and omits required CTE parentheses.
Answer & solution
Official answer: 2.0 : 2.0
Our answer: 2 under intended corrected CTE syntax
Per-district totals are Ajmer20, Bikaner40, Churu30, Dungargarh10; their mean is 25. Bikaner and Churu meet the >=25 condition, so the intended result has 2 tuples. Literal standard SQL requires parenthesized CTE bodies and a comma separating total and total_avg under one WITH clause. The printed repeated WITH and missing parentheses are not executable standard CTE syntax; the official 2 assumes those syntax repairs.
GROUP BY first produces one row per district, so AVG operates over four totals, not the seven original scheme rows. The single average row is crossed with those four totals; filtering retains 40 and 30. A repaired standard SQL form uses WITH total AS (...), total_avg AS (...) SELECT ..., making the intended semantics executable without claiming the printed syntax is valid.
The SELECT operation in SQL corresponds to which relational-algebra operation? A selection; B selection but retaining duplicates; C projection; D projection but retaining duplicates.
Your answer
Answer & solution
Official answer: D
Projection chooses output columns, whereas relational selection filters rows. A SQL SELECT list chooses the displayed columns, and ordinary SELECT uses bag semantics: two identical projected rows can both remain. Classical relational projection eliminates duplicates because a relation is a set. SELECT DISTINCT supplies the duplicate-eliminating counterpart. A full SQL query may additionally perform filtering, grouping and joins.
Solution: The SQL SELECT list performs projection, but without DISTINCT it retains duplicate result rows. Thus it corresponds to relational projection with duplicate retention, D; this describes the list operation, not every clause of a full query.
A file's data-record order is the same as, or close to, the order of entries in an index. What kind of index is it? A dense; B sparse; C clustered; D unclustered.
Your answer
Answer & solution
Official answer: C
Clustering concerns how the data records themselves are arranged relative to the search key, making nearby key values physically nearby. Dense versus sparse concerns how many index entries exist, not whether the underlying file follows the key order. Therefore density alone cannot answer the question. An unclustered index may point to records scattered throughout the file.
Solution: A clustered index determines the physical ordering/grouping of the underlying data records on its search key. Thus C.
Entities E1,E2,E3 have single-valued attributes (a11 key,a12),(a21 key,a22),(a31 key,a32). E1–E2 has m:n relationship R12; E1–E3 has 1:n R13, n on E3 side. Relationships have no attributes. Find minimum relations when all are in 3NF.
Answer & solution
Official answer: 4
Construct E1(a11,a12), E2(a21,a22), E3(a31,a32,a11), and R12(a11,a21). E3's added a11 foreign key records its single associated E1 without a separate R13 table. R12 needs a separate association relation because either entity may participate in multiple pairs. Given only the stated dependencies, these four relations meet 3NF; merging an entity's nonkey attributes into R12 would introduce redundant dependencies.
Solution: Use one relation for each of the three entity types. Implement the 1: n relationship by a foreign key on the n side, requiring no extra relation. The m: n relationship needs its own relation containing the participating keys. Thus four relations suffice under the displayed constraints.
Student(Roll_No,Student_Name) rows: (1,Raj),(2,Rohit),(3,Raj). Performance(Roll_No,Course,Marks): (1,Math,80),(1,English,70),(2,Math,75),(3,English,80),(2,Physics,65),(3,Math,80). SQL: SELECT S.Student_Name,sum(P.Marks) FROM Student S,Performance P WHERE S.Roll_No=P.Roll_No GROUP BY S.Student_Name. How many output rows?
Answer & solution
Official answer: 2
The equality join associates each course result with the appropriate student record, producing six joined rows. GROUP BY uses the name column, not the unique roll number, so the two Raj students become one aggregate group. The result contains (Raj,310) and (Rohit,140). Counting students gives three and counting course records gives six, but neither is the number of distinct grouping keys.
Solution: The join matches each performance row to its student by Roll_No, but grouping is by Student_Name alone. Roll numbers 1 and 3 both have name Raj and collapse into one group with total 80+70+80+80=310. Rohit forms the other group with 75+65=140. Hence2 result rows.
Transaction transfers 50 from x to y: read(x); x:=x−50; write(x); read(y); y:=y+50; write(y). Preserving x+y is which ACID property? A atomicity; B consistency; C isolation; D durability.
Your answer
Answer & solution
Official answer: B
Preserving the invariant x+y across the transaction is consistency, B. Atomicity is all-or-nothing execution, isolation concerns concurrent visibility, and durability concerns persistence after commit.
The declared invariant defines which database states are valid. Subtracting 50 from one account and adding 50 to the other preserves the invariant x+y, so this is consistency. Atomicity would ensure both changes occur or neither does. Isolation concerns interference between concurrent transactions, and durability concerns survival after commit. The invariant is not itself a claim about failure recovery or scheduling.
A B+ tree has root separator 9; left internal separator 5 and right internal separators 13, 17. Ordered linked leaves are[1, 3], [5, 7], [9, 11], [13, 15], [17]. Count minimum index nodes fetched, including root, for keys≥7 and<15.
Answer & solution
Official answer: 5
Search from root 9 to internal 5, then leaf[5, 7]. Follow leaf links to[9, 11] and[13, 15], stopping at 15. These are root, one internal node and three leaves: 5 index nodes. Fetches of actual record pages are outside the stated index-node count.
To find the first qualifying key 7, fetch root 9, then the internal node 5, then leaf[5, 7]. Continue using leaf sibling pointers rather than returning to the root: fetch[9, 11], then[13, 15]. The final leaf must be inspected to return 13 and discover the stopping boundary 15, which is excluded. Total distinct index nodes are 2 above-leaf nodes plus 3 leaves=5. The query asks index nodes, not how many record/data pages are subsequently read.
Simple checkpoint log: startT4; writeT4 y2→3; startT1; commitT4; writeT1 z5→7; checkpoint; startT2; writeT2 x1→9; commitT2; startT3; writeT3 z7→2; crash. Choose undo/redo lists: A undoT3, T1/redoT2; B same undo/redoT2, T4; C no undo/redo all four; D undoT3, T1, T4/redoT2.
Your answer
Answer & solution
Official answer: A
T4 committed before the completed checkpoint and needs no redo. T2 committed after it and must be redone. T1 and T3 are incomplete at crash and must be undone, including T1 begun before the checkpoint. Hence Undo{T3, T1}, Redo{T2}, A, under the stated simple checkpoint model.
Classify transactions by completion relative to the checkpoint and crash. T4 committed before the completed checkpoint, so the simple model treats its effects as safely checkpointed. T2 committed later and needs redo to ensure its updates appear. T1 and T3 have no commit record, so their changes must be undone, even though T1 started before the checkpoint. Starting before a checkpoint does not automatically make an unfinished transaction safe. More elaborate recovery protocols may scan different worklists, but this is the stated simple model.
R1(A, B)={(1, 5), (3, 7)}, R2(A, C)={(1, 7), (4, 9)}. Full natural outer join candidates a(1, 5, NULL), b(1, NULL, 7), c(3, NULL, 9), d(4, 7, NULL), e(1, 5, 7), f(3, 7, NULL), g(4, NULL, 9). A a, b, e, f, g not c, d; B all seven; C e, f, g not a, b; D e but not f, g.
Your answer
Answer & solution
Official answer: C
Matching A=1 yields(1, 5, 7). Unmatched left row gives(3, 7, NULL); unmatched right row gives(4, NULL, 9). Only e, f, g occur, C. Matched rows do not additionally produce null-padded variants.
Join on the common attribute A. The A=1 rows match and produce one combined row(1, 5, 7), without extra null-padded versions. The A=3 left row has no right match, so retain it as(3, 7, NULL). The A=4 right row has no left match, so retain it as(4, NULL, 9). Values from different unmatched keys cannot be combined into(3, NULL, 9)or(4, 7, NULL). Thus e, f, g are the complete result.
Relation X(P,Q,R,S,T,U) has functional dependencies F={ {P,R}→{S,T}, {P,S,U}→{Q,R} }. F⁺ is the closure of F. Which listed dependency is trivial? (A) {P,R}→{S,T}; (B) {P,R}→{R,T}; (C) {P,S}→{S}; (D) {P,S,U}→{Q}.
Your answer
Answer & solution
Official answer: C
1. The closure notation does not make a nontrivial dependency trivial. In A the right side introduces S,T; in B it introduces T; in D it introduces Q. Only C has no right-side attribute outside the left side.
2. A functional dependency X→Y is trivial precisely when Y⊆X. Here{P, S}→{S} meets this condition, C, independently of the other dependencies.
For Cinema(theater,address,capacity), append a condition to SELECT P1.address FROM Cinema P1 so that it returns addresses of theaters having maximum capacity. Options: (A) WHERE P1.capacity >= ALL (SELECT P2.capacity FROM Cinema P2); (B) WHERE P1.capacity >= ANY (SELECT P2.capacity FROM Cinema P2); (C) WHERE P1.capacity > ALL (SELECT MAX(P2.capacity) FROM Cinema P2); (D) WHERE P1.capacity > ANY (SELECT MAX(P2.capacity) FROM Cinema P2). Explain the ordinary nonnull-capacity assumption.
Your answer
Answer & solution
Official answer: A
Our answer: A for nonnull capacities
1. P1.capacity≥ALL capacities selects exactly maximal capacities, including ties, A.
2. ANY admits smaller nonmaximal values, and strictly greater than MAX admits none. This assumes capacities are nonnull: a NULL in the subquery can make ALL unknown even for a maximum; a NULL-safe implementation filters null capacities or compares to MAX.
A B+ tree has search keys of 12 bytes, blocks of 1024 bytes, record pointers of 10 bytes, and block pointers of 8 bytes. What is the maximum number of keys that fit in each non-leaf node? Use the usual internal-node layout with one more child pointer than keys and no additional stated overhead.
Answer & solution
Official answer: 50
1. For k=50 the node uses 50·12+51·8=1008 bytes, which fits. For k=51 it needs 51·12+52·8=1028 bytes, exceeding the block. These adjacent checks establish the maximum, not just a rounded estimate.
2. An internal node with k keys has k+1 child pointers, so 12k+8(k+1)≤1024. Thus20k≤1016 and k≤50. Record pointers belong in leaves and are not counted here.
A partial schedule lists these operations in time order: 1 T1:read(A); 2 T1:write(A); 3 T2:read(C); 4 T2:write(C); 5 T2:read(B); 6 T2:write(B); 7 T2:read(A); 8 T2:commit; 9 T1:read(B). T1 fails immediately after time 9. Which statement is correct? (A) Abort T2, then restart both T1 and T2 to ensure atomicity. (B) The schedule is non-recoverable and cannot ensure transaction atomicity. (C) Abort and restart only T2 to ensure atomicity. (D) The schedule is recoverable and ensures atomicity without doing anything else.
Your answer
Answer & solution
Official answer: B
Step through it (12 steps)
1. T2 reads A at time 7 after T1 writes it at time 2, before T1 commits.
2. T2 then commits at 8. When T1 fails after 9, its uncommitted value has already influenced a committed transaction. This violates recoverability: a reader must not commit before the transaction whose value it read. T2 cannot simply be treated as an uncommitted transaction to roll back. Thus B.
For R(E,F,G,H,I,J,K,L,M,N), the functional dependencies are EF→G, F→IJ, EH→KL, K→M, L→N. Which is a candidate key? A: EF. B: EFH. C: EFHKL. D: E.
Your answer
Answer & solution
Official answer: B
Step through it (2 steps)
1. Method and setup. Attributes absent from every dependency’s right side cannot be generated from other attributes. Thus E, F and H must occur in every key. Compute their closure systematically, and distinguish a minimal candidate key from a larger superkey such as EFHKL.
2. Work through the result and its assumptions. E, F, H never occur on a right-hand side, so every key needs all three. Their closure addsG via EF, I, J via F, K, L via EH, then M, N. Thus EFH determines all attributes and is minimal, B.
S1: A foreign-key declaration can always be replaced by an equivalent SQL check assertion. S2: If R(a,b,c) has composite primary key (a,b), then CREATE TABLE S(a INTEGER,d INTEGER,e INTEGER,PRIMARY KEY(d),FOREIGN KEY(a) REFERENCES R) is valid. Choose A: S1 true, S2 false. B: both true. C: S1 false, S2 true. D: both false.
Your answer
Answer & solution
Official answer: D
Our answer: D with full referential-action semantics; A for constraints alone
1. Method and setup. Check S2 structurally: omitting referenced column names means referencing R’s primary key, which has two columns, unlike the one-column foreign key. For S1, distinguish an assertion describing permitted database states from actions performed during an update or deletion. “Always equivalent” is ambiguous unless that distinction is specified.
2. Work through the result and its assumptions. S2 is false: the implicit referenced key is composite(a, b), but the foreign key has only one column. For S1, an SQL ASSERTION can express the allowed-state condition for an ordinary foreign key, including NULL exemptions, so under constraint-only equivalence S1 is true and A follows. An assertion alone cannot implement ON DELETE/UPDATE CASCADE or SET NULL actions; interpreting always as full behavioral equivalence makes S1 false and supports official D. This distinction is unstated; retain the official key and disclose both readings.
On one item x, which schedule is conflict serializable? Subscripts identify transactions. A: r₁(x);r₂(x);w₁(x);r₃(x);w₂(x). B: r₂(x);r₁(x);w₂(x);r₃(x);w₁(x). C: r₃(x);r₂(x);r₁(x);w₂(x);w₁(x). D: r₂(x);w₂(x);r₃(x);r₁(x);w₁(x).
Your answer
Answer & solution
Official answer: D
Step through it (4 schedules)
1. Method and setup. Build a precedence graph with one vertex per transaction. Add an edge for time-ordered accesses by different transactions to x when at least one is a write; two reads alone create no conflict. The schedule is conflict serializable exactly when this graph is acyclic.
2. Work through the result and its assumptions. A and B each contain conflicting edges 1→2 and 2→1. C likewise has 1→2 from r1 before w2 and 2→1 from r2 before w1. D has edges 2→3, 2→1, 3→1 and no cycle, with serial order T2, T3, T1. Thus D.
S1: Every table with two single-valued attributes is in 1NF, 2NF, 3NF and BCNF. S2: {AB→C,D→E,E→C} is a minimal cover of {AB→C,D→E,AB→E,E→C}. Which holds? A: S1 true, S2 false. B: both true. C: S1 false, S2 true. D: both false.
Your answer
Answer & solution
Official answer: A
Our answer: A under the nonempty-determinant convention
1. Method and setup. For S2, equivalent covers must imply the same dependencies, not merely contain fewer entries. Compute (AB)⁺ under the proposed cover: it contains A,B,C but not E, showing a lost dependency. For S1, single-valuedness addresses 1NF; the stronger forms also depend on the possible functional dependencies and their determinants.
2. Work through the result and its assumptions. For a two-attribute relation, any nontrivial FD with nonempty determinant has a singleton determinant that determines both attributes, so it is a key; hence BCNF and the weaker forms hold. S2 is false because AB→E cannot be derived from the proposed cover. Thus A under the textbook convention. If empty determinants are allowed, ∅→B with varying A violates BCNF and 3NF, so the unconditional S1 needs qualification.
Schemas: employees(emp-id,first-name,last-name,hire-date,dept-id,salary) and departments(dept-id,dept-name,manager-id,location-id). To list last names and hire dates of all latest hires in each department at location 1700, the printed query is SELECT last-name,hire-date FROM employees WHERE (dept-id,hire-date) IN (SELECT dept-id,MAX(hire-date) FROM employees JOIN departments USING(dept-id) WHERE location-id=1700 GROUP BY dept-id). Outcome? A: Executes but incorrect. B: Executes and correct. C: Error because of pairwise comparison. D: Error because GROUP BY cannot accompany joins in a subquery. Hyphens are printed unquoted.
Your answer
Answer & solution
Official answer: B
Our answer: B after identifier syntax repair
1. Method and setup. Read the subquery from its FROM clause onward: join employees to departments, restrict the departments by location, and group to obtain each department’s latest date. The outer predicate must match both department and date, preventing a latest date from one department accidentally selecting a person in another. Separately audit the literal identifier syntax.
2. Work through the result and its assumptions. Treating the hyphenated labels as properly quoted identifiers (or replacing hyphens with underscores), the inner query groups employees by department at location 1700 and returns each latest hire date. The outer row-value IN comparison selects all employees tied at those dates in their departments. Thus the intended result is correct, B; GROUP BY with a join and pairwise IN are valid. Literally, unquoted dept-id, last-name and other hyphenated names are not ordinary SQL identifiers: subtraction is parsed or syntax fails, especially USING(dept-id). The printed query needs identifier quoting/renaming.
For relation schema R(E,F,G,H), with E as the key, find the maximum number of superkeys.
Answer & solution
Official answer: 8
Our answer: 8 if E is the sole candidate key
1. Set up the reasoning. A superkey uniquely identifies tuples and may contain redundant attributes. Starting from E, independently include or omit each of the three remaining attributes F, G, and H.
2. Derive the result. Every superset of E is a superkey; choosing any subset of F, G, H gives 2³=8. Reading E as the only candidate key gives exactly this count. If it merely says E is one candidate key, additional keys could increase the count, up to all 15 nonempty attribute subsets when every singleton is a key. Thus the official 8 relies on the sole-key reading of the key.
3. Check the interpretation. The intended count treats E as the sole candidate key: E, EF, EG, EH, EFG, EFH, EGH, EFGH. If the phrase only grants that E is one key, other candidate keys are not ruled out; preserve that ambiguity rather than claiming eight follows unconditionally.
STUDENTS has columns StudentID, StudentName, StudentEmail, StudentAge, CPI and rows (2345,Shankar,shankar@math,X,9.4), (1287,Swati,swati@ee,19,9.5), (7853,Shankar,shankar@cse,19,9.4), (9876,Swati,swati@mech,18,9.3), (8765,Ganesh,ganesh@civil,19,8.7). For (StudentName,StudentAge) to be a key of this instance, what value must X NOT equal?
Answer & solution
Official answer: 19
1. Set up the reasoning. Project each row to the proposed key columns. Distinct names cannot collide, so only rows sharing a name need to be compared.
2. Derive the result. The two Shankar rows would have the same(Name, Age) pair if X=19. Other repeated names already have different ages, and neither name nor age alone is unique. Hence X must not equal 19 for the pair to be a key of this instance.
3. Check the interpretation. The two Swati ages already differ. The Shankar ages would coincide at X=19, creating two different rows with the same key pair. Other columns such as unique emails do not repair a collision in the specified pair.
Schedule S, in chronological order: T2 reads X; T3 writes X and commits; T1 writes X and commits; T2 writes Y, reads Z, and commits; T4 reads X, reads Y, and commits. Classify S. A conflict-serializable, not recoverable; B not conflict-serializable, recoverable; C both; D neither.
Your answer
Answer & solution
Official answer: C
Step through it (13 steps)
1. Set up the reasoning. Construct a precedence graph for conflicting operations on the same item, and separately inspect the commit order of transactions whose values are read. Serializability and recoverability are different tests.
2. Derive the result. Conflicts on X impose T2→T3→T1→T4, and Y adds T2→T4; the graph is acyclic. T2 reads initial X/Z; T4 reads X from already committed T1 and Y from already committed T2. Thus the schedule is both conflict-serializable and recoverable, C.
3. Check the interpretation. The graph order T2,T3,T1,T4 respects every conflict, including direct T2→T1 and T2→T4 edges. T4 reads only committed results, while T2 reads initial values, so there is no commit-before-writer recovery violation.
A nested-loop relational join combines r(R) and s(S), with size(r)<size(s). There are three disk-block-sized buffers, one reserved for intermediate output. Which yields fewer disk-block accesses? A r in the outer loop; B s in the outer loop; C join selectivity above 0.5; D join selectivity below 0.5.
Your answer
Answer & solution
Official answer: A
1. Set up the reasoning. With two input buffers, scan the inner relation once for each outer block. For block counts br and bs, compare br+br·bs with bs+bs·br, ignoring common output writes.
2. Derive the result. With one input-block buffer for each relation and one output buffer, block nested loops cost b_outer+b_outer·b_inner reads, excluding common output cost. The product is unchanged by swapping, but the initial outer scan is smaller when r is outer. Thus A, interpreting size as disk-block count.
3. Check the interpretation. The product cost is symmetric, but the one-time outer scan is not. The smaller block-count relation is therefore the better outer input. Selectivity can change result size but does not remove the specified nested-loop input scans.
SQL relations may contain duplicate tuples. Which query always matches SELECT * FROM R WHERE a IN (SELECT S.a FROM S)? A SELECT R.* FROM R,S WHERE R.a=S.a; B SELECT DISTINCT R.* FROM R,S WHERE R.a=S.a; C SELECT R.* FROM R,(SELECT DISTINCT a FROM S) AS S1 WHERE R.a=S1.a; D SELECT R.* FROM R,S WHERE R.a=S.a AND is unique R.
Your answer
Answer & solution
Official answer: C
1. Set up the reasoning. IN is an existence test: a matching R occurrence survives once irrespective of how many matching S rows exist. Reproduce that effect by deduplicating only S's join-key values before joining.
2. Derive the result. IN tests membership, preserving each original occurrence of an R row once when at least one matching nonnull S.a exists. Joining to SELECT DISTINCT a FROM S creates exactly one matching S1 row per such value, preserving R’s multiplicities: C. A multiplies rows when S repeats a; B removes duplicate R rows. SQL null comparisons remain nontrue in both the IN filter and equality join, so nulls do not invalidate C.
3. Check the interpretation. A can multiply an R occurrence by duplicate S keys; B can erase distinct occurrences of the same R tuple. C keeps R's bag multiplicity while giving one matching right-side row. NULL does not satisfy either filter's equality test, so it does not break the equivalence.
Simplify π_A1(π_A2(σ_F1(σ_F2(r)))), where A1⊂A2 are attribute sets of r and F1,F2 are predicates on r. A π_A1(σ_(F1∧F2)(r)); B π_A1(σ_(F1∨F2)(r)); C π_A2(σ_(F1∧F2)(r)); D π_A2(σ_(F1∨F2)(r)).
Your answer
Answer & solution
Official answer: A
Step 1: A row survives the two selections only if it satisfies both predicates, so σ_F1(σ_F2(r))=σ_(F1∧F2)(r). An OR would admit rows discarded by one selection. Step 2: Projecting onto A2 and then its subset A1 is equivalent to projecting directly onto A1, because the intermediate projection retains every finally requested attribute. Step 3: Combining these rules gives π_A1(σ_(F1∧F2)(r)), A. Keep the final output attributes A1; replacing them with A2 changes the query.
A prime attribute of a relation R belongs to which set? A every candidate key; B some candidate key; C a foreign key; D only the primary key.
Your answer
Answer & solution
Official answer: B
Step 1: A candidate key is a minimal attribute set that uniquely identifies a tuple. A relation may have several such sets. Step 2: An attribute is prime if it appears in at least one candidate key, including a candidate key not chosen as primary. Therefore B is the definition. Step 3: Requiring membership in every key is too strong. Foreign-key membership is unrelated, and selection of a primary key does not change which attributes are prime.
Transactions are T1:r1(X),r1(Z),w1(X),w1(Z); T2:r2(Y),r2(Z),w2(Z); T3:r3(Y),r3(X),w3(Y). S1=r1(X),r3(Y),r3(X),r2(Y),r2(Z),w3(Y),w2(Z),r1(Z),w1(X),w1(Z). S2=r1(X),r3(Y),r2(Y),r3(X),r1(Z),r2(Z),w3(Y),w1(X),w2(Z),w1(Z). Which schedules are conflict-serializable? A only S1; B only S2; C both; D neither.
Your answer
Answer & solution
Official answer: A
Step through it (2 schedules)
Step 1: Construct a precedence graph: add Ti→Tj when conflicting operations from different transactions access the same item, at least one is a write, and Ti's operation occurs first. Read/read pairs create no edge. Step 2: In S1, Y gives T2→T3, X gives T3→T1, and Z gives T2→T1. The graph is acyclic, with serial order T2,T3,T1. Step 3: In S2, r1(Z) precedes w2(Z), giving T1→T2; r2(Z) and w2(Z) precede w1(Z), giving T2→T1. This two-way cycle suffices to reject conflict serializability. Thus only S1 is conflict-serializable, A.
Schemas: employee(empId,empName,empAge) and dependent(depId,eId,depName,depAge), with eId referencing employee.empId. Every employee has at least one dependent. Interpret π_empId(employee)−π_empId(employee ⋈_(empId=eId ∧ empAge≤depAge) dependent). It returns employees older than A some dependent; B all dependents; C some of their own dependents; D all of their own dependents.
Your answer
Answer & solution
Official answer: D
Step 1: The join condition first pairs each employee only with that employee's own dependents. Its age condition selects counterexamples to “employee is older”: a dependent whose age is at least the employee's age. Step 2: Projecting empId collects employees with at least one such counterexample. Subtracting this set from all empIds keeps employees with none. Step 3: No own dependent is as old or older means the employee is strictly older than every own dependent, D. The nonempty-dependent premise prevents vacuous cases; ordinary relational algebra here assumes comparable, non-NULL ages.
Schemas are employee(empId,empName,empDept) and customer(custId,custName,salesRepId,rating), with salesRepId referencing empId. Every employee sells to at least one customer. Query: SELECT empName FROM employee E WHERE NOT EXISTS (SELECT custId FROM customer C WHERE C.salesRepId=E.empId AND C.rating <> 'GOOD'). It returns names of employees with A at least one GOOD customer; B at most one GOOD customer; C no GOOD customers; D all customers GOOD.
Your answer
Answer & solution
Official answer: D
Our answer: D assuming nonnull ratings
Step 1: For a fixed employee, the correlated subquery considers only that employee's customers, and finds rows whose rating is unequal to GOOD. NOT EXISTS keeps the employee exactly when this set is empty. Step 2: If ratings are non-NULL, having no customer rated other than GOOD means every customer is GOOD. The premise guarantees at least one customer, so the intended option is D. Step 3: The source does not declare rating NOT NULL. In SQL, NULL <> 'GOOD' is UNKNOWN, not TRUE, so a NULL-rated customer does not enter the subquery. An employee with only NULL-rated customers is still returned even though all-GOOD is not established. The precise query means “no own customer has a known non-GOOD rating”; retain the official D qualification and existing NULL discrepancy.
An index is clustered if A its fields form a candidate key; B its fields include the primary key; C data records follow the same order as index data entries; D data records do not follow that order.
Your answer
Answer & solution
Official answer: C
A clustered index has its data records physically organized in the same order as the index’s data entries. This is about file ordering, not merely whether the indexed fields form a candidate or primary key. Hence C.
Clustering describes physical locality/order of the records relative to the index ordering. Scanning adjacent index entries can therefore correspond to nearby ordered records. Key uniqueness is a different property: an index can be clustered on a nonunique field, and a primary-key index need not determine the physical record order in every storage design. Thus C states the defining relationship, while A/B confuse clustering with key constraints and D describes the opposite relationship.
Schemas: Students(rollno, sname), Courses(courseno, cname), Registration(rollno, courseno, percent). Desired result is distinct student names scoring>90 in course 107. I SQL SELECT DISTINCT S.sname FROM Students S, Registration R WHERE R.rollno=S.rollno AND R.courseno=107 AND R.percent>90. II relational projection sname after selecting courseno107 and percent>90 from Registration natural-join Students. III tuple calculus {T:∃S∈Students,∃R∈Registration(S.rollno=R.rollno∧R.courseno=107∧R.percent>90∧T.sname=S.sname)}. IV domain calculus {<SN>:∃SR∃RP(<SR, SN>∈Students∧<SR, 107, RP>∈Registration∧RP>90)}. Which equivalent queries? A all four; B I, II, III; C I, II, IV; D II, III, IV.
Your answer
Answer & solution
Official answer: A
Each expression joins a student to a registration on roll number, requires course 107 and percent>90, and returns the student name. SQL DISTINCT and set-valued relational algebra/calculi remove duplicate names. Hence all four are equivalent, A, with the tuple-calculus output T understood to have the displayed single sname attribute.
All four forms bind the same join witness: a student row and a registration row with equal rollno, course 107 and percent greater than 90. SQL DISTINCT removes duplicate names; relational projection and calculus use set semantics. The Courses table is not needed because filtering uses its numeric course identifier, not its name. In IV, SR is the shared roll number, SN is the returned name, and RP is the qualifying percentage. In III, the result tuple is understood to have just the sname attribute, matching the projected result schema.
R(A, B, C, D, E, F, G, H) has atomic fields and exactly FD closure generated by CH→G, A→BC, B→CFH, E→A, F→EG. Number of candidate keys: A3, B4, C5, D6.
Your answer
Answer & solution
Official answer: B
Step through it (8 steps)
D never occurs on any right-hand side, so every key must contain D. The dependencies A→B, B→F, F→E and E→A form a reachability cycle among A, B, E, F. Starting from any one of those four attributes derives the other three, C and H through B→CFH, and G through F→EG. Consequently A+, B+, E+, F+ each equal {A, B, C, E, F, G, H}, missing only D. Thus AD, BD, DE and DF are candidate keys, and each is minimal. For completeness, any set containing none of A, B, E, F can include only C, D, G, H; its closure can at most add G via CH→G and can never reach that four-attribute cycle. Therefore every key includes at least one of A, B, E, F, and a minimal key includes exactly one together with D. There are precisely four candidate keys, option B.
Compute closures to establish keys and then prove the list exhaustive. D cannot be derived because it never appears on an FD right side, so it must be supplied. Any one of A, B, E, F reaches all the other members of that cycle and then C, H, G. Supplying D alongside one therefore determines all eight attributes. With none of A, B, E, F, the remaining C, D, G, Hcannot generate an entry point into the cycle. Consequently a minimal key consists of Dplus exactly one cycle member: four possibilities.
For the same relation and FDs CH→G, A→BC, B→CFH, E→A, F→EG, classify normal form: A1NFnot2NF; B2NFnot3NF; C3NFnotBCNF; DBCNF.
Your answer
Answer & solution
Official answer: A
Step through it (10 steps)
Atomic fields give 1NF. The candidate keys are AD, BD, DE, DF, so the prime attributes are A, B, D, E, F and the non-prime attributes are C, G, H. From the given dependency A→BC we obtain A→C. Here A is a proper subset of the candidate key AD and C is non-prime, so C has a partial dependency on a candidate key. This violates 2NF. Therefore the relation is in 1NF but not 2NF, option A; no higher-normal-form analysis is needed.
Second normal form forbids a nonprime attribute from depending on a proper subset of any candidate key. AD is a candidate key and C is nonprime, but Aalone determines C through A→BC. This single partial dependency suffices to disprove 2NF. Atomic fields already establish 1NF, so the exact classification is 1NFbut not 2NF. There is no need to test every FD against 3NF/BCNF after a lower prerequisite has failed.
Which of the following is TRUE? (A) Every relation in 3NF is also in BCNF (B) A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on every key of R (C) Every relation in BCNF is also in 3NF (D) No relation can be in both BCNF and 3NF
Your answer
Answer & solution
Official answer: C
BCNF requires every determinant of a nontrivial functional dependency to be a superkey. This satisfies the 3NF alternative that the determinant is a superkey or the dependent attribute is prime. Therefore BCNF implies 3NF, C. The converse need not hold. Full dependence of non-prime attributes on keys describes the 2NF condition and does not by itself exclude transitive dependencies.
Check: For a concrete 3NF-not-BCNF schema, take R(A,B,C) with AB→C and C→B. Candidate keys are AB and AC. C→B violates BCNF because C is not a superkey, but satisfies 3NF because B is prime.
Given the basic ER and relational models, which of the following is INCORRECT? (A) An attribute of an entity can have more than one value (B) An attribute of an entity can be composite (C) In a row of a relational table, an attribute can have more than one value (D) In a row of a relational table, an attribute can have exactly one value or a NULL value
Your answer
Answer & solution
Official answer: C
The basic ER model can represent composite and multivalued attributes. In the ordinary first-normal-form relational representation, however, each cell contains a single atomic value (or the SQL-style NULL marker admitted by the options), not several values for that attribute. Therefore C is the incorrect statement. Multivalued ER attributes need a separate relational representation.
Check: An ER address can have components such as city and postcode, and an ER person can have several phone numbers. Mapping to relations separates components into columns and multiple phone values into rows of a related table rather than storing a set in one atomic cell.
HAVING without GROUP BY and unselected grouping attributes
SQL & Queries
Tap to enlarge
Which of the following statements are TRUE about an SQL query?
P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause Q : An SQL query can contain a HAVING clause only if it has a GROUP BY clause R : All attributes used in the GROUP BY clause must appear in the SELECT clause S : Not all attributes used in the GROUP BY clause need to appear in the SELECT clause (A) P and R (B) P and S (C) Q and R (D) Q and S
Your answer
Answer & solution
Official answer: C
Our answer: B
P is true: SELECT COUNT(*) FROM T HAVING COUNT(*)>0 is a valid aggregate query without GROUP BY, treating the input as one group. S is true: SELECT COUNT(*) FROM T GROUP BY a groups by a without selecting a. Therefore Q and R are false, and the correct pair is P and S, option B. The appended official Code A key instead prints C (Q and R). Preserve official C for scoring provenance and derived B as a documented source/key discrepancy; do not silently change either.
Check: On a table with values a=1,1,2, grouping by a while selecting only COUNT(*) returns counts 2 and 1 without exposing a. On the same nonempty table, HAVING COUNT(*)>0 without GROUP BY retains its one aggregate group. These concrete cases refute both universal claims Q and R.
Consider the following transactions with data items P and Q initialized to zero: T1 :read (P); read (Q); if P = 0 then Q := Q + 1 ; write (Q). T2 : read (Q); read (P); if Q = 0 then P := P + 1 ; write (P). Any non-serial interleaving of T1 and T2 for concurrent execution leads to (A) a serializable schedule (B) a schedule that is not conflict serializable (C) a conflict serializable schedule (D) a schedule for which a precedence graph cannot be drawn
Your answer
Answer & solution
Official answer: B
Conflicts arise on P between T1’s read and T2’s write, and on Q between T2’s read and T1’s write. If w1(Q) precedes r2(Q), then all of T1’s listed operations precede T2’s first operation, giving serial order T1, T2. Similarly, w2(P) before r1(P) forces serial order T2, T1. Therefore every genuinely nonserial interleaving has r1(P)<w2(P) and r2(Q)<w1(Q), giving both T1→T2 and T2→T1 in the precedence graph. The cycle proves it is not conflict serializable, B. The question’s qualification nonserial is necessary.
Check: The initial values affect the arithmetic outcomes but not the conflict edges, which depend on read/write order. Each transaction’s first read is before its last write; interleaving forces both cross-read-before-write relations, producing a directed two-cycle.
Let r1 and r2 be instances of R1(A,B) and R2(C,D). B is a foreign key referencing C, and referential integrity holds. Which is always true? π denotes projection. (A) π_B(r1)−π_C(r2)=∅ (B) π_C(r2)−π_B(r1)=∅ (C) π_B(r1)=π_C(r2) (D) π_B(r1)−π_C(r2)≠∅.
Your answer
Answer & solution
Official answer: A
In the classical relational model used by the relational-algebra expression, every B value in r1 must occur as a C value in r2. Thus π_B(r1) is a subset of π_C(r2), and π_B(r1)−π_C(r2)=∅, A. Referenced C values need not all occur in B, so equality and reverse containment are not guaranteed. This is the textbook non-null relational interpretation; SQL nullable foreign keys require separate treatment of NULL.
Check: For a concrete permitted instance, r1 may reference only C=1 while r2 contains C=1 and C=2. Then the forward difference is empty but the reverse difference contains 2. Referenced rows may exist even when no row currently references them.
Relations: A(Id,Name,Age)={(12,Arun,60),(15,Shreya,24),(99,Rohit,11)}; B(Id,Name,Age)={(15,Shreya,24),(25,Hari,40),(98,Rohit,20),(99,Rohit,11)}; C(Id,Phone,Area)={(10,2200,02),(99,2100,01)}. How many tuples result from (A∪B) ⋈_{A.Id>40 OR C.Id<15} C? The union has the schema of A. (A) 7 (B) 4 (C) 5 (D) 9.
Your answer
Answer & solution
Official answer: A
Relational union eliminates the two shared tuples (15, Shreya, 24) and (99, Rohit, 11), leaving five distinct tuples with Id values 12, 15, 25, 98, 99. For C.Id=10, the condition C.Id<15 is true, so all five join. For C.Id=99, only the two union tuples with Id>40 join. There are 5+2=7 result tuples, A. This is a theta join, so each qualifying pair contributes its combined tuple.
Check: The pair count can also be checked from the union side: Ids 12,15,25 each match only C.Id=10, contributing three; Ids 98,99 each match both C rows, contributing four. The total 3+4=7 agrees with counting from the C side.
Relations: A(Id,Name,Age)={(12,Arun,60),(15,Shreya,24),(99,Rohit,11)}; B(Id,Name,Age)={(15,Shreya,24),(25,Hari,40),(98,Rohit,20),(99,Rohit,11)}; C(Id,Phone,Area)={(10,2200,02),(99,2100,01)}. How many tuples result from this SQL query? SELECT A.Id FROM A WHERE A.Age > ALL (SELECT B.Age FROM B WHERE B.Name='Arun'); (A) 4 (B) 3 (C) 0 (D) 1.
Your answer
Answer & solution
Official answer: B
There is no B row with Name=Arun, so the inner query returns an empty relation. A comparison quantified by ALL over an empty set is true: there is no counterexample. Consequently all three rows of A satisfy the WHERE condition, returning Id values 12, 15, 99. The count is 3, B.
Check: ALL means every returned value satisfies the comparison, not that at least one value exists. NOT EXISTS a violating subquery row is true when there are no subquery rows at all. ANY would have the opposite empty-set truth value, false.
A student table has one row per registered student: Registration_Num is unique per student; UID is nationally unique per citizen; BankAccount_Num stores a primary account, and students may have multiple or joint accounts; Name is the student's name; Hostel_Room is the room number. Which statement is INCORRECT?
(A) BankAccount_Num is a candidate key (B) Registration_Num can be a primary key (C) UID is a candidate key if all students are from the same country (D) If S is a superkey and S intersect UID is NULL, S union UID is also a superkey
Your answer
Answer & solution
Official answer: A
Joint accounts allow two students to have the same primary BankAccount_Num, so it need not uniquely identify a student and is not guaranteed to be a candidate key. Registration numbers are unique; a national UID is unique under the stated same-country assumption; adding an attribute to a superkey preserves uniqueness. Therefore A is incorrect. NULL in the set expression is understood as empty intersection, not SQL NULL.
A candidate key must uniquely identify rows and be minimal for that purpose. A unique account number uniquely identifies a bank account, but the table stores students: joint holders can legitimately repeat the account number across student rows. Conversely, unique registration numbers identify students directly. In D, the extra UID attribute cannot create a collision between rows already distinguished by S; minimality may be lost, but superkey status is preserved.
Table T has integer columns X,Y and starts with (1,1). Let MX and MY be their current respective maxima. Perform 128 additional inserts of (MX+1,2*MY+1), recomputing maxima after each insert. What does SELECT Y FROM T WHERE X=7 return?
(A) 127 (B) 255 (C) 129 (D) 257
Your answer
Answer & solution
Official answer: A
Our answer: A under successful mathematical-integer insertions
The rows obey X=k and Y=2k−1 by induction from(1, 1): the next maximum Y is doubled and increased by 1. Hence the row X=7 has Y=127, A. Completing all 128 additional inserts would require representing 2129−1 in the final row, beyond common fixed-width SQL INTEGER types. The problem’s statement that all inserts occur therefore assumes sufficiently large integers or an abstract unbounded-integer model; the requested early row itself is representable.
The early rows make the indexing clear: (1,1),(2,3),(3,7),(4,15),(5,31),(6,63),(7,127). Since X increases strictly, there is exactly one row with X=7. For a formal recurrence, set Z=Y+1; then Z doubles at each step, with Z=2 initially, so at X=k it equals 2k. The query is not asking for the final maximum after all 128 inserts; that confusion produces inappropriate much larger powers.
A sufficiently large relation r has attributes A1,...,An, with 1≤p≤n. Q1 projects A1,...,Ap after selection Ap=c. Q2 projects the same attributes after selection c1≤Ap≤c2. The database may use ordered indexing or hashing on Ap. Which statement is intended to be TRUE?
(A) Ordered indexing always outperforms hashing for both (B) Hashing always outperforms ordered indexing for both (C) Hashing outperforms ordered indexing on Q1, but not Q2 (D) Hashing outperforms ordered indexing on Q2, but not Q1
Your answer
Answer & solution
Official answer: C
Our answer: C under the standard index cost model
Q1 is equality on the indexed attribute, where a well-distributed hash index normally locates its bucket in expected constant time and outperforms ordered search. Q2 is a range predicate, for which an ordered index finds the first qualifying entry and scans the interval; hashing lacks that order. Thus C is the conventional comparison. Actual performance also depends on collisions, selectivity, caching and index layout, so this is not a universal measured-time guarantee for every database.
Hashing sends equal keys to a bucket but does not put nearby numerical values in nearby buckets. Thus an equality predicate can use one hash lookup plus collision handling, whereas a range may require examining many buckets. A sorted index can locate the lower bound and walk adjacent entries until the upper bound. Projection of columns A1,...,Ap does not change this key distinction between the selection predicates. The source's absolute performance wording is stronger than what can be guaranteed without a storage cost model.
Loan_Records has columns Borrower,Bank_Manager,Loan_Amount and rows (Ramesh,Sunderajan,10000.00), (Suresh,Ramgopal,5000.00), (Mahesh,Sunderajan,7000.00). Evaluate SELECT count(*) FROM ((SELECT Borrower,Bank_Manager FROM Loan_Records) AS S NATURAL JOIN (SELECT Bank_Manager,Loan_Amount FROM Loan_Records) AS T).
(A) 3 (B) 9 (C) 5 (D) 6
Your answer
Answer & solution
Official answer: C
The common column of the two projections is Bank_Manager. Sunderajan appears in two rows of each projection, so the natural join yields 2×2=4 combinations for that manager. Ramgopal appears once in each projection, yielding 1×1=1 combination. COUNT(*) returns 4+1=5, option C. The join does not pair rows by their original borrower, since Borrower is absent from the second projection.
The projected left rows are (Ramesh,Sunderajan),(Suresh,Ramgopal),(Mahesh,Sunderajan). The right rows are (Sunderajan,10000),(Ramgopal,5000),(Sunderajan,7000). Each of Ramesh and Mahesh joins with both Sunderajan amounts, yielding four rows; Suresh joins with the single Ramgopal amount. COUNT(*) counts those joined rows, including combinations that were not in the original table. Joining projections can create extra combinations whenever their common attribute is not a key.
In a B+ tree, the maximum number of keys in a node is five. What is the minimum number of keys in any nonroot node? Options: (A) 1; (B) 2; (C) 3; (D) 4.
Your answer
Answer & solution
Answer: B (no official key was published)
With at most five keys, an internal node has at most six child pointers. A nonroot internal node must have at least ceil(6/2)=3 children and therefore at least two separator keys. Such an internal node attains the minimum, giving 2, B. Under the usual leaf convention a leaf with capacity five has at least three data keys; the requested minimum over nonroot nodes is still two, not a claim that every leaf may have two.
An internal search node with c child pointers has c−1 separator keys. The maximum of five keys therefore corresponds to order six, whose half-full lower bound is three children, not three keys. The root is exempt from the ordinary minimum occupancy rule. Keeping child counts distinct from key counts avoids the common off-by-one error.
Schemas: Passenger(pid,pname,age) and Reservation(pid,class,tid). Passenger rows: (0,Sachin,65), (1,Rahul,66), (2,Sourav,67), (3,Anil,69). Reservation rows: (0,AC,8200), (1,AC,8201), (2,SC,8201), (5,AC,8203), (1,SC,8204), (3,AC,8202). Which pids does this query return? SELECT pid FROM Reservation WHERE class='AC' AND EXISTS (SELECT * FROM Passenger WHERE age>65 AND Passenger.pid=Reservation.pid); Options: (A) 1,0; (B) 1,2; (C) 1,3; (D) 1,5.
Your answer
Answer & solution
Answer: C (no official key was published)
The outer query first keeps AC reservation rows, whose passenger IDs are 0,1,5,3. The correlated EXISTS requires a Passenger row with the same pid and age greater than 65. ID 0 has age exactly 65 and fails; ID 5 has no Passenger row and fails. IDs 1 and 3 have ages 66 and 69 and pass, giving 1,3, option C.
EXISTS tests whether at least one matching subquery row exists; it does not require every Passenger row to meet the age condition. Passenger 2 is old enough but its only reservation is SC, so the outer AC filter removes it. Passenger 1’s additional SC reservation also does not add another output row. No ORDER BY is present, so 1,3 describes the result members rather than a guaranteed row order.
Which concurrency-control protocols ensure both conflict serializability and freedom from deadlock? I: two-phase locking. II: timestamp ordering. Options: (A) I only; (B) II only; (C) Both I and II; (D) Neither I nor II.
Your answer
Answer & solution
Answer: B (no official key was published)
Two-phase locking guarantees conflict serializability but can create a cycle of transactions waiting for locks, so I does not guarantee deadlock freedom. Basic timestamp ordering enforces conflicts in timestamp order and rejects/aborts violating operations rather than making transactions wait on locks. It is conflict serializable and deadlock-free, although retries can still starve a transaction. Thus II only, B.
A simple 2PL deadlock is T1 holding lock X while requesting Y and T2 holding Y while requesting X; neither needs to violate the two-phase rule. Timestamp ordering instead disallows an operation inconsistent with the fixed transaction order. Deadlock freedom does not imply starvation freedom: repeated abort/restart of one transaction is still possible.
Transactions T1,T2,T3 execute this schedule, in time order: r1(X), r2(Y), r3(Y), w2(Y), w1(X), w3(X), r2(X), w2(X). Which serial order is equivalent to the schedule? Options: (A) T1→T3→T2; (B) T2→T1→T3; (C) T2→T3→T1; (D) T3→T1→T2.
Your answer
Answer & solution
Answer: A (no official key was published)
Step through it (10 steps)
In time order the schedule is r1(X), r2(Y), r3(Y), w2(Y), w1(X), w3(X), r2(X), w2(X). Conflicts on X impose T1→T3, T1→T2 and T3→T2; r3(Y) before w2(Y) also imposes T3→T2. There is no reverse edge. Its unique topological ordering is T1→T3→T2, option A.
Two operations conflict only if they belong to different transactions, access the same item, and at least one is a write. Reads r2(Y) and r3(Y) do not themselves create an edge. However r3(Y) before w2(Y) creates T3→T2. A topological ordering of the resulting acyclic graph gives a conflict-equivalent serial execution; source-code transaction numbering alone does not determine that order.
Relations R(A,B,C) and S(B,D,E) obey B→A and A→C in R. R contains 200 tuples and S contains 100 tuples. What is the maximum possible cardinality of their natural join R⋈S? Options: (A) 100; (B) 200; (C) 300; (D) 2000.
Your answer
Answer & solution
Answer: A (no official key was published)
Within R(A,B,C), B→A and A→C imply B→ABC, so B is a key under relational set semantics. In the natural join on common attribute B, each of the 100 tuples of S(B,D,E) matches at most one R tuple. Therefore the join has at most 100 tuples. This bound is attainable by choosing all S.B values among the 200 R.B values, so A. The cardinality of R does not multiply each S row because B is unique in R.
The bound is attained, for example, by choosing 100 S rows whose B values all occur in R, with distinct D,E as needed. Every S row then contributes exactly one join row. Different S rows may share a B value without violating any stated dependency, but none can match two R rows because B determines every attribute of R. This is a many-to-one join from S to R.
T1=R1x, W1x, W1y; T2=R2x, R2y, W2y. S1=R1x, R2x, R2y, W1x, W1y, W2y; S2=R1x, R2x, R2y, W1x, W2y, W1y; S3=R1x, W1x, R2x, W1y, R2y, W2y; S4=R2x, R2y, R1x, W1x, W1y, W2y. Which are conflict-serializable? A S1/S2; B S2/S3; C S3 only; D S4 only.
Your answer
Answer & solution
Answer: B (no official key was published)
Step through it (4 schedules)
S1 has T2→T1 from r2(x) before w1(x), but T1→T2 from w1(y) before w2(y), so it cycles. S2 has only T2→T1: both its reads and final write of y precede T1’s conflicting writes. S3 has only T1→T2, as w1(x) and w1(y) precede T2’s accesses. S4 cycles for the same opposing x and y directions as S1. Therefore S2 and S3 are conflict-serializable, B.
Build one vertex per transaction and add an edge when an earlier operation conflicts with a later operation of the other transaction on the same item, with at least one write. Reads of different items or two reads do not conflict. S2 has only 2→1, so it is equivalent to serial T2, T1; S3 has only 1→2. S1/S4 each contain both directions and therefore a directed cycle. Acyclicity, not whether operations are interleaved, determines conflict serializability.
Relations r on R={a, b, c}, s on S={c}. I=π_ab(r)−π_ab((π_ab(r)×s)−r). II={t∈π_ab(r):∀u∈s ∃v∈r(u=v[c]∧t=v[ab])}. III replaces that quantification by∀v∈r ∃u∈s with the same equality predicates. IV SELECT R.a, R.b FROM R, S WHERE R.c=S.c. Which pair is equivalent? A I/II; B I/III; C II/IV; D III/IV.
Your answer
Answer & solution
Answer: A (no official key was published)
I begins with candidate(a, b) pairs from r and removes those for which some c in s is missing from r, exactly relational division r÷s. II expresses the same condition: for every tuple u in s there exists a tuple v in r matching both u’s c and the candidate(a, b). Thus I and II are equivalent, A, including empty s because both restrict candidates to the projection of r. III reverses the quantifiers and requires all r tuples to share the candidate pair; IV is only an existential matching join, not universal division.
Division asks for candidates paired with every c in s. Expression I constructs all required candidate/c combinations, subtracts actual tuples to find missing combinations, then removes the candidates with any missing one. II directly quantifies the same every-c requirement. A join only requires at least one matching c, so IV cannot replace division. Empty s is handled consistently because both I and II retain candidates only fromπ_ab(r), rather than introducing an infinite domain.
Schema Suppliers(sid key, sname, city, street), Parts(pid key, pname, color), Catalog(sid, pid composite key, cost). Query SELECT S.sname FROM Suppliers S WHERE S.sid NOT IN(SELECT C.sid FROM Catalog C WHERE C.pid NOT IN(SELECT P.pid FROM Parts P WHERE P.color<>blue)). Relations nonempty. Options suppliers who A supplied a non-blue part; B have not supplied a non-blue part; C supplied only blue parts; D have not supplied only blue parts. Preserve SQL-null/referential-integrity and wording qualifications.
Your answer
Answer & solution
Answer: D (no official key was published)
The innermost query finds non-blue part IDs. The middle query finds supplier IDs for catalog rows whose part is not in that set, i.e. suppliers of a blue part under the intended referential-integrity and non-NULL color assumptions. The outer NOT IN therefore returns names of suppliers who supply no blue parts, including suppliers with no catalog rows. The intended option is D, but its printed wording is imprecise: “have not supplied only blue parts” logically also includes mixed-color suppliers, whereas the SQL excludes them. A asks for any non-blue supply and also includes mixed suppliers; B and C concern suppliers with no non-blue supply / only blue supply, the opposite condition. Thus no option states the exact result under a literal reading. Do not present D as an officially verified or exact semantic equivalence.
Read the nested NOT IN clauses from inside out. First collect non-blue part IDs; next collect suppliers with a catalog part outside that set, meaning a blue part under non-null referential-integrity assumptions; finally exclude those suppliers. The result is suppliers with no blue supply, including suppliers with no catalog row. A supplier of both blue and red is excluded. That mixed-supply example demonstrates why printed D is not literally equivalent to the SQL despite being the intended choice. The discrepancy is semantic, not a reason to invent an official key.
For the preceding schema, supplier names and street names are unique within a city, and(sname, city) is a candidate key. No FDs other than those implied by primary/candidate keys are assumed. Choose A BCNF; B 3NF not BCNF; C 2NF not 3NF; D not 2NF.
Your answer
Answer & solution
Answer: A (no official key was published)
The given primary keys are Suppliers.sid, Parts.pid, and Catalog.(sid, pid); Suppliers additionally has candidate key (sname, city). The question explicitly rules out functional dependencies other than those implied by primary and candidate keys. Consequently every nontrivial FD has a superkey as determinant, exactly the BCNF condition. All three relations are in BCNF, option A. Do not infer street→city from an address or infer sname alone is a key: the stipulated uniqueness is within a city and (sname, city) is explicitly the candidate key.
BCNF tests every nontrivial FD X→Y and requires X to be a superkey. The source explicitly permits only dependencies implied by the listed keys, so all such determinants qualify. Do not invent dependencies from the meaning of street or supplier name beyond the stated within-city uniqueness. Thus the schema meets BCNF and consequently the weaker normal forms as well; A is the strongest correct listed description.
(A) I only (B) II only (C) III only (D) III and IV only
Your answer
Answer & solution
Answer: C (no official key was published)
1. A universal statement fails exactly when there is a counterexample. Here a counterexample is a tuple t in r for which P(t) is false. 2. Excluding every such counterexample gives ¬∃t∈r ¬P(t), which is III. 3. I instead says no tuple satisfies P; II and IV discuss tuples outside r. Therefore III only, C.
A clustering index is defined on fields of which type?
(A) Non-key and ordering (B) Non-key and non-ordering (C) Key and ordering (D) Key and non-ordering
Your answer
Answer & solution
Answer: A (no official key was published)
1. An ordering field determines the physical ordering of the data file. 2. If that field is non-key, multiple records can share a value and form a contiguous cluster, indexed by a clustering-index entry. 3. This classical classification gives A. An ordering key instead gives a primary index; a non-ordering field gives a secondary index. Modern clustered-index terminology can be broader.
R(P,Q,R1,R2,R3) and S(P,Q,S1,S2) each have key {P,Q}. Which relational-algebra queries are equivalent? ⋈ denotes natural join. I: πP(R⋈S). II: πP(R)⋈πP(S). III: πP(πP,Q(R)∩πP,Q(S)). IV: πP(πP,Q(R)−(πP,Q(R)−πP,Q(S))).
(A) I and II only (B) I and III only (C) I,II,III only (D) I,III,IV only
Your answer
Answer & solution
Answer: D (no official key was published)
1. The natural join matches both common attributes P and Q. Consequently I returns P values of pairs (P,Q) appearing in both relations, exactly III. 2. Since A−(A−B)=A∩B, IV is also equivalent. II only matches P after discarding Q: R containing (p,q1) and S containing (p,q2), q1≠q2, makes II nonempty but I empty. 3. Thus only I, III and IV are equivalent, option D.
Book(Title,Author,Catalog_no,Publisher,Year,Price) and Collection(Title,Author,Catalog_no) have key {Author,Title}. Dependencies: Title Author→Catalog_no; Catalog_no→Title Author Publisher Year; Publisher Title Year→Price. Which statement is true?
(A) Both are in BCNF (B) Both are in 3NF only (C) Book is in 2NF and Collection is in 3NF (D) Both are in 2NF only
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (2 parts)
1. In Book, both {Title,Author} and {Catalog_no} are candidate keys. No given dependency makes a nonprime attribute depend on a proper subset of a candidate key, so Book is in 2NF. 2. Publisher,Title,Year→Price violates 3NF because its determinant is not a superkey and Price is nonprime. Collection has only Title, Author and Catalog_no; its nontrivial determinants are candidate keys, so it is BCNF and hence also 3NF. 3. Therefore C is true. The wording of C does not say Collection is only in 3NF.
A file has 16384 records of 32 bytes each, with a 6-byte key. It is ordered on a non-key field and uses unspanned organization. Block size is 1024 bytes and block pointers occupy 10 bytes. A multilevel secondary index is built on the key. How many first- and second-level index blocks are needed?
(A) 8 and 0 (B) 128 and 6 (C) 256 and 4 (D) 512 and 5
Your answer
Answer & solution
Answer: C (no official key was published)
1. Because the file is not ordered by the indexed key, the first secondary-index level is dense, with one entry per record. An entry occupies 6+10=16 bytes, so a 1024-byte block holds 64 entries. 2. The first level therefore needs 16384/64=256 blocks. The second level indexes those ordered first-level blocks, requiring 256/64=4 blocks. 3. Option C. The 512 data blocks are not the first-level index-block count.
An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. What is the minimum number of tables in the standard relational mapping?
(A) 2 (B) 3 (C) 4 (D) 5
Your answer
Answer & solution
Answer: B (no official key was published)
1. Use three relations: P(P1,P2), M(M1,M2,M3,P1), and N(P1,N1,N2). R1 is many-to-one from M to P with total participation of M, so a P1 foreign key in M represents it without a separate relationship table. 2. N is weak, R2 is its identifying many-to-one relationship with P, and N1 is the partial key; include P1 in N, whose primary key is (P1,N1). Thus the standard ER-to-relational mapping needs three tables, option B.
An ER diagram has strong entities M with attributes M1 (key), M2,M3, and P with attributes P1 (key),P2. Relationship R1 is many-to-one from M to P, with total participation of M. N is a weak entity with partial key N1 and attribute N2. Its identifying relationship R2 is many-to-one from N to owner P, with total participation of N. Neither relationship has attributes. In the minimum-table standard mapping, which is the attribute set of one resulting table?
1. The many-to-one R1 relationship associates each M with a unique P. Total participation means every M must have that owner/reference. 2. Store P’s key P1 as a foreign key beside M’s own attributes M1,M2,M3; a separate R1 table is unnecessary. 3. Thus M’s table has {M1,M2,M3,P1}, A. N is represented separately by owner key P1, partial key N1 and N2; there is no direct M-to-N relationship to justify the other sets.
Relations are studInfo(studId,name,sex), keyed by studId, and enroll(studId,courseId), keyed by the pair. Every course has at least one male and one female enrollee. What does π_courseId(((π_studId(σ_sex="female"(studInfo))) × π_courseId(enroll)) − enroll) return? Options: (A) Courses taken by all female students (B) Courses taken by a proper subset of female students (C) Courses taken only by male students (D) None of these
Your answer
Answer & solution
Answer: B (no official key was published)
1. Approach. The Cartesian product enumerates required pairs for every female student to take every course. Subtraction identifies missing pairs, and projection asks which courses have at least one such missing pair.
2. Derivation and interpretation. Let F be the set of female student IDs and C the set of course IDs occurring in enroll. The Cartesian product F×C contains every possible female-student/course pair. Subtracting enroll leaves exactly pairs (f,c) for which female f is not enrolled in c. Projecting on courseId therefore returns courses missing at least one female student. Since the premise says every course has at least one female enrollee, these are courses whose female enrollee set is a nonempty proper subset of all female students. This is B, not courses taken by every female student.
employee(name,sex,supervisorName) has key name. supervisorName names an employee’s supervisor. Interpret the tuple-calculus query {e.name | employee(e) ∧ ∀x[¬employee(x) ∨ x.supervisorName≠e.name ∨ x.sex="male"]}. Options: (A) Employees with a male supervisor (B) Employees with no immediate male subordinates (C) Employees with no immediate female subordinates (D) Employees with a female supervisor
Your answer
Answer & solution
Answer: C (no official key was published)
1. Approach. Rewrite the disjunction as an implication about x: if x is an employee supervised by e, x must be male. Universal conditions are true even when e has no subordinates.
2. Derivation and interpretation. The universal disjunction ¬employee(x) ∨ x.supervisorName≠e.name ∨ x.sex=male is the implication: if x is an employee supervised by e, then x is male. Consequently the result includes employees all of whose immediate subordinates are male, including employees with no subordinates by vacuous truth. Under the male/female domain convention used by the options, this is exactly employees with no immediate female subordinates (C). It says nothing about the sex of e's own supervisor.
employee(empId,name,department,salary) has more than one employee in department 5. We want employees paid more than every department-5 employee. Compare: Q1: SELECT e.empId FROM employee e WHERE NOT EXISTS (SELECT * FROM employee s WHERE s.department="5" AND s.salary>=e.salary); Q2: SELECT e.empId FROM employee e WHERE e.salary > ANY (SELECT DISTINCT salary FROM employee s WHERE s.department="5"); Which statement is intended for an arbitrary table under non-NULL salary semantics? Options: (A) Q1 is correct (B) Q2 is correct (C) Both always produce the same answer (D) Neither is correct
Your answer
Answer & solution
Answer: A (no official key was published)
1. Approach. NOT EXISTS rejects the presence of a counterexample to “greater than everyone.” SQL ANY is existential: satisfying one comparison suffices. DISTINCT does not change that quantifier.
2. Derivation and interpretation. For each e, Q1 excludes e whenever any department-5 employee has salary >= e.salary. Thus it keeps exactly salaries strictly greater than the department maximum. Q2 uses > ANY, which means greater than at least one returned salary, not every salary. For department salaries 10 and 20, a salary 15 passes Q2 but not Q1. Hence A under the usual non-NULL salary interpretation. Strict SQL NULL semantics require qualification: NULL comparisons are UNKNOWN, so Q1 can admit NULL salaries or ignore unknown department salaries; no NOT NULL constraint is printed.
Which normalization statement is intended to be false? Interpret the textbook conventions discussed in the solution. Options: (A) Any two-attribute relation is in BCNF (B) A relation whose every candidate key has one attribute is in 2NF (C) A prime attribute can be transitively dependent on a key in a 3NF relation (D) A prime attribute can be transitively dependent on a key in a BCNF relation
Your answer
Answer & solution
Answer: D (no official key was published)
1. Approach. For a nontrivial dependency X→A, 3NF permits either X to be a superkey or A to be prime. BCNF removes the prime-attribute exception. Definitions of transitive dependence and empty determinants matter here.
2. Derivation and interpretation. Under standard textbook normalization conventions, a two-attribute relation is BCNF: a nontrivial dependency from one attribute to the other makes its determinant a key. Single-attribute candidate keys have no proper nonempty subset, so no partial dependency prevents 2NF. In 3NF a non-key determinant may determine a prime attribute, permitting the transitive dependency in C. BCNF instead requires every nontrivial determinant to be a superkey, so it excludes a transitive dependency through a non-key determinant. D is the intended false statement. Here transitive dependency means the normalization violation through a non-superkey, not merely any composable implication. The claims about two-attribute relations and singleton keys also assume the textbook convention excluding nontrivial empty-determinant dependencies. If such dependencies are allowed, R(A,B) with ∅ -> B and candidate key A violates both BCNF and 2NF: ∅ is not a superkey, and the nonprime B depends on a proper subset of key A. Consequently A and B are also false under that fully general interpretation, so D is the intended answer only with this convention.
The order of a B+ tree leaf is the maximum number of (value,data-record-pointer) pairs it can hold. Block size is 1K bytes, value size 9 bytes, record-pointer size 7 bytes and block-pointer size 6 bytes. What is the leaf order? Options: (A) 63 (B) 64 (C) 67 (D) 68
Your answer
Answer & solution
Answer: A (no official key was published)
1. Approach. Reserve space for the leaf’s next-block pointer before dividing the remaining bytes by entry size. Use 1K=1024 bytes and round the result down, because partial entries cannot be stored.
2. Derivation and interpretation. A leaf stores m pairs of 9-byte values and 7-byte record pointers, plus a 6-byte pointer to the next leaf. Therefore 16m+6 <= 1024, giving m <= floor(1018/16)=63. Answer A. Ignoring the leaf-link pointer would incorrectly give 64.
Similar questions10 more → · asked again: GATE 2021 Set 1, Q32
Conflict serializability of two schedules
Transactions & Concurrency Control
Tap to enlarge
For two transactions, consider schedules S1: r1(X);r1(Y);r2(X);r2(Y);w2(Y);w1(X) and S2: r1(X);r2(X);r2(Y);w2(Y);r1(Y);w1(X). Which are conflict serializable? Options: (A) Both (B) S1 only (C) S2 only (D) Neither
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (2 schedules)
1. Approach. Create a precedence edge only between different transactions on the same item when at least one access is a write. Read–read pairs do not conflict. A cycle is exactly the obstruction to conflict serializability.
2. Derivation and interpretation. In S1, r1(Y) precedes w2(Y), producing T1 -> T2, while r2(X) precedes w1(X), producing T2 -> T1. The cycle prevents conflict serializability. In S2, w2(Y) precedes r1(Y) and r2(X) precedes w1(X), both giving T2 -> T1; there is no reverse edge. S2 is equivalent to serial order T2,T1. Thus C.
A bank account initially has balance 12000. A transaction transfers 2000 to mortgage M, then another applies 5% interest. Log records are: 1 T1 start 2 T1 B old=1200 new=10000 3 T1 M old=0 new=2000 4 T1 commit 5 T2 start 6 T2 B old=10000 new=10500 7 T2 commit The old value 1200 in record 2 is printed despite the narrative's 12000. The system crashes just before record 7 is written. Which recovery assertion is true? Options: (A) Redo record 6, setting B=10500 (B) Undo record 6 to B=10000, then redo records 2 and 3 (C) Records 2 and 3 need not be redone because T1 committed (D) Redo and undo can be performed in arbitrary order because they are idempotent
Your answer
Answer & solution
Answer: B under undo-redo logging (no official key was published)
1. T1 has a commit record, whereas T2 does not. Undo T2’s balance change to 10000 and ensure T1’s balance/mortgage changes 10000 and 2000 are redone, B.
2. Commit does not necessarily force all modified pages to disk in undo-redo logging; idempotence does not allow arbitrary ordering of conflicting log actions. The printed old balance in record 2 is 1200 although the narrative says 12000.
3. That inconsistency does not change the committed new balance or this recovery conclusion, but it is not silently corrected.
4. Teaching check: Recovery distinguishes a transaction whose commit record reached the log from one whose commit record never did. Redo protects committed effects that may not yet be on disk; undo removes effects from incomplete transactions that may already have reached disk. A commit record is therefore not proof that every data page was forced.
Relation account(customer,balance) has customer as primary key and no nulls. Rank by decreasing balance, starting at 1, tying equal balances and skipping ranks (two tied maxima both rank 1, next rank 3). Q1: SELECT A.customer,COUNT(B.customer) FROM account A,account B WHERE A.balance<=B.balance GROUP BY A.customer; Q2: SELECT A.customer,1+COUNT(B.customer) FROM account A,account B WHERE A.balance<B.balance GROUP BY A.customer; Statements: 1 Q1 and Q2 agree for some but not all databases; 2 both implement the rank specification; 3 Q1 is correct but Q2 is not; 4 neither is correct; 5 pure relational ranking is faster than scanning in decreasing balance order and assigning ranks through ODBC. Which pair is correct? Options: (A) 2 and 5 (B) 1 and 3 (C) 1 and 4 (D) 3 and 5
Your answer
Answer & solution
Answer: C (no official key was published)
1. Query1 counts B rows with A.balance≤B.balance, so a customer tied with t customers at its balance receives the count of higher-balance customers plus t, instead of plus 1. For two tied maximum balances it gives 2, not 1.
2. Query2 uses A.balance<B.balance and adds 1 to the count, but its inner join produces no group for maximum-balance customers; those customers disappear. Thus neither query is correct (statement 4).
3. They agree on the empty database but differ on every nonempty database because Query1 includes the maximum group and Query2 does not, establishing statement 1 under the allowed empty-database case. Hence statements 1 and 4, option C.
4. Statement 5 is not a general performance guarantee.
5. Teaching check: The intended rank is 1 plus the number of strictly higher balances. Q1 instead counts all tied customers along with higher ones. Q2 uses the correct comparison but an inner join removes maxima, so adding one to its count does not restore the missing rows.
Schemas enrolled(student,course), key (student,course), and paid(student,amount), key student; no nulls, foreign keys or additional constraints. Q1: SELECT student FROM enrolled WHERE student IN (SELECT student FROM paid); Q2: SELECT student FROM paid WHERE student IN (SELECT student FROM enrolled); Q3: SELECT E.student FROM enrolled E,paid P WHERE E.student=P.student; Q4: SELECT student FROM paid WHERE EXISTS (SELECT * FROM enrolled WHERE enrolled.student=paid.student); Which statement holds under SQL result-bag semantics (no DISTINCT)? Options: (A) All four return identical rows for every database (B) Q2 and Q4 always agree, but Q1 and Q2 can differ (C) Q3 can return strictly fewer rows than Q2 (D) Q4 can encounter a runtime integrity violation
Your answer
Answer & solution
Answer: B (no official key was published)
1. Query2 and Query4 each scan paid, whose student key is unique, and keep exactly students with an enrolled match. They therefore return identical bags with one row per matching student.
2. Query1 scans enrolled and returns one student occurrence for each matching enrollment; Query3 has the same multiplicities because paid has at most one matching row. A paid student enrolled in two courses appears twice in Query1/3 but once in Query2/4.
3. Thus B. SELECT alone does not eliminate duplicate rows; the phrase row sets must be interpreted as SQL result rows/bags.
4. Teaching check: A membership predicate filters each outer row but does not collapse duplicates already present in the outer projection. The paid key guarantees one outer row per student for Q2/Q4, whereas enrolled can contain several courses per student for Q1/Q3. Relational set intuition must not erase SQL multiplicities.
Schemas enrolled(student,course), key (student,course), and paid(student,amount), key student, have no nulls, foreign keys or additional constraints. Amounts 6000,7000,8000,9000,10000 are each paid by 20% of students. Both plans list courses of students paying more than x. Plan 1 sequentially scans paid, selects amount>x, probes enrolled's student index for an indexed nested-loop join, then projects course. Plan 2 scans all paid and performs the same indexed join first, then selects amount>x and projects course. Projection does not request DISTINCT. A disk seek costs 4 ms, transfer rate is 300 MB/s, and checking amount>x costs 10 μs per tuple. Which statement holds? Options: (A) The plans do not return identical rows for every database (B) Plan 1 may list a course more than once (C) At x=5000 Plan 1 is faster for every database (D) At x=9000 Plan 1 is slower for every database
Your answer
Answer & solution
Answer: B (no official key was published)
1. Both plans select the same matching paid/enrolled tuples: pushing a predicate on paid.amount below the join preserves the result. Projection without DISTINCT can output the same course for two different qualifying students, so B is true under SQL bag semantics.
2. The enrolled key is (student,course), not course. C is not universal: at x=5000 all paid rows pass, and with no enrollments Plan 2 has no joined rows to test while Plan 1 still tests paid rows.
3. D is not universal either: at x=9000 Plan 1 can avoid 80% of index probes, making it faster on ordinary populated instances. Seek and transfer constants do not turn either universal performance claim into a theorem.
4. The plans/options continue on page 11.
5. Teaching check: Pushing a filter before a join can reduce work, but a universal speed claim needs more than a selectivity estimate. Course is not a key of the join output, so two qualifying students in the same course produce repeated course values after projection without DISTINCT.
Given dependencies AB→CD, AF→D, DE→F, C→G, F→E, G→A, which claimed attribute closure is false? Both reproductions contain the following options, including F in D. Options: (A) (CF)⁺={A,C,D,E,F,G} (B) (BG)⁺={A,B,C,D,G} (C) (AF)⁺={A,C,D,E,F,G} (D) (AB)⁺={A,B,C,D,F,G}
Your answer
Answer & solution
Answer: C, D (no official key was published)
1. Apply AB→CD, AF→D, DE→F, C→G, F→E, G→A until closure stops. (CF)+={A,C,D,E,F,G}: C gives G then A; F gives E; AF gives D.
2. (BG)+={A,B,C,D,G}: G gives A then AB gives C,D; neither E nor F is derivable. (AF)+={A,D,E,F}: AF gives D and F gives E, but nothing yields C or G.
3. (AB)+={A,B,C,D,G}: AB gives C,D, C gives G; no E or F follows. Thus C is false and D is also false because its printed right side includes F.
4. A and B are true. There is no unique single false option in these reproductions.
5. Teaching check: Begin each closure with the attributes on the left, then repeatedly add a dependency’s right side only when its entire left side is present. In particular DE→F cannot fire with D alone. This is why AB cannot acquire E or F and why AF cannot acquire C or G.
Key reason to prefer B+ trees over binary search trees for database indexes? A many records; B relations sorted on primary key; C always lower memory; D disk transfers occur in blocks.
Your answer
Answer & solution
Answer: D (no official key was published)
Disk I/O transfers whole blocks. A high-fanout B+ tree packs many keys/pointers into each block, reducing tree height and therefore block reads relative to an ordinary pointer-based binary search tree. Thus D is the key storage-system reason.
The expensive unit is usually a disk block read. A B+ node can contain many separators and pointers in one block, providing much higher branching factor than a binary node. Higher branching factor reduces the number of blocks on a root-to-leaf search. Thus D identifies the storage-aware reason, not a universal claim that B+ trees use fewer bytes or require the underlying relation to be sorted.
Which normal-form statement is false? A BCNF stricter than 3NF; B lossless dependency-preserving 3NF decomposition always possible; C lossless dependency-preserving BCNF decomposition always possible; D any two-attribute relation is BCNF. Preserve the empty-determinant qualification for D.
Your answer
Answer & solution
Answer: C under the usual nonempty-determinant convention (no official key was published)
A lossless dependency-preserving 3NF decomposition always exists, whereas achieving BCNF can sacrifice dependency preservation. For example R(A, B, C) with AB→C and C→B has a BCNF violation C→B; decomposition into CB and AC loses the ability to enforce AB→C locally. Thus C is false. The separate assertion that every two-attribute schema is BCNF assumes no nontrivial empty-determinant dependencies: with ∅→A but A not determining B, R(A, B) is a counterexample to that assertion. Under literal unrestricted FDs both C and D can fail; the conventional answer excludes constant-column FDs.
A3NF synthesis can preserve every dependency and be lossless, whereas BCNF decomposition can force some dependencies to require a join for checking. For AB→C, C→B, splitting off CB removes the BCNF violation but leaves AB→C unenforceable within either component alone. Hence C is the conventional false assertion. Constant-column dependencies∅→A supply the explicitly retained counterexample to D under unrestricted definitions; the source’s unique-choice answer requires excluding that case.
For instance r(A, B, C, D), project r1=π_ABC(r), r2=π_AD(r) and rejoin s=r1⋈r2. The decomposition is lossy. Which is true? A s⊂r; B r∪s=r; C r⊂s; D r⋈s=s.
Your answer
Answer & solution
Answer: C (no official key was published)
Each original tuple contributes matching projections to r1 and r2, so r⊆r1⋈r2=s. A lossy decomposition creates spurious joined tuples; for the stated lossy instance the containment is strict, r⊂s, C. A natural join here does not discard any original tuple.
Projection cannot lose an original tuple when its two projections are rejoined: they still agree on their shared A value. The join may combine components from different original tuples, adding spurious tuples. A lossy instance therefore gives strict inclusion r⊂s. Since r and s have identical schemas, their natural join is their intersection, namely r, not s. Thus only C states the proper direction.
Two ER entities E1, E2 have simple single-valued attributes and two relationships between them: R1 one-to-many and R2 many-to-many, neither with attributes. Minimum relational tables: A2; B3; C4; D5.
Your answer
Answer & solution
Answer: B (no official key was published)
Use one table for each entity set. The one-to-many relationship is represented by placing the one-side key as a foreign key in the many-side table, so it needs no separate table. The many-to-many relationship needs a third junction table containing the two entity keys. Minimum: three tables, option B.
Represent each entity type by a table, giving two. The many side of R1 can store the one-side primary key, since each many-side instance relates to at most one one-side instance; no junction table is necessary. R2 needs a junction table because either side can have several partners. Its pair of foreign keys records each pair, bringing the minimum to three.
Table(A, C), primary key A, C references A ON DELETE CASCADE, contains (2, 4),(3, 4),(4, 3),(5, 2),(7, 2),(9, 5),(6, 4). Besides(2, 4), which rows must be deleted when it is removed? A(3, 4),(6, 4); B(5, 2),(7, 2); C(5, 2),(7, 2),(9, 5); D(3, 4),(4, 3),(6, 4).
Your answer
Answer & solution
Answer: C (no official key was published)
Deleting key A=2 directly deletes the referencing rows (5, 2) and (7, 2). Deleting A=5 in turn deletes (9, 5). Nothing points to 7 or 9 in the displayed instance. Rows (3, 4),(4, 3),(6, 4) do not depend on key 2 and remain. The additional deletion set is {(5, 2),(7, 2),(9, 5)}, option C.
Follow references toward deleted primary-key values, not outward along the deleted row’s own foreign key. Removing key 2 first removes rows with C=2, namely 5 and 7. Removing key 5 then removes row 9. No remaining row points to 7 or 9. The cycle 3↔4 and row 6→4 are unrelated to deletion of 2, so they survive. Cascades must be followed transitively, which is why choice B is incomplete.
book(title, price) has distinct prices. Query SELECT title FROM book B WHERE (SELECT COUNT(*) FROM book T WHERE T.price>B.price)<5. A four most expensive titles; B fifth cheapest; C fifth most expensive; D five most expensive titles. Examine NULL prices separately.
Your answer
Answer & solution
Answer: D, assuming non-NULL prices (no official key was published)
For each B the subquery counts books with a strictly higher price. The predicate count<5 selects ranks 1 through 5 in descending price order, because they have respectively 0 through 4 more expensive books. Distinct prices rule out ties. The result is the titles of the five most expensive books (or all books if fewer than five), option D. This intended interpretation additionally assumes prices are non-NULL. Distinct prices alone does not establish a NOT NULL constraint: for a row B with NULL price, every T.price>B.price comparison is UNKNOWN, so the subquery counts zero and that NULL-priced row is included regardless of the five highest non-NULL prices.
For a book with descending rank r and a non-NULL unique price, exactly r−1 rows are more expensive. The predicate r−1<5 is r≤5, yielding the top five, not merely the fifth. COUNT(*) counts qualifying rows, never the current book because comparison is strict. If B.price is NULL, every comparison is UNKNOWN and no row qualifies, so count is 0 and that book also passes. Distinctness alone must not be silently upgraded to NOT NULL.
R(A, B, C, D, E, H), FDs A→B, BC→D, E→C, D→A. Candidate-key sets: A AE, BE; B AE, BE, DE; C AEH, BEH, BCH; D AEH, BEH, DEH. Option C uses the clearer GateForum BEH; GFG appears to print BEE in that position.
Your answer
Answer & solution
Answer: D (no official key was published)
Step through it (6 steps)
Neither E nor H appears on any dependency right-hand side, so every key contains both. E supplies C. Adding A yields B then D through BC→D; adding B yields D then A; adding D yields A then B. Thus AEH, BEH, DEH each determine all six attributes. EH alone cannot determine A, B, D, and adding only C gives nothing new, so these are precisely the minimal keys, option D.
Attributes absent from all FD right sides cannot be manufactured by closure, so every key includes E, H. With them C becomes available. Add A: obtain B, then D. Add B: combine with C to obtain D, then A. Add D: obtain A then B. Thus all three listed triples are superkeys. Removing their third attribute leaves EH with only E, H, C, proving minimality; adding C instead cannot unlock A, B, D. This also proves there are no omitted minimal keys.
Relations R1(A,B,C) and R2(D,E) have keys A and D respectively. C is a foreign key in R1 referencing D in R2. Instances r1,r2 satisfy referential integrity. Which expression must be empty? Projection outputs in set differences are identified by their compatible single domains. Options: (A) π_D(r2) − π_C(r1) (B) π_C(r1) − π_D(r2) (C) π_D(r1 ⋈_(C≠D) r2) (D) π_C(r1 ⋈_(C=D) r2)
Your answer
Answer & solution
Answer: B (no official key was published)
1. Referential integrity requires every C value in r1 to occur as a referenced D value in r2. Hence π_C(r1)⊆π_D(r2), and π_C(r1)−π_D(r2) is empty, B, under classical relational algebra without SQL nulls.
2. The reverse difference can contain unreferenced parent keys.
3. Teaching check: Think of C values as child references and D values as parent keys. A dangling reference would be a value in the child projection absent from the parent projection. Referential integrity forbids precisely that difference, while allowing parent rows with no children.
Natural-join cardinality and an unstated foreign key
Relational Algebra & Calculus
Tap to enlarge
Student(rollno,name,address) has key rollno; Enroll(rollno,courseno,coursename) has composite key (rollno,courseno). They have 120 and 8 tuples respectively. What are the maximum and minimum sizes of Student ⋈ Enroll (natural join)? No foreign-key constraint is stated. Options: (A) 8,8 (B) 120,8 (C) 960,8 (D) 960,120
Your answer
Answer & solution
Answer: Maximum8, minimum 0; A only with referential integrity (no official key was published)
1. Student.rollno is the underlined key, while Enroll has the composite key(rollno,courseno). Each of the 8 enrollment tuples can match at most one Student tuple, so the maximum join size is 8.
2. With only the stated keys, all enrollment roll numbers may be absent from Student, giving minimum 0; no listed pair is then correct. If the intended additional constraint is Enroll.rollno referencing Student.rollno, every enrollment matches exactly once and both maximum/minimum are 8, A.
3. This foreign-key constraint is not stated and is not inferred from matching attribute names alone.
4. Teaching check: The maximum is attained when all eight enrollments use existing student roll numbers, possibly different courses for the same student. The minimum zero is attained by eight enrollments with roll numbers absent from Student. Primary-key uniqueness alone rules out duplicate student matches, not missing matches.
StudentPerformance(name,courseNo,rollNo,grade) has dependencies (name,courseNo)→grade; (rollNo,courseNo)→grade; name→rollNo; rollNo→name. What is its highest listed normal form? Options: (A) 2NF (B) 3NF (C) BCNF (D) 4NF
Your answer
Answer & solution
Answer: B (no official key was published)
Step through it (8 steps)
1. The candidate keys are{name,courseNo} and{rollNo,courseNo}. Thus name,rollNo,courseNo are prime attributes, and grade is non-prime.
2. Dependencies from either key to grade satisfy 3NF. The non-key determinants name and rollNo determine only another prime attribute, so these dependencies also satisfy 3NF.
3. But name→rollNo and rollNo→name violate BCNF because neither determinant determines courseNo. Highest listed normal form is 3NF.
4. Teaching check: Compute closures: {name,courseNo}+ and {rollNo,courseNo}+ both contain all attributes, but name+ contains only name,rollNo. In 3NF a non-superkey determinant may determine a prime attribute; BCNF forbids that exception. This is exactly why the two normal forms differ here.
Universal comparison through relational difference
Relational Algebra & Calculus
Tap to enlarge
Student(name,sex,marks), key name, contains at least one boy and one girl. Let ρ_(n,x,m)(Student) rename the three attributes. Interpret π_name(σ_(sex=female)(Student)) − π_name(Student ⋈_(sex=female ∧ x=male ∧ marks≤m) ρ_(n,x,m)(Student)). Options: (A) Names of girls with the highest marks (B) Names of girls with more marks than some boy (C) Names of girls with marks not less than some boy (D) Names of girls with more marks than every boy
Your answer
Answer & solution
Answer: D (no official key was published)
1. The left expression selects all female names. The right expression finds a female student paired with a male student whose marks m satisfy female marks≤m, and projects that female name.
2. Subtracting these removes every girl for whom at least one boy has marks greater than or equal to hers. Remaining girls therefore have marks greater than EVERY boy.
3. The primary-key name makes the projected subtraction unambiguous, and the stated existence of boys avoids a vacuous comparison.
4. Teaching check: The joined part is an existential counterexample set: it contains a girl if there exists a boy with marks at least hers. Subtracting all such counterexamples converts “there exists a violating boy” into “every boy has fewer marks.” Equality is removed because the join uses ≤.
The order of an internal B+ tree node is its maximum number of children. Child pointers use 6 bytes, search keys 14 bytes and each node occupies a 512-byte block. With no stated header overhead, what is the order? Options: (A) 24 (B) 25 (C) 26 (D) 27
Your answer
Answer & solution
Answer: C (no official key was published)
1. With order p, an internal node holds p child pointers and p−1 separator keys. The size is 6p+14(p−1)=20p−14≤512, so p≤26.3 and the maximum integer is 26.
2. At p=26 the node uses 506 bytes; p=27 would need 526 bytes. No unmentioned header overhead is assumed.
3. Teaching check: There is one fewer separator key than child pointers, so a p-child node needs p pointers and p−1 keys. Using p of each would incorrectly lower the capacity. Testing the two neighboring integers confirms maximality rather than relying only on rounded division.
Employee(name,sex,salary,deptName) has key name. What department names does this SQL query return? SELECT deptName FROM Employee WHERE sex='M' GROUP BY deptName HAVING AVG(salary) > (SELECT AVG(salary) FROM Employee); Options: (A) Departments whose average salary exceeds the company average (B) Departments whose male average salary exceeds the company-wide male average (C) Departments whose male average salary exceeds the average of all employees in that department (D) Departments whose male average salary exceeds the company average
Your answer
Answer & solution
Answer: D (no official key was published)
1. WHERE sex=M filters the outer rows to male employees before grouping by department. HAVING compares each such group’s average salary with the uncorrelated subquery SELECT AVG(salary) FROM Employee, which averages all employees company-wide.
2. Therefore it returns departments whose male employees’ average exceeds the overall company average. The inner query has no male filter and is not restricted to the same department.
3. Teaching check: Read SQL in stages: WHERE keeps only males; GROUP BY makes one male group per department; HAVING compares its average against a separately computed company-wide average. There is no correlation predicate linking the subquery to the department, and no sex filter inside it.
Which operation may lead to an irrecoverable database error? A. Writing an item after an uncommitted transaction reads it; B. Reading an item after an uncommitted transaction reads it; C. Reading an item written by a committed transaction; D. Reading an item written by an uncommitted transaction.
Your answer
Answer & solution
Answer: D (no official key was published)
1. Use the concrete schedule W₁(X), R₂(X), C₂, A₁. Transaction 2 has already committed a result based on transaction 1’s value when transaction 1 aborts. Recovery would need to undo a committed dependency, which is why the schedule is nonrecoverable. The word “may” matters: a dirty read need not always lead to such a commit order.
2. If T 2 reads data written by uncommitted T 1, then T 2 commits before T 1 aborts, the schedule is nonrecoverable: a committed transaction depended on an aborted value. Thus D may lead to the stated error. A dirty read alone does not always force irrecoverability; delaying dependent commits can permit cascading rollback.
Translate SELECT DISTINCT a₁,a₂,...,aₙ FROM r₁,r₂,...,rₘ WHERE P into classical relational algebra. Every option first applies selection σ_P and then projection π_(a₁,...,aₙ). Their innermost operation is: A. r₁×r₂×...×rₘ; B. r₁⋈r₂⋈...⋈rₘ; C. r₁∪r₂∪...∪rₘ; D. r₁∩r₂∩...∩rₘ.
Your answer
Answer & solution
Answer: A (no official key was published)
1. FROM first chooses every combination of one tuple from each relation. WHERE then keeps only combinations satisfying P. Finally SELECT chooses attributes, and DISTINCT removes repeated projected tuples. A natural join would additionally impose equality on common-named columns, which this arbitrary SQL query does not necessarily request.
2. The comma-separated FROM clause forms the Cartesian product of all relations, WHERE applies selection σ_P, and SELECT DISTINCT applies set projection onto the listed attributes. Thus π_attributes(σ_P(r 1×...×rm)), A, with attribute renaming/qualification as required and the classical relational-algebra interpretation.
The database functional dependencies are Date_of_birth→Age; Age→Eligibility; Name→Roll_number; Roll_number→Name; Course_number→Course_name; Course_number→Instructor; (Roll_number,Course_number)→Grade. Classify relation R(Roll_number,Name,Date_of_birth,Age): A. In 2NF but not 3NF B. In 3NF but not BCNF C. In BCNF D. None of the above Use only the listed dependencies unless an additional identifying dependency is explicitly assumed.
Your answer
Answer & solution
Answer: D (no official key was published)
1. Project the dependencies onto R. The relevant nontrivial ones are Roll_number→Name, Name→Roll_number and Date_of_birth→Age. No listed rule determines Date_of_birth from Roll_number or Name. 2. The closure of {Roll_number,Date_of_birth} contains all four attributes, and removing either attribute loses information. Likewise {Name,Date_of_birth} is a candidate key. Roll_number and Name alone are not keys under the stated dependency set. 3. Age is nonprime and depends on Date_of_birth, a proper subset of each composite candidate key. This is a partial dependency violating 2NF. Therefore none of A–C holds; D is the literal answer. 4. If one additionally assumes Roll_number→Date_of_birth, a single-attribute identifying key results and the usual 2NF-but-not-3NF answer A follows. The source does not supply that extra dependency, so it is a separate conditional interpretation.
Solution: Restrict the listed dependencies to R(Roll_number,Name,Date_of_birth,Age). They give Roll_number→Name, Name→Roll_number, and Date_of_birth→Age. Neither Name nor Roll_number determines Date_of_birth under this stated set. The candidate keys are therefore {Roll_number,Date_of_birth} and {Name,Date_of_birth}; Age is nonprime and depends on the proper key subset Date_of_birth. This violates 2NF, so the literal listed-dependency answer is D, none of the first three choices. If one additionally assumes Roll_number→Date_of_birth because roll numbers identify complete student records, Name and Roll_number become single-attribute keys and the relation is 2NF but not 3NF owing to Date_of_birth→Age, yielding A. That extra dependency is not supplied and must be labelled as an assumption.
Relations are Students(Roll_number,Name,Date_of_birth), Courses(Course_number,Course_name,Instructor), and Grades(Roll_number,Course_number,Grade). Interpret this query with the printed string constants rendered in SQL quotes: SELECT DISTINCT Name FROM Students,Courses,Grades WHERE Students.Roll_number=Grades.Roll_number AND Courses.Instructor='Korth' AND Courses.Course_number=Grades.Course_number AND Grades.Grade='A'; What set is computed? A. Students' names with A in all courses taught by Korth B. Students' names with A in all courses C. Students' names with A in at least one course taught by Korth D. None of the above
Your answer
Answer & solution
Answer: C (no official key was published)
1. The Roll_number equality pairs each student with that student's grade records. The Course_number equality pairs each grade with its course. 2. The two filters discard any joined row whose instructor is not Korth or whose grade is not A. Every surviving row therefore witnesses one qualifying course for that student. 3. Projection selects the name and DISTINCT removes repeated names when several qualifying rows exist. It does not test unselected rows or require every course to qualify. 4. Thus a student appears if at least one qualifying Korth-course A exists, C. Requiring all such courses would need a different universal/anti-existence/division construction.
Solution: The joins connect each student to their grade records and the corresponding courses. The filters retain records having grade A in a course taught by Korth. A student's name is produced whenever at least one such joined record exists, and DISTINCT removes duplicate names. There is no universal quantifier, division, or count comparison requiring all courses to qualify. The intended relational query therefore computes option C, names of students with an A in at least one course taught by Korth.
Three transactions act on D1,D2,D3. In chronological order the printed schedule is: R2(D3), R2(D2), W2(D2), R3(D2), R3(D3), R1(D1), W1(D1), W3(D2), W3(D3), R2(D1), R1(D2), W1(D2), W2(D1). Ri(D) and Wi(D) denote transaction Ti reading/writing D. Which is correct? A. Serializable as T2,T3,T1 B. Serializable as T2,T1,T3 C. Serializable as T3,T2,T1 D. Not serializable
Your answer
Answer & solution
Answer: D (no official key was published)
Step through it (15 steps)
1. On D1, T1 writes before T2 reads and writes, forcing edge T1→T2 in the conflict graph. 2. On D2, T2 writes before T3 reads/writes, forcing T2→T3; T3 writes before T1 reads/writes, forcing T3→T1. These edges already form T1→T2→T3→T1. 3. A directed cycle means no serial ordering can preserve all conflicts, so the schedule is not conflict-serializable. 4. Even view equivalence cannot rescue it: T2's D2 read is initial, T3 reads T2's D2 write, T1 reads T3's D2 write, and T2 reads T1's D1 write. Preserving these reads requires T2<T3<T1<T2, impossible. Therefore D holds even under the broader view-serializability interpretation.
Solution: On D1, T1 writes before T2 reads/writes, imposing T1→T2. On D2, T2 writes before T3 reads/writes, and T3 writes before T1 reads/writes, imposing T2→T3→T1. This cycle rules out conflict serializability, so D. It also rules out view serializability here: T2 reads the initial D2 value, T3 reads T2's D2 value, T1 reads T3's D2 value, and T2 reads T1's D1 value. Any view-equivalent serial order would need T2 before T3 before T1 before T2, which is impossible.
Relation R, with functional dependencies F, is decomposed into BCNF. How much redundancy caused by functional dependencies remains in the resulting relations? (A) Zero; (B) Positive, but less than in an equivalent 3NF decomposition; (C) Proportional to the size of F⁺; (D) Cannot be determined.
Your answer
Answer & solution
Answer: A (no official key was published)
Step 1: Identify the redundancy that BCNF targets.
Step 2: A dependency such as Department→Office repeats an office value across employee rows when Department is not a key. Decomposition can put that dependency in a relation where Department is a key, eliminating that particular repetition. BCNF applies this superkey condition to every nontrivial projected FD; it does not promise absence of multivalued or application-level redundancy.
Conclusion: BCNF requires the determinant of every nontrivial projected functional dependency to be a superkey. Therefore the usual within-relation redundancy caused by a nonkey determinant is eliminated, A. This claim is specifically about FD-based redundancy in the decomposed relations, not all possible redundancy or guaranteed dependency preservation.
Which comparison of expressive power is true for formal relational query languages? (A) Relational algebra is more powerful than relational calculus. (B) Relational algebra and relational calculus have equal power. (C) Relational algebra and safe relational calculus have equal power. (D) None of these.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Check the safety restriction in the equivalence statement.
Step 2: A safe query restricts its results to values justified by the finite database and query constants. An unrestricted formula such as “x is not in R” over an infinite ambient domain can return infinitely many values. Relational algebra cannot produce that infinite result from finite input relations, explaining why the safe-calculus qualifier selects C over the unrestricted claim.
Conclusion: The expressive-equivalence theorem relates relational algebra to safe/domain-independent relational calculus, C. An unrestricted calculus expression can describe an infinite or domain-dependent result, which ordinary relational algebra over finite input relations cannot produce.
Build a B⁺-tree index on STUDENT.Name. Each name occupies 8 bytes, a disk block holds 512 bytes, and an index pointer occupies 4 bytes. What is the best degree, defined as pointers per node? (A) 16; (B) 42; (C) 43; (D) 44.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Check the limiting integers explicitly.
Step 2: For43 pointers there are 42 keys, using 43×4+42×8=172+336=508 bytes, which fits 512. For44 pointers and 43 keys, storage is 176+344=520 bytes, which does not fit. Thus43 is the maximum under the stated layout;42 is unnecessarily conservative, and 16 leaves substantial unused space.
Conclusion: An internal node with m child pointers has m−1 separator keys. Its storage is 4m+8(m−1)=12m−8 bytes. Requiring this to fit 512 bytes gives m≤43⅓, so the largest integer fanout is 43, C. This uses the stated idealized node layout without extra header bytes;44 would need 520 bytes.
R is decomposed using functional dependencies F, and S using dependencies G. One decomposition is stated to be BCNF and the other 3NF, without identifying which. Given the closures of F and G, which test should be applied to guarantee identification? (A) Dependency preservation; (B) Lossless join; (C) BCNF definition; (D) 3NF definition.
Your answer
Answer & solution
Answer: C under the intended exclusive classification (no official key was published)
Step 1: Explain why the other tests do not identify the form.
Step 2: A lossless decomposition can be either BCNF or 3NF, and BCNF decomposition can fail to preserve dependencies. Testing only 3NF also fails because BCNF implies 3NF. The stronger BCNF determinant test directly determines whether any nontrivial dependency has a non-superkey left side. If both pass it, the original nonexclusive premise cannot distinguish them.
Conclusion: Test each resulting relation for every nontrivial projected dependency X→Y: X must be a superkey for BCNF. This direct definition gives C; neither dependency preservation nor losslessness distinguishes BCNF from 3NF in general, and every BCNF relation also satisfies 3NF. To identify exactly one decomposition, the premise must mean the other is 3NF but not BCNF. If it only says 3NF, both might be BCNF and no unique classification follows.
What a relation instance proves about dependencies
Functional Dependencies & Keys
Tap to enlarge
An instance of R(A,B,C) lists rows (1,1,1), (1,1,0), (2,3,2), (2,3,2), including the repeated displayed row. What can be concluded? (A) A functionally determines B, and B functionally determines C. (B) A functionally determines B, and B does not functionally determine C. (C) B does not functionally determine C. (D) A does not functionally determine B, and B does not functionally determine C.
Your answer
Answer & solution
Answer: C for schema-level inference (no official key was published)
Step 1: Use a counterexample to distinguish failure from confirmation.
Step 2: The two rows(1,1,1) and(1,1,0) agree on B but disagree on C, immediately witnessing failure of B→C. No displayed pair violates A→B, but an additional legal row(1,2,0) would violate it unless a schema constraint forbids that row. Observing the current sample cannot establish that prohibition. This is why schema inference selects C while instance-only testing supports the stronger conjunction B.
Conclusion: The rows with B=1 have different C values 1 and 0, disproving B→C for any schema constraint meant to hold on all legal instances containing this one. The displayed rows do satisfy A→B, but a single positive example cannot establish that dependency for all legal instances. Therefore the guaranteed schema conclusion is C. If the question instead asks only which dependencies hold on this particular instance, B’s conjunction is true too. The duplicate(2,3,2) row does not affect either observation.
Placement schema COMPANY(cname,clocation), STUDENT(srollno,sname,sdegree), INTERVIEW(cname,srollno,idate), OFFER(cname,srollno,osalary). Keys: cname; srollno; (cname,srollno) for each remaining relation. cname and clocation are company name and location; srollno, sname and sdegree are student roll number, name and degree program. Interviews record company/student/date; offers record salary for successful interviews. Original15(a)(i): Using only relational algebra join, selection, projection, union and difference, list roll numbers and names of students interviewed at least once but receiving no offer.
Answer & solution
Answer: π_{srollno,sname}(STUDENT ⋈ (π_{srollno}(INTERVIEW) − π_{srollno}(OFFER))) (no official key was published)
Let I=π_{srollno}(INTERVIEW) and O=π_{srollno}(OFFER). I−O contains exactly the students with at least one interview and no offer at all. Join this one-column relation to STUDENT on srollno and project srollno,sname: π_{srollno,sname}(STUDENT ⋈ (π_{srollno}(INTERVIEW) − π_{srollno}(OFFER))). Only the permitted join, projection and difference operators are needed. Relational-algebra projection removes duplicates, so repeated interviews do not repeat students.
Placement schema COMPANY(cname,clocation), STUDENT(srollno,sname,sdegree), INTERVIEW(cname,srollno,idate), OFFER(cname,srollno,osalary). Keys: cname; srollno; (cname,srollno) for each remaining relation. cname and clocation are company name and location; srollno, sname and sdegree are student roll number, name and degree program. Interviews record company/student/date; offers record salary for successful interviews. Original15(a)(ii): Using only join, selection, projection, union and difference, list roll numbers and names of interviewed students receiving an offer from every company that interviewed them.
Answer & solution
Answer: π_{srollno,sname}(STUDENT ⋈ (π_{srollno}(INTERVIEW) − π_{srollno}(π_{cname,srollno}(INTERVIEW) − π_{cname,srollno}(OFFER)))) (no official key was published)
First form the interviewed company–student pairs I=π_{cname,srollno}(INTERVIEW) and offered pairs O=π_{cname,srollno}(OFFER). The difference I−O contains precisely the interviews not followed by an offer from that same company. Its student projection is the disqualified set. Therefore: π_{srollno,sname}(STUDENT ⋈ (π_{srollno}(INTERVIEW) − π_{srollno}(I−O))). Expanding the abbreviations gives the expression in the derived answer, using only join, projection and difference. Starting with students who appear in INTERVIEW excludes students with no interviews, rather than admitting them by vacuous truth. Receiving some offer is insufficient: every interviewed company must be covered.
Placement schema COMPANY(cname,clocation), STUDENT(srollno,sname,sdegree), INTERVIEW(cname,srollno,idate), OFFER(cname,srollno,osalary). Keys: cname; srollno; (cname,srollno) for each remaining relation. cname and clocation are company name and location; srollno, sname and sdegree are student roll number, name and degree program. Interviews record company/student/date; offers record salary for successful interviews. Original15(b): Write SQL listing each degree program with more than five students offered jobs, together with the program name and average offered salary of its students.
Answer & solution
Answer: SELECT S.sdegree, AVG(O.osalary) AS avg_offered_salary FROM STUDENT S JOIN OFFER O ON O.srollno=S.srollno GROUP BY S.sdegree HAVING COUNT(DISTINCT S.srollno)>5; (no official key was published)
A query under the usual interpretation of average offered salary, averaging the offer records, is: SELECT S.sdegree, AVG(O.osalary) AS avg_offered_salary FROM STUDENT AS S JOIN OFFER AS O ON O.srollno=S.srollno GROUP BY S.sdegree HAVING COUNT(DISTINCT S.srollno)>5; The join associates each offer with its student's degree. COUNT(DISTINCT S.srollno) implements more than five students, not more than five offers: the composite OFFER key permits several companies to offer jobs to one student. AVG(O.osalary) averages the offered salary values within the degree group. No JOIN to INTERVIEW is needed, because OFFER already identifies successful candidates.
Lossless decomposition through a common determinant
Normalization & Decomposition
Tap to enlarge
R(L,M,N,O,P) has M→O,NO→P,P→L,L→MN and is decomposed into R1(L,M,N,P),R2(M,O). Original16(a): Is the decomposition lossless? Explain.
Answer & solution
Answer: Yes, the decomposition is lossless. (no official key was published)
Step through it (2 steps)
The source dependencies are M→O, NO→P, P→L, and L→MN. The components are R1(L,M,N,P) and R2(M,O), with intersection {M}. Since M→O, their intersection functionally determines all of R2. The binary lossless-join criterion therefore holds: (R1∩R2)→R2 is implied by the dependencies. Consequently joining the two projections of any legal instance recreates the original relation without spurious tuples.
R(L,M,N,O,P) has M→O,NO→P,P→L,L→MN and is decomposed into R1(L,M,N,P),R2(M,O). Original16(b): Is it dependency-preserving? If not, list dependencies not preserved.
Answer & solution
Answer: No; NO→P is not preserved. (no official key was published)
Step through it (4 steps)
M→O is enforceable within R2, and P→L and L→MN within R1. The projection onto R1 also contains MN→P: M supplies O, then NO→P applies. Nevertheless NO→P cannot be recovered from the union of the projected dependency sets. In R1 no nontrivial dependency has determinant contained in {N}, since N+ under the original set is just {N}; in R2, O alone likewise determines nothing new. Thus the closure of {N,O} under the projected dependencies remains {N,O}, and does not contain P. Of the given dependencies, precisely NO→P is lost. A concrete locally valid join illustrates the loss. Let R1 contain (L1,M1,n,P1) and (L2,M2,n,P2), with distinct Li,Mi,Pi, and let R2 contain (M1,o),(M2,o). Each component satisfies all its projected dependencies. Their join has the same (N,O)=(n,o) with different P values, violating NO→P.
R(L,M,N,O,P) has M→O,NO→P,P→L,L→MN and is decomposed into R1(L,M,N,P),R2(M,O). Original16(c): Determine the highest normal form of each decomposed relation.
Answer & solution
Answer: Both R1 and R2 are in BCNF. (no official key was published)
Step through it (2 parts)
For R1(L,M,N,P), the candidate keys are {L}, {P}, and {M,N}. L gives M,N and then P using M→O and NO→P; P gives L and hence the rest; MN gives O and then P,L. Any determinant containing L or P is therefore a superkey. A determinant containing neither is a subset of {M,N}; neither M nor N alone determines an additional R1 attribute, whereas MN is a key. Hence every nontrivial projected dependency has a superkey determinant, so R1 is BCNF. In R2(M,O), M is the key and the only essential nontrivial dependency is M→O, so R2 is also BCNF. This does not imply dependency preservation; the lost NO→P constraint still requires checking across components.
Original17(a): Fill Constant or Variable in four search-time cells: X1 successful B-tree, X2 unsuccessful B-tree, X3 successful B+tree, X4 unsuccessful B+tree. Constant means independent of which key is sought in a fixed tree, not asymptotically O(1); Variable means depending on that key. Successful means the key exists; unsuccessful means it is absent.
Answer & solution
Answer: X1=Variable; X2=Constant; X3=Constant; X4=Constant. (no official key was published)
Interpret search time as the number of tree levels or disk pages visited in a fixed tree, with record retrieval in a B+ tree proceeding to its leaf. A successful B-tree search may stop at the root, an internal node, or a leaf, depending on where its key resides; X1 is Variable. An unsuccessful B-tree search reaches a leaf, and all leaves have equal depth, so X2 is Constant. B+ tree records are located at leaves, so both successful and unsuccessful record searches traverse the fixed-height root-to-leaf path; X3 and X4 are Constant. Here Constant means independent of which key is searched in that tree, not O(1) as the database grows.
R(A,B)={(1,2),(2,3),(2,4),(4,5),(6,7),(6,8),(9,10)}. View V is SELECT R1.A,R2.B FROM R R1,R R2 WHERE R1.B=R2.A. Original17(b)(i): Find the current contents of V.
Answer & solution
Answer: V={(1,3),(1,4),(2,5)}. (no official key was published)
The view combines a tuple (u,v) in the first copy of R with a tuple (v,w) in the second and returns (u,w), so it enumerates two-edge paths. For R={(1,2),(2,3),(2,4),(4,5),(6,7),(6,8),(9,10)}, the paths 1→2→3 and 1→2→4 yield (1,3),(1,4), while 2→4→5 yields (2,5). No other second component matches a first component. Thus V contains exactly those three tuples. They are distinct, so SQL bag semantics and set semantics give the same contents for this instance.
Incremental self-join view after two inserted tuples
SQL & Queries
Tap to enlarge
R(A,B)={(1,2),(2,3),(2,4),(4,5),(6,7),(6,8),(9,10)}. View V is SELECT R1.A,R2.B FROM R R1,R R2 WHERE R1.B=R2.A. Original17(b)(ii): Insert(2,11),(11,6) into R. Which additional tuples enter V?
Answer & solution
Answer: Additional tuples: {(1,11),(2,6),(11,7),(11,8)}. (no official key was published)
Let ΔR={(2,11),(11,6)}. A newly created length-two path must use at least one new edge, so inspect R⋈ΔR, ΔR⋈R, and ΔR⋈ΔR. The existing edge 1→2 followed by 2→11 adds (1,11). The new edge 11→6 followed by existing 6→7 or 6→8 adds (11,7),(11,8). The two new edges together form 2→11→6 and add (2,6). These four tuples are the additions; the original three remain. Longer paths such as 1→2→11→6 do not qualify, because this view joins exactly two copies of R rather than taking a transitive closure.
Relation R(A,B,C,D) has dependencies A→B and C→D and is decomposed into AB and CD. Classify the decomposition as dependency-preserving or not and lossless or not.
Your answer
Answer & solution
Answer: C (no official key was published)
Step through it (3 steps)
Step 1: A→B can be checked entirely in R1(AB), and C→D entirely in R2(CD). Thus the decomposition preserves both supplied dependencies.
Step 2: The two schemas have empty intersection. Their natural join is a Cartesian product, which can create spurious combinations. For instance tuples(a1,b1,c1,d1) and(a2,b2,c2,d2) satisfy the dependencies, but joining their projections also creates(a1,b1,c2,d2) and(a2,b2,c1,d1).
Hence the decomposition is dependency-preserving but not guaranteed lossless, C.
Given an adjacency relation Adj(X,Y), which query cannot be expressed by a fixed-length ordinary relational-algebra expression: neighbors of a vertex, vertices with self-loops, vertices in cycles with fewer than three vertices, or all vertices reachable from a vertex?
Your answer
Answer & solution
Answer: D (no official key was published)
Step 1: Adjacency and self-loops require selection/projection on Adj. A cycle of a fixed bounded length can be described by a fixed number of renamed joins and equality tests.
Step 2: Reachability permits paths of arbitrarily large length as the graph grows. Ordinary nonrecursive relational algebra has no transitive-closure operation; one fixed expression cannot supply an unbounded chain of joins.
Thus D cannot be expressed by a constant-length ordinary relational-algebra expression over all finite input graphs. Recursive query extensions or a fixed maximum graph size change that setting.
For relations r and s with A an attribute of r, simplify σ_(A=a)(r⋈s). Choices are σ_(A=a)(r), r, σ_(A=a)(r)⋈s, or none.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: The predicate A=a refers only to an attribute of r. A joined tuple survives the selection exactly when its r component has that value.
Step 2: Rejecting the failing r tuples before joining therefore removes exactly the same joined tuples: σ_(A=a)(r⋈s)=σ_(A=a)(r)⋈s. This is C.
Dropping s altogether can lose its attributes and its filtering effect, so neither r nor its selected subset alone is generally equal to the joined result.
Which FD set on R(A,B,C,D) does not admit a lossless, dependency-preserving BCNF decomposition? A: A→B,B→CD. B: A→B,B→C,C→D. C: AB→C,C→AD. D: A→BCD.
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: For option C, AB→C and C→AD imply AB and BC are keys. Yet C alone does not determine B, so C→A and C→D violate BCNF. Decomposition into CAD and BC is lossless because their intersection C determines CAD, but it loses local enforcement of AB→C.
Step 2: Any relation containing A,B,C is not BCNF: it retains C→A while C is not a key. Without such a relation, projected dependencies cannot derive C from AB; no proper smaller attribute subset provides that dependency. Thus no dependency-preserving BCNF decomposition exists.
The other options admit lossless preserving choices: AB and BCD for A; AB,BC,CD for B; and the original already-BCNF relation for D. Hence C.
Which tuple-calculus expression is unsafe? A binds t[A] to an R1 value absent from R2. B says for every u∈R1, u[A]=constant x implies some s∈R2 has t[A]=s[A] and s[A]=u[A]. C is {t:¬(t∈R1)}. D binds t[A] to values present in both relations. Examine empty/unguarded cases as well as the obvious complement; exact formulas remain linked.
Your answer
Answer & solution
Answer: C is unsafe; B is also unsafe as literally printed (no official key was published)
Step 1: C returns all tuples outside R1. Over an unrestricted infinite domain and finite R1, this produces an unbounded complement, so it is unsafe. A and D bind the returned A-value to existing relation values, under the intended one-attribute result interpretation.
Step 2: B universally quantifies u in R1 and guards the existential restriction on t with u[A]=the constant x. If R1 is empty, or contains no tuple with that A-value, every implication is vacuously true. Then t is unconstrained and arbitrary outside-domain values satisfy the expression. Thus B is also not domain-independent.
This is a literal second-unsafe-option issue confirmed in the paper, not an official-key correction. Adding an existence requirement for the guarded R1 value would change the question.
Recursive deletion through a self-referencing foreign key
Database Models, Architecture & ER Diagrams
Tap to enlarge
Table geq has nonnull integer lb,ub, primary key lb, and self-referencing foreign key ub with ON DELETE CASCADE. Every row(x,y) obeys y≥x. On deleting(x,y), can a cascaded row(z,w) have z>y, z>x, or w<x, or must deletion be prohibited?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Deleting parent key x directly cascades to rows(z,w) with w=x. Since every row obeys w≥z, these direct children have z≤x. Cascades continue to their children, so keys along a deletion chain cannot increase. Options requiring z>x or z>y≥x are therefore impossible.
Step 2: A deeper descendant can have w<x. For example the legal rows(3,3),(2,3),(1,2) satisfy the ordering and foreign key. Deleting(3,3) cascades to(2,3) and then(1,2), whose upper value 2 is less than the original x=3.
Thus C is possible. ON DELETE CASCADE means the mere presence of dependent rows does not prohibit the deletion; self-reference is handled by the database’s cascade semantics.
examinee(regno,name,score), with primary key regno. Use projection, selection, renaming and Cartesian product to find names appearing in multiple tuples.
Answer & solution
Answer: π_X.name σ_(X.name=Y.name ∧ X.regno≠Y.regno)(ρ_X(examinee) × ρ_Y(examinee)). (no official key was published)
Rename the relation twice so the two tuple occurrences are distinguishable: X=ρ_X(examinee), Y=ρ_Y(examinee). Form X×Y, retain equal names but different registration numbers, then project the name.
π_X.name(σ_(X.name=Y.name AND X.regno≠Y.regno)(X×Y)).
The equal-name condition identifies candidates; the unequal-key condition ensures two different examinees rather than pairing a row with itself. Because regno is a key, different regno values mean different rows. Standard relational algebra has set semantics, so projection returns each repeated name once even if it has many matching pairs. Example: (1,Asha,70),(2,Asha,80),(3,Bela,90) returns only Asha. Without the unequal-key predicate every name would incorrectly qualify.
examinee(regno,name,score), where regno is a primary key and score is real. List registration numbers with score above the relation-wide average.
Answer & solution
Answer: SELECT regno FROM examinee WHERE score > (SELECT AVG(score) FROM examinee); (no official key was published)
Use an uncorrelated scalar subquery to compute one average over all examinees:
SELECT e.regno FROM examinee AS e WHERE e.score > (SELECT AVG(x.score) FROM examinee AS x);
The outer query compares each score with the same global average. Strict > excludes scores exactly equal to that average. No GROUP BY is needed because the intended comparison is to the whole relation, not a separate average per person or centre. The primary key ensures no duplicate registration number in the result. In SQL, AVG ignores NULL scores and comparison with NULL is unknown, so NULL-score rows do not qualify; the stated mathematical real-number model normally excludes this extra case.
examinee(regno,name,score) and appears(regno,centr_code). List centre codes having an examinee whose score exceeds 80.
Answer & solution
Answer: SELECT DISTINCT a.centr_code FROM appears a JOIN examinee e ON e.regno=a.regno WHERE e.score>80; (no official key was published)
Join each appearance to its examinee using the shared registration number, keep scores strictly greater than 80, then project distinct centre codes:
SELECT DISTINCT a.centr_code FROM appears AS a JOIN examinee AS e ON e.regno = a.regno WHERE e.score > 80;
DISTINCT is important because several high-scoring examinees can share a centre. This is an existential requirement: one qualifying examinee is sufficient. It is not a condition on centre average, and it does not require every examinee at that centre to exceed 80. An equivalent SQL formulation selects DISTINCT centre codes from appears a WHERE EXISTS (SELECT 1 FROM examinee e WHERE e.regno=a.regno AND e.score>80).
Why prefer B+-trees to binary trees for disk-resident databases: larger disk capacity, much slower disk access than memory, lower transfer rate alone, or greater disk reliability?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: A B+-tree node can fill a disk page and contain many keys and child pointers. Its high fanout sharply reduces the number of levels compared with a binary tree holding a similar number of keys.
Step 2: A search typically needs one page access per level, so reducing height reduces expensive random disk accesses. The latency difference between disk and memory is the decisive reason, B.
Capacity and reliability do not by themselves explain this branching-factor advantage; transfer rate is distinct from the random-access cost being minimized.
Given employee(name,salary,deptno) and department(deptno,deptname,address), which cannot be expressed with basic selection,projection,product,join,union,intersection,difference: department addresses, matching employee/department names, total salaries, or employees of a department?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: Joining on deptno and projecting yields each employee’s department address. Selection can compare name with deptname or filter a particular department.
Step 2: Summing salaries across arbitrarily many tuples requires aggregation and produces a new arithmetic value. The listed basic relational-algebra operators select/combine existing tuple values but contain no aggregate-sum operation.
Therefore total salaries, C, needs an extended algebra or SQL aggregation.
Rows(X,Y,Z) are(1,4,2),(1,5,3),(1,6,3),(3,2,2). Which pair holds: XY→Z and Z→Y; YZ→X and Y→Z; YZ→X and X→Z; XZ→Y and Y→X?
Your answer
Answer & solution
Answer: B (no official key was published)
Step 1: Every Y value in the four rows is distinct. Hence Y uniquely identifies the entire row in this instance, so Y→Z and Y→X hold. Adding Z to Y cannot destroy uniqueness, so YZ→X also holds.
Step 2: Z→Y fails because Z=2 occurs with Y=4 and 2. X→Z fails because X=1 occurs with Z=2 and 3. XZ→Y fails because(X,Z)=(1,3) occurs with Y=5 and 6.
Thus only the conjunction in B holds. These are instance-level observations, not an inference that the same FDs constrain every possible future instance.
For r(w,x) and s(y,z), when is SELECT DISTINCT w,x FROM r,s guaranteed equal to r? Options: r duplicate-free and s nonempty; both duplicate-free; s duplicate-free and r nonempty; equal tuple counts.
Your answer
Answer & solution
Answer: A (no official key was published)
Step 1: FROM r,s creates a Cartesian product. If s is nonempty, every row of r appears at least once in that product; projection onto w,x and DISTINCT then returns exactly the distinct rows of r.
Step 2: To preserve SQL bag multiplicities as well, r itself must have no duplicates. No duplicate restriction on s is needed because DISTINCT removes replication.
Hence A. If s is empty, the result is empty even for nonempty r. If r has duplicates, DISTINCT changes it. The other listed conditions do not rule out these failures.
Suppose every comparison involving NULL returns FALSE rather than UNKNOWN. Which pair ceases to be equivalent: x=5 versus NOT NOT(x=5); x=5 versus x>4 AND x<6 for integer x; x≠5 versus NOT(x=5); or none?
Your answer
Answer & solution
Answer: C (no official key was published)
Step 1: For an ordinary nonnull x, inequality x≠5 agrees with negated equality. But at x=NULL, the stipulated direct comparison x≠5 is FALSE, while x=5 is FALSE and its negation is TRUE. Thus C differs.
Step 2: Double negation still restores the original Boolean value, so A remains equivalent. In B, both comparisons on NULL are FALSE, making the conjunction FALSE just like equality; for nonnull integers the open interval(4,6) contains only 5.
Therefore only C among these pairs exposes the inconsistency. Standard SQL uses UNKNOWN precisely to avoid treating a negated unknown comparison as true.
An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 6, without intermediate diagrams.
Answer & solution
Answer: Root [4]; linked leaves [1,2,3] → [4,5,6]. (no official key was published)
The requested final tree is:
[4]
/ ╲
[1 2 3] → [4 5 6]
The first five keys fit in the single root-leaf. Inserting 6 overflows its capacity to six keys, so divide its sorted entries evenly into [1,2,3] and [4,5,6]. Create an internal root with separator 4, the minimum of the right child. A search for a key below 4 chooses the left child and a search for 4 or greater chooses the right. Because this is a B+-tree, copying 4 to the parent does not remove 4 from the leaf. The arrow denotes the leaf-level successor link. The stem does not define its separator convention; a max-left convention can instead display root[3] with the same leaves. Here and in subsequent parts the minimum-of-right convention is fixed explicitly.
An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Show the tree after inserting 1 through 10, without intermediate diagrams.
Answer & solution
Answer: Root [4,7]; linked leaves [1,2,3] → [4,5,6] → [7,8,9,10]. (no official key was published)
The requested tree is:
[4 | 7]
/ | ╲
[1 2 3] → [4 5 6] → [7 8 9 10]
After the first split, increasing keys always enter the rightmost leaf. That leaf fills with 4,5,6,7,8 and overflows on 9. Splitting its six keys yields [4,5,6] and [7,8,9]; copy 7 into the existing root. The root now has two separators and three child pointers, well within its five-key capacity, so it does not split. Insert 10 into the rightmost leaf to get [7,8,9,10]. The first leaf remains [1,2,3]. Separators4 and 7 remain present in their respective data leaves. Under a max-left separator convention the same leaf layout can be shown with root[3,6]; the answer above uses the stated minimum-of-right convention throughout.
An initially empty B+-tree allows up to 5 keys per leaf and up to 5 separator keys per internal node. Insert distinct keys in increasing order. Use standard overflow splitting: a sixth leaf key yields two 3-key leaves, and copy the right leaf minimum into the parent; leaf data keys stay in leaves. Modify insertion: before splitting an overflowing/full target, move one value to its left sibling if that sibling exists and has room; otherwise split. Show the tree after inserting 1 through 9.
Answer & solution
Answer: Root [5]; leaves [1,2,3,4] → [5,6,7,8,9]. (no official key was published)
The final tree under the stated overflow-split convention is:
[5]
/ ╲
[1 2 3 4] → [5 6 7 8 9]
At the first overflow there is no left sibling, so the first six keys split as usual into [1,2,3] and [4,5,6]. Increasing insertions fill the right leaf through 8. To accommodate 9, that target leaf would contain [4,5,6,7,8,9], but the left sibling has spare capacity. Move its smallest key4 to the left sibling, and keep [5,6,7,8,9] on the right. Moving the smallest, rather than the largest, preserves the global leaf ordering. Update the parent separator from 4 to 5 because the right leaf’s minimum changed. No new leaf is needed. Equivalently one can redistribute4 just before inserting 9 into the full right leaf. Do not split again merely because the right leaf has five entries: five is its legal maximum; the sixth causes overflow. Separator conventions and split timing must be consistent with part(a).
A B+-tree leaf holds at most m keys. Insert a long increasing sequence using ordinary balanced splits on overflow. What is the approximate average number of keys per leaf?
Answer & solution
Answer: Approximately m/2; more precisely the frozen left split size, usually floor((m+1)/2), up to rounding and a boundary leaf. (no official key was published)
All new larger keys enter the rightmost leaf. When it overflows with m+1 keys, a balanced split leaves about half in the old left leaf and half in a new rightmost leaf. The old left leaf will never receive another key during an increasing insertion sequence. Repeating this process freezes nearly every completed leaf at its half-full split occupancy. Only the final rightmost leaf varies between its initial split size and m, and its contribution to the average vanishes as the number of leaves grows. Therefore the average is approximately m/2, not the roughly 69% occupancy sometimes quoted for random insertions. If the convention gives the left leaf floor((m+1)/2) keys, the limiting average is that integer. For m=5 and a3+3 split this is exactly 3 in the limit. Rounding and the choice of which side gets an extra key for even m explain why the question asks approximately.
A B+-tree leaf holds at most m keys. Insert a long increasing sequence, moving a key to the left sibling before splitting whenever that sibling has room. Estimate average leaf occupancy.
Answer & solution
Answer: Approximately m keys per leaf, approaching full occupancy. (no official key was published)
New keys continue to enter the rightmost leaf. Whenever it overflows, move its smallest key into its left sibling if possible. Repeated overflows progressively fill that left sibling to m entries. Only once that sibling is full must the rightmost leaf split; at that moment the earlier leaves are already full and will receive no more keys. After a split the two rightmost leaves can be partly full, but later insertions fill the older of them by redistribution. Consequently all except at most the final two leaves are full. If there are L leaves, their combined deficit from Lm keys is O(m), independent of L, so average occupancy is m−O(m/L) and tends to m as L grows. This is the improvement over ordinary splitting’s approximately half-full completed leaves for monotone input. Parent separator updates are essential for correctness but do not change the leaf occupancy calculation.
Bank relation transaction(transno,acctno,date,amount) stores positive deposits and negative withdrawals. TP must contain (acctno,T1.date,T2.amount) for every pair of transactions on the same account with T2.date<=T1.date. Define TP in SQL.
Answer & solution
Answer: Self-join by equal account and T2.date<=T1.date, without DISTINCT. (no official key was published)
One SQL definition is
CREATE VIEW TP (acctno, txn_date, amount) AS
SELECT T1.acctno, T1.date, T2.amount
FROM transaction AS T1
JOIN transaction AS T2
ON T1.acctno = T2.acctno
AND T2.date <= T1.date;
Here T1 chooses a balance-observation date and T2 chooses one transaction contributing to that balance. Include equality so the transaction on the observation date contributes; using < would produce the balance before, rather than after, that transaction and omit the first date’s self-pair. Each qualifying transaction pair contributes a row. Do not add DISTINCT: SQL’s bag semantics deliberately preserve separate same-amount transactions even though the projected triples may be identical. For example two deposits of 100 on different days generate two copies of (account,later_date,100), both of which must be summed. transaction and date can be reserved identifiers in some SQL dialects; quote the existing identifiers with that dialect’s supported delimiters if needed.
Bank relation transaction(transno,acctno,date,amount) stores positive deposits and negative withdrawals. TP must contain (acctno,T1.date,T2.amount) for every pair of transactions on the same account with T2.date<=T1.date. Using only TP, create intermediate view V and query each account’s minimum balance after a transaction, excluding the initial zero. At most one transaction per account per day; each account has at least one transaction.
Answer & solution
Answer: V sums amounts by account and observation date; final query takes MIN(balance) by account. (no official key was published)
Use two aggregation levels: CREATE VIEW V (acctno, txn_date, balance) AS SELECT acctno, txn_date, SUM(amount) FROM TP GROUP BY acctno, txn_date;
SELECT acctno, MIN(balance) AS minbalance FROM V GROUP BY acctno; For a fixed account and T1 date, TP has one amount row for every transaction up to and including that date. SUM therefore gives the cumulative balance immediately after the transaction, assuming the opening balance is zero as specified. The one-transaction-per-account-per-day condition ensures each observation date has one T1 row, avoiding repeated copies of the entire prefix caused by multiple T1 transactions on the same day. Taking MIN over these cumulative balances returns the lowest post-transaction balance, including negative balances when appropriate. There is no row for account creation, so the initial zero is not accidentally included; a positive-only account correctly returns its first positive balance rather than zero. An account with amounts 100,100,−250 has balances 100,200,−50 and minimum−50. DISTINCT in TP would collapse the two 100 entries at the later dates and corrupt these sums. Distinct dates, not distinct amounts, define observation groups. Non-null numeric amounts and a comparable chronological date type are implicit in the bank model.
Relations R,S have m,n tuples. What are the maximum and minimum possible sizes of their join?
Your answer
Answer & solution
Answer: B: mn and 0 (no official key was published)
A join selects qualifying pairs from R×S, which contains mn pairs. Therefore it cannot exceed mn. This upper bound occurs when every pair satisfies the join predicate. The minimum zero occurs when no pair satisfies it. Hence B gives the general possible extremes. This reasoning assumes an ordinary inner join with a condition that can permit or reject pairs. A fixed natural join on disjoint schemas is always the Cartesian product, so its minimum would not be zero for positive m,n; the question is the usual unrestricted join-bound comparison.
Translate {t | t∈r and t[A]=10 and t[B]=20}. Options combine the two selections by OR/union, intersection, or difference.
Your answer
Answer & solution
Answer: C (no official key was published)
The tuple must satisfy both tests simultaneously. Selection on A=10 retains the first qualifying subset, and selection on B=20 retains the second. Their intersection contains exactly tuples passing both, so σ(A=10)(r)∩σ(B=20)(r) is equivalent, C. Union or a disjunctive predicate would admit a tuple satisfying only one test. Difference would keep the first test while rejecting the second, which reverses the required conjunction.
R(A,B,C,D,E,F) has C→F,E→A,EC→D,A→B. Choose a key from CD,EC,AE,AC.
Your answer
Answer & solution
Answer: B: EC (no official key was published)
Step through it (2 steps)
Start the closure of EC with E,C. E→A adds A; A→B adds B; C→F adds F; and EC→D adds D. Thus (EC)+ contains every attribute, so EC is a superkey. Neither E nor C occurs on a right-hand side, so neither can be obtained from other attributes; every key must contain both. Therefore EC is also minimal, a candidate key, and B is correct. Each other listed pair is missing E or C.
Which comparison is correct: disk versus RAM exclusivity, faster B+-tree range queries, primary versus secondary exclusivity, or height independent of record count?
Your answer
Answer & solution
Answer: B (no official key was published)
B+-trees store the data entries at the leaf level and typically link those leaves in key order. After locating a range’s first entry, scanning successive leaves retrieves the remainder efficiently without repeated searches through internal nodes. This is the conventional range-query advantage in B. Both structures may be disk resident and can support different index roles, so A and C are false dichotomies. Height still increases with record count at a fixed fanout, making D false. The comparison assumes the standard linked-leaf B+-tree layout.
Schedule: r1(A),r2(B),w1(A),r2(A),w2(A),w2(B),r1(B),w1(B). Is it serializable and/or possible under two-phase locking?
Select all that apply
Answer & solution
Answer: D: neither (no official key was published)
Step through it (10 steps)
The A conflicts put transaction 1 before transaction 2: w1(A) precedes r2(A) and w2(A). The B conflicts put transaction 2 before transaction 1: w2(B) precedes r1(B) and w1(B). Hence the precedence graph has a directed cycle. It is not conflict serializable; even view equivalence fails because T2 reads A from T1 while T1 reads B from T2, requiring opposite serial orders. Two-phase locking guarantees conflict serializability, so it cannot produce this completed schedule. Thus D.
R(S,T,U,V) has S→T,T→U,U→V,V→S and is decomposed into R1,R2. Determine whether the components satisfy 2NF and 3NF.
Select all that apply
Answer & solution
Answer: D: both (no official key was published)
By following the dependency cycle, each single attribute determines all four. Consequently, in any projected component, every individual attribute determines all attributes of that component and is a key. Every nontrivial projected FD therefore has a superkey determinant, so each component is in BCNF, hence also 3NF and 2NF. Thus D. This normal-form argument does not depend on whether the components intersect. The reproductions differ on that intersection symbol; normal form alone does not establish lossless decomposition.
Which is correct: queries automatically remove duplicates; queries require indexes; column names may repeat within the same relation; none?
Select all that apply
Answer & solution
Answer: D under the base-table reading (no official key was published)
Ordinary SELECT uses bag semantics; DISTINCT is needed when duplicate elimination is desired, so A is false. Indexes improve access paths but table scans execute queries without them, so B is false. A base table schema requires distinct column names within that table, so C is false in the stated relation-schema sense. Hence D. Different tables may share names and qualified references disambiguate them; some query result displays may also contain repeated labels, which is not the same as a valid base relation definition.
EMP(Employee-no, Dept-no, Employee-name, Salary), DEPT(Dept-no, Dept-name, Location). Return employee names whose department is located at Calcutta and salary exceeds Rs.50,000.
Answer & solution
Answer: Join EMP to DEPT and filter Location=Calcutta and Salary>50000. (no official key was published)
Use the common department identifier to join each employee to their department, then apply both predicates:
SELECT e."Employee-name"
FROM EMP AS e
JOIN DEPT AS d ON d."Dept-no" = e."Dept-no"
WHERE d.Location = 'Calcutta'
AND e.Salary > 50000;
The double quotes are standard SQL identifier quoting, required here because the printed attribute names contain hyphens. A database schema using Employee_name and Dept_no may use those unquoted names instead. The inequality is strict: salary exactly 50000 does not qualify. The department join is essential because Location belongs to DEPT, not EMP. This returns one row per matching employee under the usual department-key assumption; two employees sharing a name may produce duplicate name values. Add DISTINCT only if the intended output is a set of distinct names rather than names per employee. SQL NULL salaries do not pass the comparison.
EMP(Employee-no, Dept-no, Employee-name, Salary), DEPT(Dept-no, Dept-name, Location). For each department number, count employees whose salary exceeds Rs.1,00,000.
Answer & solution
Answer: LEFT JOIN all departments to qualifying employees and count the matching employee department values, including zeros. (no official key was published)
To interpret “for each department” literally, start from DEPT so that departments with zero qualifying employees are retained:
SELECT d."Dept-no", COUNT(e."Dept-no") AS high_salary_count
FROM DEPT AS d
LEFT JOIN EMP AS e
ON e."Dept-no" = d."Dept-no"
AND e.Salary > 100000
GROUP BY d."Dept-no";
The salary condition belongs in ON: placing it in WHERE would discard the null-extended rows and remove zero-count departments. COUNT(e."Dept-no") counts only actual matches, since a matched equality implies a non-null employee department value; COUNT(*) would incorrectly count the null-extended row as one. Salaries equal to 100000 do not qualify. This assumes the conventional unique department number in DEPT. If the expected interpretation asks only for department numbers represented by qualifying employees, the shorter traditional query is: SELECT "Dept-no", COUNT(*) AS high_salary_count FROM EMP WHERE Salary > 100000 GROUP BY "Dept-no"; That version omits zero-count departments. It is a different coverage choice, so the all-department query is preferable for the literal wording. Attribute names are quoted to preserve the printed hyphens.
For union-compatible R1(A, B), R2(C, D), interpret R1 join on A=C and B=D R2. Choices include union, product, difference, intersection.
Your answer
Answer & solution
Answer: D after projecting duplicate columns; raw theta join has four attributes (no official key was published)
A qualifying pair contains the same two values in both input relations. Thus each output is (a, b, a, b), one for each common tuple (a, b). Projecting onto A, B gives the intersection R1∩R2 after renaming, explaining D. But an ordinary theta join retains all four attributes A, B, C, D, whereas intersection has only two. They are not literally equal schemas without projection or a duplicate-column-eliminating join convention. This arity distinction is recorded rather than silently identifying the raw four-column relation with the two-column intersection.
Which normal form is conventionally adequate for ordinary relational design:2NF, 5NF, 4NF, 3NF?
Your answer
Answer & solution
Answer: D (no official key was published)
Third normal form addresses dependencies of nonkey attributes that produce common update anomalies while permitting dependency-preserving, lossless decompositions. It is therefore the conventional general design target among these choices, D. Second normal form only removes partial dependence on composite keys and can leave transitive problems. Fourth and fifth normal forms address additional multivalued or join dependencies and may be necessary for particular schemas, but are not implied as the routine minimum by the question.
Records 1–5 are Rama 27CON A, Abdul 22ENG A, Jennifer 28DOC B, Maya 32SER D, Dav 24MUS C. Index pointers are 1, 3, 2, 5, 4. Which field is sorted?
Your answer
Answer & solution
Answer: C: occupation (no official key was published)
Read occupations in pointer order: CON, DOC, ENG, MUS, SER. They are alphabetically increasing, so the index is on occupation. Ages in that order are 27, 28, 22, 24, 32 and are not sorted. Names start Rama, Jennifer, Abdul and likewise are not alphabetical; categories are A, B, A, C, D, also not ordered. Thus C is the matching field. The pointer sequence denotes record positions, not the index-key values themselves.
Which rewrite is not generally valid? A commuting selections; B moving a well-defined selection before projection; C distributing selection over union; D moving selection after projection without retaining predicate attributes.
Your answer
Answer & solution
Answer: D (no official key was published)
Selections commute because both predicates must hold, and selection distributes over union tuple by tuple. If selection after projection is already well typed, all predicate attributes survived, so pushing it down is safe. In the reverse direction, projecting first may delete an attribute needed by the predicate. For R(A, B), πA(σB=1(R)) is defined, but σB=1(πA(R)) is not. Thus D is not an unrestricted rule. Enlarged the paper B shows its right outer operator as σ with attribute subscript A 1 rather than a projection π, another literal typing defect; the coherent projection rule analyzed above is an explicitly stated reconstruction, not a silent transcription.
Signed four-digit values are stored as character strings or integers. Choose reduction 80%, 20%, 60%, 40%.
Your answer
Answer & solution
Answer: C: 60% under 5-byte text and 16-bit integer conventions (no official key was published)
A sign plus four decimal characters uses 5 bytes with one byte per character. Values from−9999 to 9999 fit in a 16-bit signed integer, using 2 bytes. The saving is 5−2=3 bytes, or 3/5·100%=60%, C. This assumes a fixed sign character and no text terminator or length metadata. A 32-bit integer would save only 20% under the same text layout, while other encodings change the comparison. Therefore the supplied result depends on the conventional storage widths rather than the numeric domain alone.
Given FREQUENTS(student,parlor), SERVES(parlor,ice_cream), and LIKES(student,ice_cream), print students who frequent at least one parlor serving at least one ice cream they like. Each student likes an ice cream and frequents a parlor.
Answer & solution
Answer: Join FREQUENTS to SERVES by parlor and LIKES by both student and ice cream; select distinct students. (no official key was published)
A qualifying student needs one witness consisting of a frequented parlor and a flavor both served there and liked by that same student. Match those three facts with a join:
SELECT DISTINCT f.student
FROM FREQUENTS AS f
JOIN SERVES AS s
ON s.parlor = f.parlor
JOIN LIKES AS l
ON l.student = f.student
AND l.ice_cream = s.ice_cream;
The schema spells the attribute as “ice-cream”; ice_cream above is a SQL-friendly identifier for that same field. If the actual schema uses a hyphen, use the database's identifier quoting, for example l."ice-cream" in standard SQL. The query assumes the ordinary relational model with non-NULL identifying values.
The first join enumerates flavors served at every parlor a student frequents. The second retains only flavors liked by that student. Both equalities in the second join matter: omitting the student equality would incorrectly let somebody else's preference qualify the student. DISTINCT prints each qualifying student once even if several parlors or flavors witness qualification.
For example, if Ada frequents P, P serves vanilla, and Ada likes vanilla, the triple survives. If Bob also frequents P but only likes chocolate, Bob does not survive unless P serves chocolate as well. The request is existential, so it needs neither relational division nor a test that every frequented parlor serves every liked flavor. The assumptions that students have some likes and visits do not by themselves imply qualification.
Relation(Book-id,Subject-Category,Author-Name,Author-Nationality) has Book-id primary key. What is its highest normal form?
Answer & solution
Answer: 2NF under intended Author-Name→Nationality; key alone does not establish that dependency. (no official key was published)
Under the usual semantic assumption that an author name uniquely identifies one author with one nationality, the dependencies include Book-id→all attributes and Author-Name→Author-Nationality. The key is a single attribute, so there is no nonempty proper subset of it on which a nonprime attribute can partially depend. With atomic values, this gives 2NF in the conventional setting.
However Author-Name is not a superkey when an author can write several books, and Author-Nationality is nonprime. The dependency Author-Name→Author-Nationality therefore violates 3NF, and also BCNF. Thus the intended highest form is 2NF.
The premise formally states only the primary key, not all functional dependencies or candidate keys. If the only nontrivial dependencies were those forced by Book-id, the relation would be BCNF instead. Names need not uniquely identify authors in a real database, and multiple nationalities may require a separate modeling choice. Hence 2NF is a conditional semantic answer, not a theorem from the primary-key declaration alone. Constant-valued attributes with empty determinants would introduce additional exceptional dependencies not assumed by the textbook model.
Add Book-title and Author-address to the preceding book relation, with primary key(Author-Name,Book-title). What is its highest normal form?
Answer & solution
Answer: 1NF under intended author→nationality,address dependencies; otherwise underdetermined. (no official key was published)
Assume all values are atomic and that each author identifier determines one nationality and one address. The declared key is now K={Author-Name,Book-title}, but the nonprime attributes Author-Nationality and Author-address depend on Author-Name alone, a proper subset of K. These are partial dependencies, violating 2NF. The intended highest normal form is therefore 1NF.
The contrast with part (a) is important: the same author dependency was transitive from a one-attribute book key there, but becomes partial when author is itself one component of the composite key. A decomposition into Author(Author-Name,Nationality,Address) and Book(Author-Name,Book-title,...) removes that particular partial dependency, subject to the remaining domain dependencies.
As before, the key declaration alone does not logically imply the semantic FDs. Author homonyms, multiple addresses or other candidate keys change the analysis. If no such non-key dependencies are imposed, one cannot infer a 2NF violation solely from the displayed attribute names. The conditional answer and its assumptions are retained because no official original/key has been verified.
COURSES(Cno,name), PRE-REQ(Cno,pre-Cno), COMPLETED(student-no,Cno). Use relational algebra to list courses for which student 2310 has completed every prerequisite.
Answer & solution
Answer: Return courses minus those with a missing prerequisite, including courses having no prerequisites. (no official key was published)
First collect completed course numbers for the selected student and rename the attribute to match the prerequisite column: D=ρ_(pre-Cno←Cno)(π_Cno(σ_(student-no=2310)(COMPLETED))). Let P=PRE-REQ. A natural join P⋈D contains exactly those prerequisite pairs whose prerequisite was completed. Hence Missing=P−(P⋈D) contains pairs identifying at least one uncompleted prerequisite. Project these to obtain Bad=π_Cno(Missing).
Let All=π_Cno(COURSES). Then Eligible=All−Bad, and the requested full course listing is COURSES⋈Eligible. The join uses Cno and returns each eligible course's number and name.
This construction implements 'all' by excluding counterexamples. If a course has three prerequisites and one is missing, that missing pair places it in Bad and removes it. A course with no prerequisites has no missing pair, so it remains eligible by vacuous truth. A naive division over only existing prerequisite pairs can accidentally omit such courses. Nothing in the question excludes courses already completed by the student; add that exclusion only if explicitly requested. The expression uses set relational algebra, so duplicate completion records have no effect.
R(a, b, c, d) has atomic domains and only FDs a→c, b→d and their consequences. Which normal form applies?
Your answer
Answer & solution
Answer: A: 1NF but not 2NF (no official key was published)
Step through it (4 steps)
Neither a nor b can be derived from the other attributes, so every key must contain both. The closure of ab includes c and d, so ab is the candidate key. Attribute c depends on only a, and d on only b, both proper subsets of that composite key. These are partial dependencies of nonprime attributes, violating 2NF. Atomic domains establish 1NF, so A is correct. The statement that no other independent FDs hold rules out an unstated single-attribute key that would alter this analysis.
S.d references the primary key of R. Which can violate this reference: insert R, insert S, delete R, delete S?
Your answer
Answer & solution
Answer: D: insert S and delete R (no official key was published)
Inserting into S can introduce a nonnull d value absent from R. Deleting a referenced row from R can leave existing S rows without a parent. These are operations 2 and 3, D. Inserting a valid new R row cannot remove an existing reference target; deleting an S row removes a referencing requirement. This concerns the foreign-key constraint specifically, not a separate duplicate-primary-key violation on insertion into R. A DBMS may reject or cascade dangerous operations, but those enforcement policies do not change which raw changes can create a violation.
In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. With ℓ≥2 leaves, how many key entries are stored across all internal nodes?
Answer & solution
Answer: ℓ−1 internal key entries. (no official key was published)
Let I be the number of internal nodes and let kv be the number of key entries in internal node v. That node has kv+1 children, so summing all internal-node child counts counts every tree edge exactly once:
Σ_internal v (kv+1) = number of edges.
The whole tree has I+ℓ nodes and is connected and acyclic, so it has I+ℓ−1 edges. Therefore
Σ kv + I = I+ℓ−1, and hence Σ kv = ℓ−1.
This argument includes the root, whose minimum occupancy differs from other internal nodes. It does not depend on the height, branching distribution, or order d, only on the fact that every internal node has one more child than key entries.
For a root with three leaf children, there are two root keys and ℓ−1=2. If an internal node with five leaf children is inserted one level lower, its four keys and the necessary separator keys above it still obey the same identity. The result counts stored separator entries in internal nodes; it is not the number of data records in the leaves, nor a claim about the number of distinct values across the entire B+-tree. Leaf keys can have different occupancy conventions without affecting this edge-count identity.
In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. For d=4 and exactly 52 leaves, find the maximum number of internal nodes.
Answer & solution
Answer: 13 internal nodes, attainable at height 3. (no official key was published)
With 52 leaves, the total number of internal key entries is 52−1=51. If there are I internal nodes, the root uses at least one key and every other internal node uses at least d=4. Hence
1+4(I−1)≤51, so 4I≤54 and I≤13.
An upper bound alone is not enough: equal leaf depth might prevent attaining it. Here it is attainable. Build a height-3 tree as follows: Depth 0: one root with two children (one key). Depth 1: two internal nodes, each with five children (four keys each). Depth 2: ten internal nodes. Give eight of them five leaf children and two of them six leaf children. Depth 3: 8·5+2·6=52 leaves.
Every nonroot internal node has five or six children, within the permitted five-to-nine range for d=4. All leaves are at depth three. The internal-node count is 1+2+10=13, and their key total is 1+8+8·4+2·5=51, confirming the arithmetic.
Thus 13 is both an upper bound and an achievable maximum. Treating order 4 as a maximum of four children would use a different B+-tree definition and give a wrong result for the convention explicitly supplied in this paper.
In this question a B+-tree of order d has d to 2d key entries in each nonroot internal node, and an internal node with M keys has M+1 children. An internal root has 1 to 2d keys. All leaves are at equal edge-distance h from the root. Use this stated convention, not the alternative convention that “order” means maximum fan-out. For h≥1, find the minimum number of leaves.
Answer & solution
Answer: 2(d+1)^(h−1). (no official key was published)
Since h≥1, the root is internal. Its minimum one key gives a minimum of two children. Every other internal node has at least d keys, hence at least d+1 children.
At depth 1 there are therefore at least 2 nodes. At depth 2 there are at least 2(d+1), and continuing to the leaf level h gives
minimum leaves = 2(d+1)h−1.
The exponent is h−1 because the first branching step is performed by the root, with minimum fan-out two; the remaining h−1 steps have minimum fan-out d+1. Multiplying by d rather than d+1 would confuse the minimum number of keys with the number of child pointers.
The bound is attainable: give the root exactly two children and every other internal node exactly d+1 children, stopping with leaves at depth h. All nonroot internal nodes then have exactly d keys, the root has exactly one, and every leaf lies at the required common depth. For h=1 the tree is a root with two leaf children, and the formula gives 2. For d=4,h=3 it gives 2·5²=50 leaves, consistent with the 52-leaf construction in the companion part. A tree of height zero is outside this subpart and would instead consist of a single leaf.
Relations are EMP(eno,name,age), PROJ(pno,name), and INVOLVED(eno,pno). The underlined primary keys are EMP.eno, PROJ.pno, and the composite key (eno,pno) of INVOLVED. EMP describes employees, PROJ projects, and INVOLVED employee–project participation. Use ordinary set relational algebra unless a different model is explicitly stated. Translate the supplied SQL using relational-algebra operators: SELECT eno FROM EMP, INVOLVED WHERE EMP.eno = INVOLVED.eno AND INVOLVED.pno = 3; The SELECT column is unqualified in the reproduction.
Answer & solution
Answer: After qualifying SELECT EMP.eno, the set-algebra answer is π_EMP.eno(σ_EMP.eno=INVOLVED.eno ∧ INVOLVED.pno=3(EMP×INVOLVED)). Literal SQL has an ambiguous column reference. (no official key was published)
First distinguish the printed query from its evident intention. Both EMP and INVOLVED have a column named eno, and an explicit FROM EMP,INVOLVED cross join retains both column names. The equality in WHERE does not make the unqualified SELECT eno syntactically unambiguous in standard SQL. The literal query therefore requires qualification. Taking the intended target as EMP.eno gives:
The Cartesian product produces all employee/participation row pairs. Selection keeps only pairs referring to the same employee and project number 3. Projection then retains the requested employee number. One may push the project filter down before the product, obtaining π_EMP.eno(σ_EMP.eno=INVOLVED.eno(EMP × σ_pno=3(INVOLVED))), which is set-equivalent and usually more efficient.
Attribute qualification in the first formula prevents confusion between the two eno fields and the two relations. A natural join EMP ⋈ INVOLVED followed by σ_pno=3 and π_eno is also valid here because eno is their only shared attribute name. PROJ is not used: the SQL never checks whether project 3 exists in PROJ, and adding that join would impose an extra condition not present in the query.
The displayed composite primary key (eno,pno) of INVOLVED rules out duplicate employee–project pairs, and EMP.eno is also a primary key. After restricting INVOLVED.pno to 3, there is at most one qualifying involvement row for each employee, and the join matches at most one EMP row. Therefore the qualified SELECT returns each selected employee number at most once. Although SQL SELECT normally uses bag semantics and ordinary relational algebra uses sets, that difference does not change this query’s result under the stated keys. No added DISTINCT or extra uniqueness assumption is needed. The printed unqualified SELECT eno still requires the column-name repair explained above.
Relations are EMP(eno,name,age), PROJ(pno,name), and INVOLVED(eno,pno). The underlined primary keys are EMP.eno, PROJ.pno, and the composite key (eno,pno) of INVOLVED. EMP describes employees, PROJ projects, and INVOLVED employee–project participation. Use ordinary set relational algebra unless a different model is explicitly stated. In at most 15 words state what this relational-algebra expression determines: π_eno(INVOLVED) − π_eno((π_eno(INVOLVED) × π_pno(PROJ)) − INVOLVED). The two b-subparts together carry 4 marks; their individual marks are not printed.
Answer & solution
Answer: Employee numbers of involved employees who participate in every project. (no official key was published)
Requested short answer: Employee numbers of involved employees who participate in every project.
This is 10 words, within the requested limit. The wording involved employees preserves the candidate domain actually used by the expression. For the derivation, let C=π_eno(INVOLVED) be the employee numbers appearing in at least one involvement row, let P=π_pno(PROJ) be all project numbers, and let R=INVOLVED.
The product C×P enumerates every employee–project pair that would be required if each candidate participated in every project. Subtracting R leaves missing pairs: a pair (e,p) remains exactly when e is a candidate, p is a project, and the participation (e,p) is absent. Projecting those missing pairs onto eno produces the candidates who fail to participate in at least one project. Finally, subtracting that set from C leaves the candidates with no missing project.
Formally, the result is {e∈C: for every p∈P, (e,p)∈R}. This is the usual division construction R÷P with its candidate universe drawn from R. For example, if P={1,2}, candidate 7 appears with both projects and candidate 8 only with project 1, the missing-pair set contains (8,2), so only 7 remains.
Two boundary details matter. EMP is not referenced, so the expression does not independently check that every eno is a valid employee if referential integrity is absent. If PROJ is empty, C×P is empty, the missing-candidate set is empty, and the result is C by vacuous truth. It is not automatically all rows of EMP; employees absent from INVOLVED are outside the candidate universe even in that empty-project case. The short answer is therefore narrower and more faithful than an unconditional claim that all employees participating in every project are returned.
Relations are EMP(eno,name,age), PROJ(pno,name), and INVOLVED(eno,pno). The underlined primary keys are EMP.eno, PROJ.pno, and the composite key (eno,pno) of INVOLVED. EMP describes employees, PROJ projects, and INVOLVED employee–project participation. Use ordinary set relational algebra unless a different model is explicitly stated. In at most 15 words explain the second expression in GFG76(b). The available reproduction visibly reads approximately π_age(EMP) − π_{E.age<EMP.age}(ρ_E(EMP) × EMP). The second operator is printed as a projection symbol whose subscript is a comparison, rather than a projection of an attribute followed by a selection. A note describes ρ as renaming a copy of EMP, but uses an inconsistent alias in its prose. State the literal defect, and separately explain the likely intended well-typed maximum-age query. The two b-subparts jointly carry 4 marks; individual allocations are unavailable.
Answer & solution
Answer: Literal expression: not well-typed standard relational algebra. Under the separately stated repair: “Ages of the oldest employees.” (no official key was published)
Literal reading first: in standard relational algebra, π takes an attribute list, not a Boolean comparison predicate. The printed subscript E.age<EMP.age therefore does not define an ordinary projection. Simply changing that π into σ is insufficient: it would produce tuples of the two-relation product, which cannot be subtracted from the unary relation π_age(EMP). Set difference requires compatible schemas. Consequently the paper, as read, does not have a defined standard relational-algebra result. No verified original or alternate complete tail is available to establish the missing symbols.
A plausible intended repair is π_age(EMP) − ρ_age←E.age(π_E.age(σ_E.age<EMP.age(ρ_E(EMP) × EMP))). Here ρ_E(EMP) is a distinct copy whose attributes are qualified E. The inner selection finds each pair where the copied employee is younger than the other employee. Projecting E.age collects ages that have a strictly greater age somewhere in EMP. The explicit attribute rename makes the right-hand unary age relation union-compatible with the left-hand one. Subtract those nonmaximum ages from all ages and only the maximum age remains.
Under this repair, the requested short English answer is: Ages of the oldest employees. This is five words. For ages {25,40,40}, the Cartesian comparison finds that 25 has an older witness, while 40 does not. Set projection removes duplicate 40s, and the final result is {40}, an age value rather than employee names or employee records. With an empty EMP, the result is empty. Equal ages do not eliminate each other because the comparison is strict.
This maximum-age interpretation is conditional on projecting the younger copy's age. Projecting EMP.age instead would remove ages that have a smaller witness and leave the minimum, a different query. Thus the damaged expression cannot safely be repaired silently. The literal defect and the proposed older-witness interpretation must remain separate until a better source establishes the exact original notation.
Relations are USERS(User#,UserName,HomeTown), BOOKS(Book#,BookTitle,AuthorName), and ISSUED(Book#,User#,Date). Natural joins match the identically named key attributes. Explain in one English sentence the query σ_User#=6(π_User#,BookTitle((USERS ⋈ ISSUED) ⋈ BOOKS)). This paraphrase uses GFG's legible relational operators; GateForum's reproduction drops join symbols and degrades projection typography.
Answer & solution
Answer: Returns (6, title) pairs for books recorded as issued to user 6. (no official key was published)
One-sentence answer: It returns user number 6 together with the titles of books recorded as issued to that user.
To see why, USERS ⋈ ISSUED first connects each issue record with the user whose User# matches. Joining this result with BOOKS on Book# adds the associated BookTitle and AuthorName. The projection π_User#,BookTitle retains just the user identifier and title, discarding names, dates, book identifiers and author names. Finally σ_User#=6 keeps only rows whose user identifier is 6.
Selection occurs after projection here without losing its input attribute, because User# is explicitly retained. It could equivalently be pushed earlier to restrict the user or issue records before the joins. Under ordinary set-based relational algebra, projection removes duplicate pairs: borrowing the same titled book more than once does not produce multiple identical (6,title) rows, and distinct books with the same title also collapse at this projection. No return-date or current-loan condition exists in the schema, so “recorded as issued” is more precise than claiming these are necessarily the user's currently unreturned books. The query yields titles with the fixed identifier 6, not a count of loans, author names, or all users who borrowed the same books.
Relations are USERS(User#,UserName,HomeTown), BOOKS(Book#,BookTitle,AuthorName), and ISSUED(Book#,User#,Date). Natural joins match the identically named key attributes. Explain in one English sentence the query π_AuthorName(BOOKS ⋈ σ_HomeTown='Delhi'(USERS ⋈ ISSUED)). Use the projection and natural-join symbols visible in GFG; GateForum misprints/degrades these operators.
Answer & solution
Answer: Names of authors with at least one book issued to a Delhi-hometown user. (no official key was published)
One-sentence answer: It returns the names of authors having at least one book recorded as issued to a user whose hometown is Delhi.
The inner natural join USERS ⋈ ISSUED matches each issue to its borrower through User#. Selecting HomeTown='Delhi' retains issue records belonging to Delhi users; the condition describes the borrower's hometown, not the author's residence or the book's publication place. The join with BOOKS matches Book# and adds the author of each surviving issued book. Projection onto AuthorName then discards every other attribute.
Under set semantics each distinct author name appears once, even if several Delhi users borrowed that author's books or one user borrowed several such books. The condition is existential: one qualifying issue suffices. It does not require that all books by the author have been issued, that every Delhi user has read the author, or that the author is popular by any numerical threshold. Likewise nothing in the given schema tests whether a book has since been returned. If no Delhi user has any issue record, the result is empty. Two different people who happen to share AuthorName are not distinguished by this schema and projection; the result is a set of names rather than necessarily unique real-world author identities.
For R(A,B,C) with functional dependencies AB→C and C→A, show that R is in 3NF but not BCNF.
Answer & solution
Answer: Candidate keys AB and BC make all attributes prime. C→A satisfies 3NF but violates BCNF since C is not a superkey. (no official key was published)
Step through it (7 steps)
Compute enough closures to identify the keys. (AB)+ contains A,B and gains C by AB→C, so AB is a superkey; neither A nor B alone determines all attributes, so it is minimal. (BC)+ gains A by C→A and is likewise a candidate key. Every candidate key must contain B because no dependency can introduce B. A key containing B must also include A or C, giving precisely AB and BC. Thus A,B,C are all prime attributes, meaning each occurs in at least one candidate key.
For 3NF, every nontrivial dependency X→Y with a single right-side attribute must have X a superkey or Y prime. The given AB→C has a superkey determinant. In C→A, C is not a superkey, but A is prime because it belongs to key AB. This is allowed in 3NF. In fact every attribute of R is prime, so any implied single-attribute dependency also meets that alternative of the definition. Hence R is in 3NF.
BCNF removes the prime-attribute exception: every nontrivial dependency must have a superkey on the left. Here C+={C,A}; it cannot acquire B, so C is not a superkey. The nontrivial dependency C→A therefore violates BCNF. Being in 3NF does not imply that every determinant is a key. This conclusion assumes the displayed dependencies generate the schema's constraints and that the relation is in first normal form, as is conventional for this normalization problem.
For R(A,B,C), with AB→C and C→A, determine every minimal key.
Answer & solution
Answer: AB and BC are exactly the candidate keys. (no official key was published)
Step through it (4 steps)
A candidate key must determine all three attributes, and none of its proper subsets may do so. Since B does not occur on the right side of either given functional dependency, starting from attributes that omit B can never derive B. Thus every key must contain B. The closure B+ is just {B}, so B by itself is not enough.
Add A: (AB)+ initially contains A,B and then AB→C adds C, so AB is a superkey. Removing A leaves B+, which lacks A,C; removing B leaves A+={A}. Therefore AB is minimal. Add C instead: (BC)+ contains B,C, then C→A adds A, so BC is a superkey. Removing B leaves C+={C,A}, and removing C leaves B+={B}; neither is all of R. Thus BC is minimal.
These are exhaustive. Any key must contain B and at least one of the other two attributes. Such a set therefore contains AB or BC. The only larger possibility ABC is a superkey but not a minimal key, because either of those proper subsets already determines R. Hence the complete candidate-key set is {AB,BC}, not just the first key suggested by the dependency AB→C. No extra dependencies are assumed.
AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain the names of all publishers.
Answer & solution
Answer: π_PNAME(PUBLISHER). (no official key was published)
The requested output is a single attribute, PNAME, from every tuple of PUBLISHER. Projection selects columns, so the expression is π_PNAME(PUBLISHER). No selection predicate is needed because no publisher is to be filtered out, and no join is needed because the required data already reside in one relation.
Under classical relational algebra, relations are sets, so projection returns each distinct publisher name once. If two stored tuples happen to share a name, the output still contains that value once. The result schema consists only of PNAME, not PCITY.
It would be incorrect to obtain these names by projecting BOOK: that would return only publishers represented by at least one recorded book, whereas the query asks for all publishers. Similarly, joining PUBLISHER with BOOK first could incorrectly lose a publisher with no matching book. DIVIDE is also unnecessary: there is no requirement involving all members of another relation. This simple query tests matching the requested output columns and population directly to the base relation.
AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain all AUTHOR attributes of authors who have published a book with PNAME='TECHNICAL PUBLISHERS'.
Answer & solution
Answer: π_ANAME,INSTITUTION,ACITY,AGE(AUTHOR ⋈ σ_PNAME='TECHNICAL PUBLISHERS'(BOOK)). (no official key was published)
First identify the relevant books using selection: T=σ_PNAME='TECHNICAL PUBLISHERS'(BOOK). This keeps tuples whose publisher name matches the specified literal, while retaining TITLE and ANAME so that authors can be linked. Next compute AUTHOR⋈T. The only shared attribute name is ANAME, so this natural join matches each qualifying book to its author record. Finally project ANAME,INSTITUTION,ACITY,AGE to return exactly the attributes requested from AUTHOR.
Thus the complete expression is π_ANAME,INSTITUTION,ACITY,AGE(AUTHOR⋈σ_PNAME='TECHNICAL PUBLISHERS'(BOOK)). Equivalently, first project ANAME from the selected books, then join that name relation to AUTHOR; the result already has exactly the AUTHOR schema.
An author with several matching books still appears only once in classical set relational algebra after projection. An author with no such book is excluded because there is no matching join tuple. Joining PUBLISHER is not needed: the condition is already expressible using BOOK.PNAME. The expression uses the association specified by the schema, namely ANAME as the author link; it does not infer that names uniquely identify people outside this database model. DIVIDE would express a universal requirement and would be inappropriate for the existential condition 'has published a book'.
AUTHOR(ANAME,INSTITUTION,ACITY,AGE), PUBLISHER(PNAME,PCITY), BOOK(TITLE,ANAME,PNAME). Use relational algebra SELECT, PROJECT, JOIN and/or DIVIDE. Obtain the names of all authors who have published a book for any publisher located in Madras.
Answer & solution
Answer: π_ANAME(AUTHOR ⋈ BOOK ⋈ σ_PCITY='Madras'(PUBLISHER)). (no official key was published)
Select publishers by their city: M=σ_PCITY='Madras'(PUBLISHER). Join BOOK to M on the common attribute PNAME. This keeps exactly books whose publisher is among the Madras publishers. Join the result to AUTHOR on ANAME, and finally project ANAME. A full expression is π_ANAME(AUTHOR⋈BOOK⋈σ_PCITY='Madras'(PUBLISHER)). Natural joins are unambiguous here: BOOK and PUBLISHER share PNAME, while AUTHOR and BOOK share ANAME. ACITY and PCITY are different attributes.
The test is on the publisher's city PCITY, not the author's city ACITY. An author outside Madras qualifies if at least one book has a Madras publisher. Conversely an author living in Madras does not qualify solely because of that residence. The word 'any' here is existential: one matching publisher is enough, so use selection and join rather than division.
Under an assumed foreign-key constraint BOOK.ANAME references AUTHOR.ANAME, the AUTHOR join can be omitted and π_ANAME(BOOK⋈M) is equivalent. Since that referential constraint is not explicitly stated, retaining AUTHOR is the safer literal expression for names of stored authors. Projection removes repetitions caused by multiple qualifying books or publishers under set semantics. Exact comparison uses the displayed city value 'Madras', not a silently substituted modern place-name string.
True or false: every schema has a BCNF decomposition that is both lossless and dependency preserving.
Answer & solution
Answer: False (no official key was published)
Take R(A,B,C) with F={AB→C,C→B}. Its candidate keys are AB and AC. The dependency C→B violates BCNF because C is not a superkey. Decomposing into CB and AC is lossless, since the common C determines CB, and both components are BCNF. But their projected dependencies do not imply AB→C: from AB one cannot derive C. More generally every proper subrelation here supplies no dependency producing C from AB, so no decomposition into proper BCNF components can preserve that FD. BCNF can guarantee losslessness, not simultaneous dependency preservation in every case.
One instance of R(A,B,C) has distinct values for A. Can A be concluded to be a candidate key for the schema?
Answer & solution
Answer: No (no official key was published)
A candidate key is a schema-level guarantee: it must uniquely identify rows in every legal instance and be minimal among such attribute sets. Distinct A values in one observed instance show only that A happens to be unique there. For example rows (1,x,u),(2,y,v) are consistent with no uniqueness constraint on A; a later legal row (1,z,w) could repeat it. Therefore one instance does not establish the functional dependency A→BC or candidate-key status.
Give an expression equivalent to R∩S using the minimum number of operators from {∪,−}.
Answer & solution
Answer: R−(R−S), using two differences (no official key was published)
The inner R−S contains exactly the R tuples absent from S. Removing those from R leaves the tuples present in both, namely R∩S. This uses two operators. One operator cannot work for arbitrary R,S: R∪S includes exclusive tuples, R−S and S−R keep exclusives rather than common tuples, and applying an operator to a relation twice yields either that relation or the empty relation. Thus two is minimal under set semantics with only R,S and the listed binary operators, assuming union-compatible schemas.
True or false: logical data independence is easier to achieve than physical data independence.
Answer & solution
Answer: False (no official key was published)
Physical data independence hides changes such as indexes, file organization and storage placement behind an unchanged logical schema. Applications can often remain unaffected. Logical data independence must hide changes to the conceptual schema itself, such as restructuring relations or attributes, while preserving external views and application meaning. That generally requires more semantic translation and is harder. Therefore the source reverses the usual difficulty comparison. This is a database-design principle, not an assertion that every individual physical change is trivial.
COURSES(cno,cname), primary key cno; STUDENTS(rollno,sname,age,year), primary key rollno; REGISTERED_FOR(cno,rollno), composite primary key (cno,rollno). year denotes the student’s current year of study. GateForum asks for a relational algebra query printing roll numbers of students who HAVE registered for cno 322. GFG instead asks for those who HAVE NOT registered.
Answer & solution
Answer: Registered: π_rollno(σ_cno=322(REGISTERED_FOR)). Not registered: π_rollno(STUDENTS) − π_rollno(σ_cno=322(REGISTERED_FOR)). (no official key was published)
1. Select registrations for course 322 before projecting rollno, so registrations in other courses do not count.
2. For the registered variant, projection directly returns the wanted roll numbers under the usual valid student-reference assumption. Without that assumption, intersect with π_rollno(STUDENTS).
3. For the not-registered variant, subtract the selected roll-number set from all student roll numbers. Selecting registrations where cno≠322 would be wrong because a student may register for both 322 and another course, or for no course.
COURSES(cno,cname), primary key cno; STUDENTS(rollno,sname,age,year), primary key rollno; REGISTERED_FOR(cno,rollno), composite primary key (cno,rollno). year denotes the student’s current year of study. Write SQL to print the age and year of the youngest student in each year.
Answer & solution
Answer: SELECT MIN(age) AS age, year FROM STUDENTS GROUP BY year; (no official key was published)
1. Group rows by year so each year is processed independently.
2. MIN(age) computes the youngest age within that group. Output just age and year, as requested, rather than an arbitrary student name or roll number.
3. Ties need no extra rows because the requested attributes are identical for tied youngest students. Standard SQL ignores NULL ages; if all ages in a year are NULL, the result is NULL.
An ISAM file has 16K records of 64 bytes including a 14-byte key. A block address needs 2 bytes; disk blocks are 512 bytes. Find data blocks, index blocks, and number of index-tree levels.
Answer & solution
Answer: 2048 data blocks; 67 index blocks (64+2+1); 3 index levels, or 4 levels including data. (no official key was published)
Use K=1024, full blocks, unspanned fixed-length records, and the usual sparse ISAM index with one key-and-block-address entry per child block. Each data block holds floor(512/64)=8 records. Thus 16*1024/8=2048 data blocks are needed. The 14-byte key is already included in each 64-byte record; it must not be added again.
An index entry occupies 14+2=16 bytes, so an index block contains floor(512/16)=32 entries and can identify 32 child blocks. The lowest index level needs one entry for each of 2048 data blocks, giving ceil(2048/32)=64 index blocks. The next level indexes those 64 blocks and uses ceil(64/32)=2 blocks. A root indexes these two and fits in ceil(2/32)=1 block. Hence the total index area contains 64+2+1=67 blocks.
The hierarchy is:
root index: 1 block (2 populated entries)
-> middle index: 2 blocks (64 entries in total)
-> bottom index: 64 blocks (2048 entries in total)
-> data: 2048 blocks (16384 records).
There are three index levels, excluding the data level. If all levels including data are counted, the root-to-record path spans four levels; that is a different counting convention. The data area occupies 2048*512=1,048,576 bytes, and the allocated index area occupies 67*512=34,304 bytes, including root slack. There are 2115 blocks overall. No overflow reserve, block header overhead, or occupancy factor is supplied, so none is invented. A dense record-level index would have a different size and is not the standard sparse ISAM interpretation used here.
STUDENTS(rollno key,sname,saddr), COURSES(cno key,cname), ENROLL(rollno,cno composite key,grade), TEACH(tno,cno composite key,tname). FDs: rollno→sname,saddr; cno→cname; tno→tname; rollno,cno→grade. The reproduced cao/sdaddr spellings are interpreted as cno/saddr. Retrieve roll number and name of students with grade A in at least one course taught by a teacher named Ramesh.
Answer & solution
Answer: Use EXISTS to correlate enrollment and teaching to each student. (no official key was published)
A student qualifies if some enrollment has their roll number and grade A, and some teaching row for that enrollment's course has tname='Ramesh'. The course number is the join between ENROLL and TEACH; names need not be unique teacher identifiers.
SELECT s.rollno, s.sname
FROM STUDENTS AS s
WHERE EXISTS (
SELECT 1 FROM ENROLL AS e
JOIN TEACH AS t ON t.cno=e.cno
WHERE e.rollno=s.rollno
AND e.grade='A' AND t.tname='Ramesh'
);
EXISTS yields one truth value for each outer student, so several qualifying courses or several teachers named Ramesh do not duplicate the output. A plain join version would need DISTINCT for that purpose. The COURSES relation is unnecessary because the query does not request a course name or another condition on it. No requirement says the student must have an A in every Ramesh-taught course; replacing EXISTS with universal division would answer a stronger question.
The source TEACH attribute is printed cao but described as course number cno, and its FD list prints sdaddr for saddr. These obvious naming inconsistencies are explicitly normalized in the query rather than treated as extra attributes.
STUDENTS(rollno key,sname,saddr), COURSES(cno key,cname), ENROLL(rollno,cno composite key,grade), TEACH(tno,cno composite key,tname). FDs: rollno→sname,saddr; cno→cname; tno→tname; rollno,cno→grade. The reproduced cao/sdaddr spellings are interpreted as cno/saddr. Is this database in 3NF?
Answer & solution
Answer: No: TEACH violates 3NF through tno→tname. (no official key was published)
Step through it (4 parts)
Treat each listed relation separately and use the supplied FDs as the schema constraints. In STUDENTS, rollno is a key and determines the other attributes; COURSES likewise has key cno. ENROLL's determinant (rollno,cno) is its key. These three relations therefore satisfy BCNF, and in particular 3NF, under the stated dependencies.
TEACH has declared composite key (tno,cno). The dependency tno→tname is nontrivial, but tno alone does not determine cno, so it is not a superkey. The dependent attribute tname is not a member of the candidate key and is nonprime. This violates the 3NF test that every nontrivial FD have a superkey determinant or prime right-side attribute. Indeed it is already a partial dependency of a nonprime attribute on part of the composite key, violating 2NF.
Do not infer that tno is a key simply because it identifies a teacher: a teacher can occur in several teaching rows, one per course. No additional FD tno→cno is supplied. If such a different constraint were imposed the answer could change, but it is not part of this schema.
STUDENTS(rollno key,sname,saddr), COURSES(cno key,cname), ENROLL(rollno,cno composite key,grade), TEACH(tno,cno composite key,tname). FDs: rollno→sname,saddr; cno→cname; tno→tname; rollno,cno→grade. The reproduced cao/sdaddr spellings are interpreted as cno/saddr. Normalize the relations to 3NF if needed.
Answer & solution
Answer: Keep STUDENTS,COURSES,ENROLL; replace TEACH with TEACHER(tno key,tname) and TEACHES(tno,cno composite key). (no official key was published)
Separate teacher facts from teaching assignments. Use TEACHER(tno,tname) with primary key tno, and TEACHES(tno,cno) with primary key (tno,cno). Retain the other three relations unchanged. The dependency tno→tname now has a key determinant in TEACHER; no supplied nontrivial non-key dependency remains in TEACHES. Thus both components are BCNF, stronger than the requested 3NF.
This decomposition is lossless under the given FD. Its intersection is {tno}, which determines all of TEACHER. More concretely, every teaching pair joins to its unique teacher name, and rows sharing a teacher number cannot acquire different names because of the FD. Projecting a valid original TEACH relation and joining the projections therefore reconstructs it without spurious combinations of teacher names and assignments.
It also preserves the relevant dependency locally in TEACHER. Separating tname into a relation with only cno instead would attach a teacher name to a course rather than its determining teacher number, and would not preserve the intended dependency. Identical names across different teacher numbers remain permitted.
Give a one-line answer: how is redundancy reduced in the hierarchical database model?
Answer & solution
Answer: Store shared parent information once above its children; systems supporting logical/virtual child links can reference a shared record rather than duplicate it. (no official key was published)
One-line answer: Store shared parent information once above its children; systems supporting logical/virtual child links can reference a shared record rather than duplicate it.
Why this works: A parent such as a department need not have its name and address copied into every employee child. A pure tree, however, gives each child one parent and does not automatically remove duplication for many-to-many relationships. Logical relationships or virtual/pointer records are implementation extensions, not a universal property of every hierarchical model.
Redundancy means repeatedly storing the same fact, not merely having repeated key values. Keys or links may legitimately recur to express relationships. These are design mechanisms rather than a claim that the model makes every possible database free of redundancy.
Give a one-line answer: how is redundancy reduced in the network database model?
Answer & solution
Answer: Store an entity record once and represent its multiple owner/member relationships by links instead of repeating its data. (no official key was published)
One-line answer: Store an entity record once and represent its multiple owner/member relationships by links instead of repeating its data.
Why this works: A network model allows a record to participate in multiple set relationships. A course shared by several student relationships can be stored as one course record with relationship links or connector records, rather than duplicating the course attributes for each student. The relationships still occupy space; the reduction is in repeated entity facts.
Redundancy means repeatedly storing the same fact, not merely having repeated key values. Keys or links may legitimately recur to express relationships. These are design mechanisms rather than a claim that the model makes every possible database free of redundancy.
Give a one-line answer: how is redundancy reduced in the relational database model?
Answer & solution
Answer: Normalize relations using their dependencies, decomposing repeated facts into linked relations with keys. (no official key was published)
One-line answer: Normalize relations using their dependencies, decomposing repeated facts into linked relations with keys.
Why this works: For example, a relation Employee(emp,dept,deptName) repeats deptName for every employee in a department when dept→deptName. Decompose it into Employee(emp,dept) and Department(dept,deptName), with dept as the latter key. The department fact is then stored once. Decomposition should preserve information through a lossless join, and dependency preservation is desirable. Being relational alone does not guarantee a normalized schema.
Redundancy means repeatedly storing the same fact, not merely having repeated key values. Keys or links may legitimately recur to express relationships. These are design mechanisms rather than a claim that the model makes every possible database free of redundancy.
Relations are FREQUENTS(CUSTOMER,HOTEL), SERVES(HOTEL,SNACKS), LIKES(CUSTOMER,SNACKS). They record visits, available snacks, and preferences respectively. Express in relational algebra the query: list hotels that serve a snack customer Rama likes.
Answer & solution
Answer: π_HOTEL(SERVES ⋈ σ_CUSTOMER='Rama'(LIKES)). (no official key was published)
First select Rama's preferences: R = σ_CUSTOMER='Rama'(LIKES). Next match those snack names with served snacks by a natural join on their common attribute SNACKS. Finally discard the customer and snack columns, retaining only hotels:
π_HOTEL(SERVES ⋈ σ_CUSTOMER='Rama'(LIKES)).
An equivalent expression first projects preferences to snack names: π_HOTEL(SERVES ⋈ π_SNACKS(σ_CUSTOMER='Rama'(LIKES))).
For any hotel h in this result, the join supplies some snack s with SERVES(h,s) and LIKES('Rama',s), exactly the requested existential condition. Conversely, every such pair joins and projects to h, so no qualifying hotel is omitted. Under ordinary set relational algebra projection removes duplicates when a hotel serves several liked snacks.
FREQUENTS is deliberately unused: the query does not require Rama to visit the hotel. Joining it and filtering Rama would incorrectly exclude unvisited hotels. Nor is division appropriate: division would express serving every liked snack, whereas the wording asks for at least one. If Rama likes no snacks, the result is empty.
SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Write SQL returning part codes supplied to a Delhi project by a Delhi supplier.
Answer & solution
Answer: SELECT DISTINCT X.PCODE from the shipment/supplier/project join where both cities are DELHI. (no official key was published)
The shipment relation provides the association among a supplier, a part and a project. Join it to SUPPLIER on SCODE and to PROJECTS on PRCODE. The two city restrictions apply independently to supplier and project, not to PART.CITY.
SELECT DISTINCT X.PCODE FROM SPPR AS X JOIN SUPPLIER AS S ON S.SCODE = X.SCODE JOIN PROJECTS AS P ON P.PRCODE = X.PRCODE WHERE S.CITY = 'DELHI' AND P.CITY = 'DELHI';
A qualifying shipment is a witness that the part satisfies the request. DISTINCT ensures each code appears once even if multiple suppliers or projects witness it, or several shipment records exist. No join to PART is necessary because the requested code is already present in SPPR, under the usual foreign-key consistency assumption. If parts must also exist despite unenforced references, add JOIN PART AS T ON T.PCODE=X.PCODE. SQL string comparison follows the database's collation; DELHI is the source's city literal.
SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Write SQL returning distinct triples (supplier city, part code, project city), excluding equal cities.
Answer & solution
Answer: Join shipments to suppliers and projects, filter S.CITY <> P.CITY, and select the distinct three requested attributes. (no official key was published)
A row must describe an actual shipment rather than an arbitrary supplier/project combination. Use SPPR as the central relation and join the endpoint relations by their code keys. The supplier city is the first component; the destination project's city is the third.
SELECT DISTINCT S.CITY AS SUPPLIER_CITY,
X.PCODE,
P.CITY AS PROJECT_CITY
FROM SPPR AS X
JOIN SUPPLIER AS S ON S.SCODE = X.SCODE
JOIN PROJECTS AS P ON P.PRCODE = X.PRCODE
WHERE S.CITY <> P.CITY;
The predicate removes local shipments, and DISTINCT collapses repeated triples caused by different suppliers, projects or shipment rows. PART.CITY is irrelevant: it is neither endpoint requested in the result. Aliases make the two CITY columns distinguishable. Classical relational problems normally assume nonnull attributes. In SQL, if a city is NULL, the inequality is UNKNOWN and the row is excluded; a different policy for unknown cities would require an explicit requirement and predicate.
SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for supplier codes supplying both projects PR1 and PR2.
Answer & solution
Answer: π_SCODE(σ_PRCODE='PR1'(SPPR)) ∩ π_SCODE(σ_PRCODE='PR2'(SPPR)). (no official key was published)
First select shipments to PR1 and project their supplier codes: A=π_SCODE(σ_PRCODE='PR1'(SPPR)). Separately form B=π_SCODE(σ_PRCODE='PR2'(SPPR)). Both expressions have the same one-attribute schema, so set intersection is defined. The answer is A∩B.
Membership in the intersection requires a shipment witness to each project. The witnesses need not have the same part, quantity or shipment record. Selecting PRCODE='PR1' AND PRCODE='PR2' on a single tuple would be wrong because one shipment tuple cannot have two different project codes. Selecting with OR and projecting without intersection would also be wrong: it admits suppliers serving only one project. Under standard relational-algebra set semantics projection automatically eliminates duplicate supplier codes.
SUPPLIER(SCODE,SNAME,CITY), PART(PCODE,PNAME,PDESC,CITY), PROJECTS(PRCODE,PRNAME,CITY), SPPR(SCODE,PCODE,PRCODE,QTY). SPPR records shipments of parts by suppliers to projects. Give relational algebra for project codes supplied by at least one supplier in a different city.
Answer & solution
Answer: π_P.PRCODE(σ_S.CITY≠P.CITY((ρ_S SUPPLIER) ⋈_S.SCODE=X.SCODE (ρ_X SPPR) ⋈_X.PRCODE=P.PRCODE (ρ_P PROJECTS))). (no official key was published)
Rename SUPPLIER as S, SPPR as X and PROJECTS as P so that both CITY attributes can be referenced explicitly. Form J=(S ⋈_{S.SCODE=X.SCODE} X) ⋈_{X.PRCODE=P.PRCODE} P. Then return π_{P.PRCODE}(σ_{S.CITY≠P.CITY}(J)).
The joins establish that S actually supplies P through a shipment row. The selection keeps witnesses whose endpoint cities differ, and the projection returns the set of project codes having at least one such witness. A project may also have local suppliers and must still appear: the condition is existential, not a requirement that every supplier be out of town. A natural join over unrenamed relations would wrongly equate the two CITY attributes and suppress precisely the rows sought, so use explicit theta joins or rename the city columns before joining.