Databases

4,127 questions on Databases, part of Computing & Information Sciences. Below are 12 of them in full, each answered in plain language.

Questions & explanations

1. Give an example of a strict schedule that is not rigorous.

Consider T1 writes X, then T2 writes X, and then T1 commits, then T2 commits. This schedule is strict because both writes are on committed data? Wait, T2 writes X before T1 commits, so T2 writes uncommitted data? That is not strict. A proper example: T1 writes X and commits, then T2 writes X and commits. That is strict and also rigorous. To get strict but not rigorous, we need a schedule where a transaction writes after another has written but before that other commits, but reads only committed? Actually in strict, no reads/writes uncommitted, so if T1 writes X (uncommitted), T2 cannot write X until T1 commits, so T2 writes after T1 commits -> that is rigorous. Maybe strict and rigorous are equivalent? No, rigorous forbids writing until previous writer commits; strict allows writing if previous writer is still active? Actually strict says no read/write uncommitted, so if T1 writes X (uncommitted), T2 cannot read X (that's strict), but if T2 writes X before T1 commits, that is writing uncommitted data (T1's write is uncommitted) so strict forbids it. So strict also forbids writing unc

2. Given decomposition R1(A,B), R2(B,C) of R(A,B,C) with no FDs, use chase to test losslessness.

Set up chase table: Row1: (a, b, n1) where a,b distinguished, n1 null. Row2: (n2, b, c) with n2 null. No FDs, so no equating can happen. The table does not have a row with all distinguished variables (a,b,c). So the decomposition is not lossless? Actually with no FDs, it is lossless? Wait, chase: if there is a row with all distinguished, it's lossless. Here not. But for this decomposition, it is lossless? Actually if no FDs, any decomposition that is lossless? Not necessarily. The chase says it's not lossless because joining R1 and R2 on B may produce spurious tuples. For example, R1 has (1,2), R2 has (2,3), join gives (1,2,3) okay, but also if R1 has (1,2) and R2 has (2,4), join gives (1,2,4), no problem. Actually with no FDs, any decomposition is lossless? No, it's not guaranteed. The chase correctly indicates that there might be spurious tuples? Actually the chase test is sound and complete. For no FDs, the decomposition is lossless if and only if the common attributes include a key in one of the relations? Here common is B, but B is not a key in either relation (since no FDs). So

3. Given R(A,B,C,D) with FDs {A→B, B→C, CD→A}, find a BCNF decomposition.

First, find candidate keys: compute closure of attributes. Start with A: gives A,B,C (from A→B, B→C) but not D, so A not key. CD: gives C,D, then CD→A gives A, then A gives B,C, so CD gives all, so CD is a candidate key. Check violating FDs: A→B: A not a superkey (closure of A is {A,B,C} not D), so violate. Decompose: use A→B: R1(A,B), R2(A,C,D). For R2, FDs? From original, we have A→C? Actually A→C by transitivity from A→B and B→C, so it's implied. And CD→A. In R2, candidate key? Compute closure of A in R2: A gives A,C (from A→C) but not D, so not key. CD→A works? CD gives all in R2? CD gives A, then A gives C, so all attributes: C,D,A. So CD is a candidate key in R2. Check violation: A→C in R2? A not a superkey (closure of A in R2 is {A,C} not D), so violate. Decompose R2 using A→C: R2a(A,C), R2b(A,D). Now check R2a: only FD A→C, A is key? Closure of A gives A,C, so yes key. R2b: no non-trivial FDs (since original didn't have A→D), so it's in BCNF. So final decomposition: R1(A,B), R2a(A,C), R2b(A,D). But we lost CD→A? Check: CD→A involves attributes from R2a and R2b? Actually D fro

4. Give a step-by-step derivation of a non-trivial FD using only reflexivity and transitivity.

Assume we have FD: A -> B and A -> C. We want to derive A -> BC. First, from A -> B, by reflexivity we have A -> AB (since AB is a superset of A? Wait, reflexivity gives X -> Y if Y ⊆ X. That doesn't directly help. Instead, we can use union rule which is derived from Armstrong's axioms. But using only reflexivity and transitivity: (1) A -> B (given). (2) A -> C (given). (3) We cannot directly combine them with only reflexivity and transitivity; union requires augmentation and transitivity. So a valid derivation using only reflexivity and transitivity is: from A -> B and B -> ? Wait we need a chain. Actually, without augmentation it's hard. Let's take a simpler example: from A -> B and B -> C, derive A -> C using transitivity. That's a non-trivial FD. Steps: (1) A -> B (given). (2) B -> C (given). (3) A -> C (by transitivity from 1 and 2). This is valid using only transitivity and the given FDs (reflexivity not needed here).

5. Can you have schedules that are CO but not rigorous?

Yes, a schedule can be CO but not rigorous. For example, T0 writes X and commits. T1 reads X (committed) then writes Y. T1 commits after T0. This satisfies CO because T1 commits after T0. But it is not rigorous because T1 read X before T0 committed? Actually, rigorous requires that a transaction only read/write after the previous writer commits. In this example, T1 reads X after T0 committed, so it is rigorous. A non-rigorous schedule: T0 writes X, then T1 reads X before T0 commits, but CO forces T1 to commit after T0 if it reads. However, that read is dirty; CO may allow dirty reads? Actually, CO does not prevent dirty reads; it only ensures commit order. So a schedule could be CO but allow dirty reads, which is not rigorous. Example: T0 writes X, T1 reads X (dirty), then T0 commits, then T1 commits. This satisfies CO because T1 commits after T0. But it is not rigorous because T1 read X before T0 committed. So yes.

6. Given F = {A→B, AC→D, B→C}, find the minimal cover. Is there an extraneous attribute?

First decompose: A→B, AC→D, B→C. No right side decomposition needed. Check redundancy: Try to remove A→B? Without it, closure of A under {AC→D, B→C} is {A} only, so A→B not redundant. AC→D? Without it, closure of AC under {A→B, B→C} gives AC→A,C, then A→B gives B, then B→C gives C (already), so AC→D? We cannot get D, so AC→D not redundant. B→C? Without it, closure of B under {A→B, AC→D} gives B→B, A→B but doesn't give C, so B→C not redundant. Check extraneous: In AC→D, is A extraneous? Compute closure of C under set without AC→D? Actually for extraneous, we temporarily remove AC→D and test if attribute removal changes closure. Check if A is extraneous: With A→B, B→C, we can compute closure of C alone: {C}. That doesn't give D, so A not extraneous. Is C extraneous? Closure of A alone: A gives B, B gives C, so A gives {A,B,C}. Does that imply D? No, so C not extraneous. Minimal cover = same set.

7. Given F = {AB->C, C->A}, list all FDs in F+. Assume attributes A,B,C only.

Given: (1) AB->C, (2) C->A. Start with trivial FDs: A->A, B->B, C->C, AB->A, AB->B, AC->A, AC->C, etc. From AB->C, apply augmentation: ABB->CB => AB->C is already. Augment with A: ABA->CA => AB->AC? Actually careful. Using augmentation: add B to both sides: ABB->CB => AB->BC? Wait, we need systematic. Let's list: From AB->C and C->A, by transitivity AB->A (trivial anyway). By reflexivity we have all subsets. Non-trivial: from C->A, augment with C: CC->AC => C->AC? That gives C->A and C->C, so C->AC. From AB->C and C->A, transitivity gives AB->A (trivial). So non-trivial ones: AB->C, C->A, C->AC, AB->AC (from AB->C and C->A? Actually AB->C and C->AC gives AB->AC). Also by augmentation of AB->C with A: AAB->AC => AB->AC again. Also from C->A, augment with B: BC->AB. So F+ includes many. Essentially all FDs where left side is a superset of some key? Hard to list all but these are main.

8. Compare external consistency with eventual consistency in distributed transaction processing.

External consistency guarantees that transactions appear in real-time order and that all reads see the latest committed data from earlier transactions. Eventual consistency only promises that if no new updates are made, all replicas will eventually converge, possibly after some delay. External consistency gives strong, predictable behavior useful for financial transactions or inventory systems. Eventual consistency allows higher availability and lower latency because updates propagate asynchronously. However, users may temporarily see stale data. External consistency requires synchronized clocks or expensive coordination, while eventual consistency can scale better. The choice depends on the application's need for correctness versus performance.

9. Given F = {A→BC, B→C, AB→D}, find a minimal cover. Show steps.

Step 1: decompose right sides: A→B, A→C, B→C, AB→D. Step 2: remove redundant FDs. Check B→C: is it implied by others? Without B→C, closure of B under remaining is {B} only, so B→C is not redundant? Actually compute closure: from A→B,AB→D? But without B→C, we can't get C, so B→C is not redundant. Check A→C: can it be derived? With A→B and B→C we get A→C, so A→C is redundant. Remove it. Now set = {A→B, B→C, AB→D}. Step 3: remove extraneous attributes from left side of AB→D. Is A extraneous? Compute closure of B under remaining: B gives B,C. Does that include D? No, so A not extraneous. Is B extraneous? Closure of A under remaining: A gives B, then B gives C, so A gives {A,B,C} - no D, so B not extraneous. Minimal cover = {A→B, B→C, AB→D}.

10. Compare the performance benefits of Hekaton's lock-free execution with traditional disk-based locking for a high-contention workload.

In a high-contention workload, traditional locking causes transactions to block waiting for locks, leading to long wait times and reduced throughput. Hekaton's lock-free approach allows transactions to proceed in parallel on different versions. However, under very high contention, Hekaton's optimistic validation may cause many aborts, as only one transaction per row can commit. Hekaton typically outperforms locking for workloads with moderate contention and high concurrency, because it avoids lock overhead and context switching. For extremely high contention, performance may suffer due to repeated retries. Overall, Hekaton excels for read-heavy or low-contention workloads but may need tuning for heavy write conflicts.

11. Explain the term 'lossless-join' in BCNF decomposition.

A decomposition is lossless if joining the decomposed relations yields exactly the original tuples without spurious ones. BCNF decomposition using a violating FD X→Y produces two relations: R1 = X∪Y and R2 = R - (Y - X). This decomposition is always lossless because the common attributes (X) form a foreign key from R1 to R2? Actually the intersection is X, and X is a key in R1? Wait, in R1, does X determine all attributes? Since X→Y, X is a key in R1? Not necessarily; in R1, X is a key for R1? In R1, we have X→Y, but if there are other attributes? R1 only has X∪Y, so X is a key for R1 (since X→Y and no other attributes). So the common attribute X is a key in R1, which ensures lossless join.

12. Given R(A,B,C) with FDs {A→B, B→C}, is it in BCNF? If not, decompose.

Check each FD. For A→B, is A a superkey? Compute closure of A: {A,B,C} so A is a superkey (candidate key). For B→C, closure of B: {B,C} - not all attributes, so B is not a superkey. So R is not in BCNF due to B→C. Decompose: use violating FD B→C. Create R1(B,C) and R2(A,B) (since R2 includes all attributes except C? Actually standard: R1 = X∪Y = {B,C}, R2 = R - Y = {A,B}? Wait careful: If violating FD is X→Y, then decompose into (X ∪ Y) and (R - (Y - X)). Here X={B}, Y={C}, so R1 = {B,C}, R2 = {A,B}. Now check R1: only FD is B→C, B is a key in R1? In R1, B is a key (since B→C), so R1 in BCNF. R2: has FD A→B, A is a key? Closure of A in R2 gives {A,B} so yes, A is key. So R2 in BCNF. Done.

More Computing & Information Sciences topics

This page shows 12 of 4,127 questions on this topic. The full set, with progress tracking and five agent perspectives per question, is in the JupiteX app — browse the exam catalogue or browse the Learn library.