CS FundamentalsHardGATE CS (PYQ pattern)
K(a UNIQUE, b CHECK (b > 0)) is empty. These rows are inserted one by one, ignoring any row that violates a constraint: (1,5), (1,6), (NULL,3), (NULL,4), (2,0), (2,NULL), (3,-1), (NULL,NULL). How many rows end up in K? (Standard SQL semantics: UNIQUE allows several NULLs, and a CHECK that evaluates to UNKNOWN passes.)
- A. 4
- B. 6
- C. 5
- D. 3
Correct answer: C. 5
(1,5) ok; (1,6) duplicates a = 1; (NULL,3) and (NULL,4) both ok (NULLs are distinct for UNIQUE); (2,0) fails CHECK; (2,NULL) passes (UNKNOWN is not a violation); (3,-1) fails; (NULL,NULL) ok. Rows kept: 5.
More DBMS and SQL questions
- G(g, x): (a,5), (a,7), (b,4), (b,4), (b,4), (c,20), (d,NULL), (d,1). How many groups does SELECT g FROM G GROUP BY g HAVING SUM(x) >…
- SALE(r, q, amt): (n,1,10), (n,2,30), (s,1,5), (s,2,5), (s,3,5), (e,1,50). View V is SELECT r, SUM(amt) AS tot, COUNT() AS c FROM SALE…
- A Grace hash join partitions both inputs into B - 1 partitions using one input page per partition plus one input buffer; in the probe…
- A table has 1,000,000 rows in 10,000 pages. An unclustered B+ tree index of height 3 costs 3 page reads to reach the first matching entry…
- A RAID 6 array has 10 disks, each sustaining 200 random I/Os per second. A small read costs 1 disk I/O and a small write costs 6 (read…
- Which of the following tuple-relational-calculus expressions are SAFE (guaranteed to return a finite result for every database)? I. { t |…