CS FundamentalsHardProduct-company placement
Cust(cid, city) has rows (1, 'Pune'), (2, 'Delhi'), (3, NULL), (4, 'Pune'). What are the values of Q1: SELECT COUNT(*) FROM (SELECT city FROM Cust UNION SELECT city FROM Cust) t; Q2: SELECT COUNT(DISTINCT city) FROM Cust;
- A. Q1 = 2, Q2 = 2
- B. Q1 = 4, Q2 = 2
- C. Q1 = 3, Q2 = 3
- D. Q1 = 3, Q2 = 2
Correct answer: D. Q1 = 3, Q2 = 2
UNION removes duplicates and treats NULLs as duplicates of each other, leaving Pune, Delhi and NULL: 3 rows. COUNT(DISTINCT city) ignores NULL entirely, so it gives 2.
More DBMS and SQL questions
- Ord(oid, cid, amt) has no row with cid = 99. What do these return? Q1: SELECT SUM(amt), COUNT() FROM Ord WHERE cid = 99; Q2: SELECT cid…
- R(A, B, C, D, E, F) has functional dependencies AB → C, C → D, D → E, E → A and F → B. How many superkeys does R have?
- R(A, B, C, D, E, F) has functional dependencies A → BC, CD → E, E → A and B → F. It is decomposed into R1(A, B, C, F) and R2(A, C, D, E)…
- R(A, B, C, D, E) has functional dependencies A → C, B → D and CD → E. It is decomposed into R1(A, C), R2(B, D) and R3(A, B, E). Is the…
- R(A, B, C, D, E) has functional dependencies AB → CDE, C → A and D → E. What is the highest normal form R satisfies?
- R(A, B, C, D, E) has functional dependencies BC → A, A → B, D → E and E → D. How many candidate keys does R have, and what is its highest…