∑GateAndNet
PlannerSign Up
ADVANCEDFrequently Tested 4 min read 9 views

DBMS 2027 Rank-Decider: Relational Division (R ÷ S), SQL Double-NOT-EXISTS & ARIES WAL Recovery

Primitive operator expansion of Relational Division R(X,Y) ÷ S(Y), De Morgan double-NOT-EXISTS SQL pattern, Steal/No-Force Write-Ahead Logging (Undo vs Redo), and Blind-Write View Serializability.

1. Universal Quantification ("For All") in Relational Algebra & SQL

Since SQL has no FOR ALL keyword, rewrite ∀y∈S:(x,y)∈R\forall y \in S : (x, y) \in R via De Morgan’s law as ¬∃y∈S:(x,y)∉R\lnot \exists y \in S : (x, y) \notin R (Double NOT EXISTS):

sql
-- Find Student IDs enrolled in ALL courses offered by 'CS' department
SELECT s.sid FROM Students s
WHERE NOT EXISTS (
    SELECT c.cid FROM Courses c WHERE c.dept = 'CS'
    AND NOT EXISTS (
        SELECT 1 FROM Enrolled e
        WHERE e.sid = s.sid AND e.cid = c.cid
    )
);
Common Exam Mistake

Empty Divisor Edge Case: In the SQL double-NOT EXISTS query above, if the CS department offers 00 courses (S is empty), the outer NOT EXISTS evaluates to TRUE for EVERY student in Students!

2. Crash Recovery: Write-Ahead Logging (WAL), Deferred vs Immediate Update

Recovery SchemeBuffer PolicyUncommitted Writes on Disk?On Crash: Committed TxnsOn Crash: Aborted/Active Txns
Deferred UpdateNO-STEAL / NO-FORCE❌ NeverREDO (need new value)NO-UNDO (simply ignore!)
Immediate Update (ARIES)STEAL / NO-FORCE✅ PossibleREDO (forward order)UNDO (reverse log order!)
  • Two Golden WAL Rules: (1) Before a modified dirty page hits disk, its <Ti, X, old, new> Undo log record must be flushed to stable storage (STEAL safety); (2) Before Ti is declared committed to the user, all its log records through <Ti, COMMIT> must be flushed to stable storage (NO-FORCE durability)!
  • View Serializable WITHOUT being Conflict Serializable: Requires at least one Blind Write (writing XX without first reading XX)! If a schedule has zero blind writes, View Serializable   ⟺  \iff Conflict Serializable!
Key Formulas Summary
Relational Division R(X, Y) ÷ S(Y) Using ONLY Primitive Operators (pi, sigma, x, -)
R÷S  =  πX(R)  −  πX ⁣((πX(R)×S)  −  R)R \div S \;=\; \pi_X(R) \;-\; \pi_X\!\Big( \big(\pi_X(R) \times S\big) \;-\; R \Big)
Note: Answers universal "FOR ALL" queries: Find X tuples paired in R with EVERY Y tuple in S!
#DBMS#Relational Division#SQL NOT EXISTS#Tuple Calculus#ARIES Recovery#WAL#GATE CS 2027

Practice Questions on This Chapter (2)

Q1GATE CS 2027 ExpectedMCQMEDIUM
+2M • -0.67

Let R(A,B)R(A, B) have 1212 tuples with 44 distinct values of AA, and let S(B)S(B) be non-empty with 33 tuples. What are the minimum and maximum possible numbers of tuples in the Relational Division R÷SR \div S?

⚡ Click an option above to verify instantly
Q2GATE CS 2026–27 Expected MSQMSQHARD
+2M • 0 Neg

Which of the following statements regarding Database Concurrency & Crash Recovery are ALWAYS TRUE?

☑️ Multiple Select Question — pick one or more options, then click Check Answer.
Previous TopicConflict Serializability (Precedence Graph) & B+ Tree Order MathNext Topic IPv4 CIDR Subnetting, CSMA/CD Minimum Frame & Sliding Window Math