Challenge - 5 Problems
View Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
Output of a simple view query
Given the table Employees with columns
id, name, salary, and a view HighEarners defined as CREATE VIEW HighEarners AS SELECT id, name FROM Employees WHERE salary > 70000;, what will be the output of SELECT * FROM HighEarners; if the table contains:id | name | salary
1 | Alice | 80000
2 | Bob | 60000
3 | Carol | 90000SQL
CREATE VIEW HighEarners AS SELECT id, name FROM Employees WHERE salary > 70000; SELECT * FROM HighEarners;
Attempts:
2 left
💡 Hint
Remember the view filters employees with salary greater than 70000.
✗ Incorrect
The view selects only employees with salary above 70000, so Bob is excluded.
🧠 Conceptual
intermediate1:30remaining
Purpose of using views for security
Why are views often used to improve security in databases?
Attempts:
2 left
💡 Hint
Think about how views can limit what data users see.
✗ Incorrect
Views can show only certain columns or rows, hiding sensitive data from users.
📝 Syntax
advanced2:00remaining
Identify the syntax error in view creation
Which option contains a syntax error when creating a view that shows only active customers from a
Customers table with a boolean active column?Attempts:
2 left
💡 Hint
Check the comparison operator used in SQL.
✗ Incorrect
SQL uses a single equals sign (=) for comparison, not double (==).
❓ optimization
advanced2:30remaining
Optimizing view performance with indexes
You have a view
RecentOrders defined as SELECT * FROM Orders WHERE order_date > CURRENT_DATE - INTERVAL '30 days'. Which approach will best improve query performance when selecting from this view?Attempts:
2 left
💡 Hint
Think about how databases use indexes to speed up filtering.
✗ Incorrect
Indexes on the underlying table columns used in the view's WHERE clause speed up filtering.
🔧 Debug
expert3:00remaining
Why does this view cause an error on update?
Consider the view
CREATE VIEW EmployeeNames AS SELECT id, name FROM Employees;. A user tries to run UPDATE EmployeeNames SET name = 'John' WHERE id = 5; but gets an error. Why?Attempts:
2 left
💡 Hint
Think about what makes a view updatable.
✗ Incorrect
Views that do not include all key columns or have complex logic often cannot be updated directly.