Practice / macOS

Solve a SQL or NoSQL challenge

Run a read-only SQL query and a JSON pipeline, then verify both against visible and hidden checks.

Data Practice with SQL and NoSQL selection, the query editor, and visible checks.
Data Practice with SQL and NoSQL selection, the query editor, and visible checks. Select the image to enlarge.
  1. Group accounts in Duplicate Email Audit

    Search for Duplicate Email Audit and select the result. The SQL contract asks for one row per lowercase email shared by more than one account. Filter NULL and empty strings, group by the normalized email, and use HAVING to keep duplicate groups.

    Example

    For Alex@example.com and alex@example.com, expect one row with email alex@example.com and account_count 2. Keep the exact normalization in the prompt. Paste the query and choose Run Checks to see two passing visible checks.

    SELECT LOWER(email) AS email, COUNT(*) AS account_count
    FROM accounts
    WHERE email IS NOT NULL AND email <> ''
    GROUP BY LOWER(email)
    HAVING COUNT(*) > 1
    ORDER BY email;
    The Duplicate Email Audit SQL query passes both visible checks in Data Practice.
    Run Checks validates the SQL result against the visible fixtures. Select the image to enlarge.
  2. Filter inventory in Low Stock Projection

    Search for Low Stock Projection and select the NoSQL result. Return each matching inventory record with only sku and quantity. Match quantity at most 5, sort by quantity and then sku, and project the requested fields.

    Example

    A record with quantity 5 should remain. A record with quantity 6 should be filtered out. If two quantities are equal, the smaller sku sorts first. Paste the pipeline and choose Run Checks to see two passing visible checks.

    [
      {"$match": {"quantity": {"$lte": 5}}},
      {"$sort": {"quantity": 1, "sku": 1}},
      {"$project": {"_id": 0, "sku": 1, "quantity": 1}}
    ]
    The Low Stock Projection pipeline passes both visible checks in Data Practice.
    The filter, sort, and projection stages produce the expected documents. Select the image to enlarge.
  3. Submit each result and check its scope

    With a passing query selected, choose Submit. Checks & Results should show four of four passing for each worked example. Repeat after switching to the other challenge.

    Example

    To see what the visible checks protect, change the NoSQL threshold from 5 to 2 and run again. The primary fixture loses SKUs A and C, which both have quantity 3. Restore 5, run the visible checks, then submit.

Check your work

You can explain why the SQL query returns groups while the NoSQL pipeline returns individual inventory records. Each submission passes four checks.

Try it yourself

In Low Stock Projection, remove the final projection and run the visible checks. Compare the returned columns with the requested sku and quantity fields. Restore the projection after inspecting the result.

What to look for
The projection keeps warehouse and the internal document ID out of the returned shape. Passing the filter alone does not establish that the returned fields match the contract.