Timedora
Free Online Flashcard Deck

SQL Joins, Row Grain, and Aggregation Free Online Flashcards

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

12 cards
01
Front

How can you prevent overcounting order totals after a one-to-many join?

Back

Calculate order-level totals from the orders table before joining to item details, or aggregate item data to the order level first.

02
Front

What should you establish first when diagnosing repeated rows after a join?

Back

Define the intended row grain first, then judge whether the join preserves that unit of analysis.

03
Front

How do you test uniqueness for a composite key?

Back

Group by all columns that should jointly identify a row. Checking only part of a composite key may miss non-unique rows.

04
Front

Why can summing order amounts after joining to items overstate revenue?

Back

The order-level amount is repeated on each item row, so summing it across the joined rows can overstate revenue.

05
Front

At what grain should an order-level total be calculated?

Back

Calculate the total at the order grain: aggregate item data by order first, or calculate order totals from the orders table before joining.

06
Front

What can a non-unique key indicate about a table?

Back

A key that is not unique may indicate a data problem, or the table may intentionally contain multiple records at that level. Check the intended grain.

07
Front

Why can a valid one-to-many join increase the row count?

Back

A one-to-many join produces one result row for each matching right-side row. More rows can therefore be expected when the relationship is valid.

08
Front

Does a repeated customer name prove that joined rows are duplicates?

Back

Repeated displayed values are not necessarily duplicate records. For example, a customer's name may appear on multiple rows when each row represents an order.

09
Front

What should you check in the ON condition when a join multiplies rows unexpectedly?

Back

Check that the ON condition includes the complete relationship key. Omitting part of a composite key can create unintended matches.

10
Front

How can join type affect row counts when matches are missing?

Back

An inner join can reduce the left-side count when some left rows have no matches. A left join retains unmatched left rows but can still produce multiple rows for multiple matches.

11
Front

Are multiple matches per order always evidence of a faulty join?

Back

It may be expected: each matching item creates a joined row. Multiple matches are problematic only when they conflict with the intended relationship or analysis.

12
Front

When should you check whether a supposed key is unique?

Back

Check whether the supposed key is unique at the intended level of detail before joining.