CS FundamentalsHardAmazon · Microsoft MCQ pattern
Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2), (4, 'John', 'Sales', 40000, 1), (5, 'Kiran', 'IT', 90000, 2), (6, 'Dev', NULL, 45000, 4), (7, 'Lata', 'Sales', NULL, 4). Which employees does this query return?
Table Emp(id, name, dept, salary, mgr) rows: (1, 'Asha', 'HR', 50000, NULL), (2, 'Ravi', 'IT', 70000, 1), (3, 'Meena', 'IT', 70000, 2), (4, 'John', 'Sales', 40000, 1), (5, 'Kiran', 'IT', 90000, 2), (6, 'Dev', NULL, 45000, 4), (7, 'Lata', 'Sales', NULL, 4).
Which employees does this query return?
SELECT e.name FROM Emp e JOIN Emp m ON e.mgr = m.id WHERE m.dept = 'IT';
- A. Ravi, Kiran
- B. Ravi, Meena, Kiran
- C. Meena, Kiran, Dev
- D. Meena, Kiran
Correct answer: D. Meena, Kiran
This is a self-join: m is the manager. Employees whose manager is in IT: Meena and Kiran (manager Ravi, IT). Ravi himself is in IT but his manager Asha is in HR.
More DBMS and SQL questions
- R(A, B, C) has functional dependencies AB → C and C → B. What is the highest normal form of R?
- R(A, B, C) with A → B and B → C. Which decomposition is lossless?
- Is the schedule R1(A), R2(A), W1(A), W2(A) conflict serializable?
- Which isolation level prevents dirty reads and non-repeatable reads but may still allow phantom reads (in the SQL standard)?
- Which statement about basic two-phase locking (2PL) is correct?
- A B+ tree is built on a key of 9 bytes. A block is 1024 bytes and a block pointer is 6 bytes. What is the maximum order p (number of child…