0
0
SQLquery~10 mins

Denormalization and when to use it in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all columns from the denormalized table.

SQL
SELECT [1] FROM sales_summary;
Drag options to blanks, or click blank then click option'
ACOLUMNS
BALL
C*
DEVERYTHING
Attempts:
3 left
💡 Hint
Common Mistakes
Using keywords like ALL or COLUMNS which are not valid in SELECT.
Trying to write out all column names manually.
2fill in blank
medium

Complete the code to add a denormalized column that stores total sales.

SQL
ALTER TABLE sales_summary ADD COLUMN total_sales [1];
Drag options to blanks, or click blank then click option'
ADECIMAL(10,2)
BTEXT
CVARCHAR(255)
DDATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using VARCHAR or TEXT which store strings, not numbers.
Using DATE which is for dates, not numbers.
3fill in blank
hard

Fix the error in the query that tries to join normalized tables but misses the join condition.

SQL
SELECT orders.order_id, customers.name FROM orders [1] customers;
Drag options to blanks, or click blank then click option'
AINNER JOIN
BINNER JOIN ON
CJOIN
DLEFT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using JOIN without specifying ON clause causes error.
Using INNER JOIN ON without the ON condition is invalid syntax.
4fill in blank
hard

Fill both blanks to create a denormalized table that stores customer name and total orders.

SQL
CREATE TABLE customer_orders AS SELECT customers.name AS [1], SUM(orders.amount) AS [2] FROM customers JOIN orders ON customers.id = orders.customer_id GROUP BY customers.name;
Drag options to blanks, or click blank then click option'
Acustomer_name
Btotal_amount
Corder_count
Dcustomer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using ambiguous or incorrect aliases that confuse the data meaning.
Using customer_id instead of customer_name for the name column.
5fill in blank
hard

Fill all three blanks to write a query that selects denormalized data with a condition on total sales.

SQL
SELECT [1], [2] FROM sales_summary WHERE [3] > 1000;
Drag options to blanks, or click blank then click option'
Acustomer_name
Btotal_sales
Dorder_count
Attempts:
3 left
💡 Hint
Common Mistakes
Using order_count in the WHERE clause instead of total_sales.
Selecting columns that do not exist in the denormalized table.