CS FundamentalsEasyGATE CS (PYQ pattern)
X1(a): 1, 1, 2, 2, 3, 4 and Y1(a): 2, 4, 5. Let p = rows from SELECT a FROM X1 WHERE a NOT IN (SELECT a FROM Y1) and q = rows from SELECT a FROM X1 EXCEPT SELECT a FROM Y1. What is p + q?
- A. 5
- B. 6
- C. 4
- D. 3
Correct answer: A. 5
NOT IN keeps duplicates: 1, 1 and 3 give p = 3. EXCEPT removes duplicates (multiset difference only with ALL): 1 and 3 give q = 2. Sum 5.
More DBMS and SQL questions
- Tables: P(id); C(id, p) with p referencing P(id) ON DELETE CASCADE; G(id, c) with c referencing C(id) ON DELETE SET NULL. Rows: P = {1…
- Optimistic concurrency control with backward validation. Transactions (start, validation, finish times; read set; write set): T1 (0, 4, 5…
- A two-phase commit has 1 coordinator and 5 participants and uses the read-only optimisation. All 5 receive PREPARE. Three vote YES, one…
- A linear hashing file starts with 2 buckets (hash h0 = k mod 2, then h1 = k mod 4, h2 = k mod 8, ...), a bucket holds 2 keys before it…
- A B+ tree index is built on (a, b) in this order. For which of these predicates can a search descend directly to a contiguous range of…
- Which of the following relational-algebra identities are valid for union-compatible relations R and S? I. σ{A=1}(R ∪ S) = σ{A=1}(R) ∪…