Timedora
Free Online Flashcard Deck

SQL Joins and Query Grain Free Online Flashcards

Study SQL Joins and Query Grain with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

Why can an orders-to-order_items join inflate an order-level sum?

Back

Joining orders to line items repeats order-level attributes for each matching item. This is expected for line-level analysis but can inflate an order-level measure if summed.

02
Front

What does a query’s output grain describe?

Back

The grain is the level of detail represented by each output row. State it before writing the query so you can choose suitable tables, joins, and aggregations.

03
Front

How do grouping columns define an aggregated query’s output?

Back

The grouping columns define what each output row means. Aggregate only measures appropriate to that level of detail.

04
Front

Do unexpected extra rows prove that source data is wrong?

Back

No. More rows than expected warrant checking table relationships, keys, and query grain, but may reflect valid events rather than bad source data.

05
Front

What should be specified before writing a business query?

Back

Define the measure, output grain, time basis, and scope first. Then choose tables that provide the required details, such as dates, prices, or product categories.

06
Front

How can you validate whether aggregated results are interpretable?

Back

Make rules for missing values, canceled or refunded transactions, and unmatched lookups explicit. Check a small sample against known records and reconcile totals with a trusted report when possible.

07
Front

What should you inspect before joining tables?

Back

Check what each row represents, which keys connect the tables, whether keys are unique, and how many matches each row can have. This reveals whether a join may multiply rows.

08
Front

How can you safely combine order-level payments with line-level sales?

Back

Aggregate payments to one row per order before joining them with order-level data. Joining raw payments directly to raw items can multiply rows when an order has several of each.

09
Front

Does adding DISTINCT fix an inflated sum from a faulty join?

Back

No. DISTINCT may hide a faulty join, but it does not correct an inflated sum caused by multiplied rows.

10
Front

What does grouping by month and category produce in a completed-orders sales query?

Back

Grouping by month and category produces one result per month-and-category combination; SUM calculates revenue across line items in each group. The example filters to completed orders.

11
Front

What checks help locate the cause of unexpected duplicate rows?

Back

Compare row counts before and after each join, check whether the presumed key is unique, and group by the expected key to find multiple matches.

12
Front

How should a query plan be corrected after finding row multiplication?

Back

Determine whether matches are valid events, repeated source records, or caused by an incorrect join condition. Then correct the join, choose a suitable starting grain, or aggregate one side before joining.