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.)

  1. A. 4
  2. B. 6
  3. C. 5
  4. 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

Exams that ask this topic