CS FundamentalsHardGATE CS · SQL
Table Sale(id, rep, region, amt) rows: (1, 'Ira', 'N', 100), (2, 'Jai', 'S', 250), (3, 'Ira', 'S', NULL), (4, 'Kim', 'N', 300), (5, 'Jai', 'N', 150), (6, 'Ira', 'N', 200), (7, 'Lal', NULL, 120). What does this query return?
Table Sale(id, rep, region, amt) rows: (1, 'Ira', 'N', 100), (2, 'Jai', 'S', 250), (3, 'Ira', 'S', NULL), (4, 'Kim', 'N', 300), (5, 'Jai', 'N', 150), (6, 'Ira', 'N', 200), (7, 'Lal', NULL, 120).
What does this query return?
SELECT COUNT(*) FROM Sale WHERE NOT (region = 'N');
- A. 2
- B. 3
- C. 4
- D. 7
Correct answer: A. 2
Only rows where region = 'N' is FALSE survive: the two 'S' rows. For Lal, region is NULL, so the condition is UNKNOWN and NOT UNKNOWN is still UNKNOWN.
More DBMS and SQL questions
- Consider the schedule R2(B), R3(A), W3(A), R2(A), W2(B), R1(B), R1(A). Which statement is correct?
- The system crashes after the last record of this log (immediate database modification; <Ti, X> denotes an update with old and new values…
- R(A, B, C, D, E) has functional dependencies CE → A, B → AC, BE → CD, DE → B. How many superkeys does R have?
- Classify the schedule W1(B), W2(A), R2(B), C2, W1(A), C1 (Ci = commit of Ti) by the strongest property it satisfies.
- R(A, B, C, D, E) has functional dependencies CE → A, A → D, AC → DE, B → D. How many superkeys does R have?
- R(A, B) = {(1, 1), (1, 3), (3, 1), (3, 2), (3, 3)} and S(B, C) = {(1, 5), (2, 5), (2, 6), (2, 7), (4, 6)}. How many tuples are in πA(R ⋈…