Challenge - 5 Problems
Denormalization Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Why choose denormalization in a database?
Which of the following is the main reason to use denormalization in a database design?
Attempts:
2 left
💡 Hint
Think about what happens when you want faster data retrieval at the cost of some redundancy.
✗ Incorrect
Denormalization is used mainly to reduce the number of joins in queries, which improves read performance. It intentionally introduces some redundancy.
❓ query_result
intermediate2:00remaining
Output of a denormalized query
Given these two tables:
Customers(customer_id, name)
Orders(order_id, customer_id, order_date)
We create a denormalized table:
CustomerOrders(customer_id, name, order_id, order_date)
What will be the output of:
Customers(customer_id, name)
Orders(order_id, customer_id, order_date)
We create a denormalized table:
CustomerOrders(customer_id, name, order_id, order_date)
What will be the output of:
SELECT customer_id, name, COUNT(order_id) AS order_count FROM CustomerOrders GROUP BY customer_id, name;
Attempts:
2 left
💡 Hint
Grouping by customer_id and name counts orders per customer.
✗ Incorrect
The query groups by customer and counts orders, showing how denormalized data can simplify queries.
📝 Syntax
advanced1:30remaining
Identify the error in denormalized table update
Consider a denormalized table storing product info and category name:
Products(product_id, product_name, category_id, category_name)
Which SQL statement will cause an error when updating category_name for all products in category 5?
Products(product_id, product_name, category_id, category_name)
Which SQL statement will cause an error when updating category_name for all products in category 5?
SQL
UPDATE Products SET category_name = 'New Category' WHERE category_id = 5;
Attempts:
2 left
💡 Hint
Check the data types in the WHERE clause.
✗ Incorrect
Option A compares category_name (a string) to 5 (a number), causing a type mismatch error or no rows updated.
❓ optimization
advanced2:00remaining
Optimizing read performance with denormalization
You have a normalized database with tables for Users, Orders, and Products. You want to speed up a report that shows user names, order dates, and product names. Which denormalization strategy will best improve read speed?
Attempts:
2 left
💡 Hint
Denormalization duplicates data to avoid joins in queries.
✗ Incorrect
Combining related data into one table reduces joins and speeds up reads, which is the goal of denormalization.
🔧 Debug
expert2:30remaining
Troubleshooting stale data in denormalized tables
You have a denormalized table storing customer info and their latest order date. After updating the Orders table, the denormalized table shows old order dates. What is the most likely cause?
Attempts:
2 left
💡 Hint
Denormalized data must be refreshed or updated manually or via triggers.
✗ Incorrect
Denormalized tables duplicate data and require explicit updates or triggers to stay current.