Will the schema allow a negative item quantity?
In the iv_order_items table, the quantity column is defined as INTEGER NOT NULL. A query inserts an order item with a negative quantity, then reads the new row. Will the schema accept this value, and what will the query return?
Predict the resultDDL, keys, and normalizationJuniorBackendQAData Engineer
Input data · iv_order_items
| id | order_id | product | quantity | price |
|---|---|---|---|---|
| 1 | 1 | pen | 10 | 2.00 |
| 2 | 1 | notebook | 1 | 10.00 |
| 3 | 2 | pen | 1 | 4.00 |
| 4 | 3 | notebook | 5 | 10.00 |
| 5 | 3 | bag | 1 | 50.00 |
| 6 | 4 | pen | 2 | 3.00 |
| 7 | 5 | pen | 3 | 10.00 |
| 8 | 7 | bag | 2 | 60.00 |
| 9 | 8 | notebook | 2 | 40.00 |
Query
INSERT INTO iv_order_items
(id, order_id, product, quantity, price)
VALUES
(10, 1, 'pen', -2, 3.00);
SELECT id,
quantity
FROM iv_order_items
WHERE id = 10
ORDER BY id