Learn SQL Lesson

Feel the Delete Anomaly

The flat table also has a delete problem. Product facts exist only because they are attached to order rows.

If a product appears in exactly one row, deleting that order would also delete the only stored record of that product. The database would forget that the product ever existed.

Try finding the products that are hanging by a single row.

Practice challenge

Find the products that appear in exactly one order row. Return product_name and row_count, ordered by product_name.

Open interactive editor