Bird
Raised Fist0
SQLquery~20 mins

Star schema concept in SQL - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Star Schema Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the Fact Table in a Star Schema

In a star schema, which table typically contains the measurable, quantitative data for analysis?

AStaging table
BFact table
CLookup table
DDimension table
Attempts:
2 left
💡 Hint

Think about where the numbers you want to analyze are stored.

❓ data_modeling
intermediate
2:00remaining
Choose the Correct Star Schema Structure

Which of the following SQL table structures best represents a star schema for sales data?

AOne large table with all sales and product details combined
BMultiple normalized tables with many-to-many relationships between sales and products
CA central sales fact table linked to separate product, customer, and date dimension tables
DA single table with repeated product and customer information for each sale
Attempts:
2 left
💡 Hint

Star schema uses a central fact table connected to dimension tables.

❓ dax_lod_result
advanced
2:00remaining
Calculate Total Sales Using DAX in a Star Schema

Given a fact table 'Sales' with a column 'Amount', which DAX measure correctly calculates the total sales amount?

SQL
Total Sales = SUM(Sales[Amount])
ATotal Sales = SUMX(Sales, Sales[Quantity])
BTotal Sales = COUNT(Sales[Amount])
CTotal Sales = AVERAGE(Sales[Amount])
DTotal Sales = SUM(Sales[Amount])
Attempts:
2 left
💡 Hint

To get total sales, add up all amounts.

❓ visualization
advanced
2:00remaining
Best Visualization for Star Schema Sales Data

You have sales data in a star schema with dimensions for Product, Date, and Customer. Which visualization best shows total sales by product category over time?

ALine chart showing sales trends by product category over months
BTable listing all sales transactions
CPie chart showing sales by product category
DScatter plot of sales amount vs. customer age
Attempts:
2 left
💡 Hint

Think about showing changes over time by category.

🔧 Debug
expert
2:30remaining
Identify the Error in Star Schema SQL Query

Consider this SQL query joining a fact table 'Sales' with dimension 'Product' to get total sales per product name:

SELECT Product.Name, SUM(Sales.Amount) AS TotalSales
FROM Sales
JOIN Product ON Sales.ProductID = Product.ID
GROUP BY Product.Name, Sales.Amount;

What is the error in this query?

AGrouping by Sales.Amount causes incorrect aggregation
BMissing WHERE clause to filter sales data
CJOIN condition uses wrong columns
DSUM function cannot be used with GROUP BY
Attempts:
2 left
💡 Hint

Check which columns should be in GROUP BY when using aggregation.

Practice

(1/5)
1. What is the main characteristic of a star schema in a data warehouse?
easy
A. One central fact table connected to multiple dimension tables
B. Multiple fact tables connected to one dimension table
C. Only dimension tables without any fact tables
D. A flat table with no relationships

Solution

  1. Step 1: Understand star schema structure

    A star schema has a central fact table that stores measurable data.
  2. Step 2: Identify dimension tables role

    Dimension tables surround the fact table and provide descriptive attributes.
  3. Final Answer:

    One central fact table connected to multiple dimension tables -> Option A
  4. Quick Check:

    Star schema = central fact + many dimensions [OK]
Hint: Fact table is the center, dimensions are spokes [OK]
Common Mistakes:
  • Confusing fact and dimension tables
  • Thinking star schema has multiple fact tables
  • Assuming no relationships exist
2. Which SQL JOIN type is typically used to connect fact and dimension tables in a star schema?
easy
A. INNER JOIN
B. LEFT JOIN
C. FULL OUTER JOIN
D. CROSS JOIN

Solution

  1. Step 1: Understand fact-dimension relationship

    Fact tables usually have matching keys in dimension tables.
  2. Step 2: Choose JOIN type for matching rows

    INNER JOIN returns only matching rows, ideal for star schema queries.
  3. Final Answer:

    INNER JOIN -> Option A
  4. Quick Check:

    Fact and dimension use INNER JOIN [OK]
Hint: Use INNER JOIN to link matching keys [OK]
Common Mistakes:
  • Using CROSS JOIN which multiplies rows
  • Using FULL OUTER JOIN causing unnecessary nulls
  • Using LEFT JOIN when INNER JOIN suffices
3. Given a star schema with a fact table Sales and dimension table Product, what does this SQL query return?
SELECT p.ProductName, SUM(s.SalesAmount) AS TotalSales
FROM Sales s
JOIN Product p ON s.ProductID = p.ProductID
GROUP BY p.ProductName;
medium
A. Sales amount grouped by sales date
B. Total sales amount for each product
C. Total sales amount for all products combined
D. List of products without sales data

Solution

  1. Step 1: Analyze JOIN and GROUP BY

    The query joins Sales and Product on ProductID and groups results by product name.
  2. Step 2: Understand aggregation

    SUM(s.SalesAmount) calculates total sales per product group.
  3. Final Answer:

    Total sales amount for each product -> Option B
  4. Quick Check:

    GROUP BY product sums sales per product [OK]
Hint: GROUP BY product sums sales per product [OK]
Common Mistakes:
  • Ignoring GROUP BY causing total for all products
  • Confusing JOIN keys
  • Assuming query lists products without sales
4. Identify the error in this SQL query using a star schema:
SELECT d.CustomerName, SUM(f.SalesAmount)
FROM FactSales f
JOIN DimProduct d ON f.ProductID = d.ProductID
GROUP BY d.CustomerName;
medium
A. JOIN uses wrong dimension table alias
B. GROUP BY column not in SELECT
C. SUM aggregation missing alias
D. JOIN condition uses wrong keys

Solution

  1. Step 1: Check JOIN condition keys

    FactSales.ProductID should join with DimProduct.ProductID, but SELECT and GROUP BY use CustomerName from a different dimension.
  2. Step 2: Identify mismatch in dimension usage

    CustomerName likely belongs to DimCustomer, not DimProduct, so JOIN keys are incorrect.
  3. Final Answer:

    JOIN condition uses wrong keys -> Option D
  4. Quick Check:

    JOIN keys must match correct dimension [OK]
Hint: Match JOIN keys to correct dimension table [OK]
Common Mistakes:
  • Grouping by column not selected
  • Using alias inconsistently
  • Missing aggregation alias
5. You want to design a star schema for sales data including customers, products, and time. Which approach best supports fast queries and easy analysis?
hard
A. Store all data in one big table without relationships
B. Create multiple fact tables for each dimension and one large dimension table
C. Create one fact table for sales and separate dimension tables for customers, products, and time
D. Use normalized tables with many joins instead of star schema

Solution

  1. Step 1: Understand star schema design principles

    Star schema uses one fact table for measurable events and multiple dimension tables for descriptive data.
  2. Step 2: Evaluate options for query speed and simplicity

    Create one fact table for sales and separate dimension tables for customers, products, and time matches star schema best, enabling fast joins and simple queries.
  3. Final Answer:

    Create one fact table for sales and separate dimension tables for customers, products, and time -> Option C
  4. Quick Check:

    Star schema = 1 fact + many dimensions [OK]
Hint: One fact table, many dimension tables for star schema [OK]
Common Mistakes:
  • Using multiple fact tables unnecessarily
  • Flattening all data into one table
  • Choosing normalized schema over star schema for BI
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard