task CREATE / ALTER · easy
Create a wishlist table
Create a table wishlist with shopper_id INTEGER NOT NULL, item_id INTEGER NOT NULL and added_on TEXT, where (shopper_id, item_id) is the primary key. Insert (1, 12, '2025-03-01') and (2, 4, '2025-03-02'), then return all wishlist rows ordered by shopper_id.
what to return
- Columns
shopper_iditem_idadded_onin this order- Rows
- 2 rows · in the order asked
- Watch for
- The same shopper can't list the same item twice.
- Neither id may be NULL.
- Skill
- Define a table with a composite primary key and NOT NULL columns. Refresher: Constraints protect the data contract →
expected result
Your query should return exactly these columns and values. Run it and compare.
expected result2 rows · in this order
| shopper_id | item_id | added_on |
|---|---|---|
| 1 | 12 | 2025-03-01 |
| 2 | 4 | 2025-03-02 |
all 2 rows
data you can query
Sample rows from each table. Each column shows its type underneath; → marks a link to another table.
shoppers5 columns · 17 rows
| idinteger · key | nametext | emailtext | regiontext | signup_datetext |
|---|---|---|---|---|
| 1 | Ana Ruiz | ana@harbor.test | West | 2025-01-03 |
| 2 | Ben Okafor | ben@harbor.test | East | 2025-01-05 |
| 3 | Chloe Park | chloe@harbor.test | West | 2025-01-09 |
| 4 | Dmitri Volkov | dmitri@harbor.test | North | 2025-01-14 |
| 5 | Esi Mensah | NULL | South | 2025-01-20 |
showing 5 of 17 rows
catalog_items4 columns · 13 rows
| idinteger · key | nametext | categorytext | pricereal |
|---|---|---|---|
| 1 | Desk Lamp | Lighting | 39 |
| 2 | Floor lamp | Lighting | 89 |
| 3 | String Lights | Lighting | 19.5 |
| 4 | Chef Knife | Kitchen | 59 |
| 5 | Cast Iron Pan | Kitchen | 45 |
showing 5 of 13 rows
solution.sql
Hints and the answer are always available. Using them counts the question as solved with help.