Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions task.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ USE ShopDB;
START TRANSACTION;

-- And some data should be created inside the transaction
INSERT INTO Orders (CustomerID, Date) VALUES(1, CURDATE());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The task explicitly mentions that the order can be created using any date, for example 2023-01-01. Using CURDATE() is logically fine, but to match the requirement and possible tests more strictly, consider replacing CURDATE() with a fixed literal date like '2023-01-01'.

INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES(LAST_INSERT_ID(), 1, 1);
UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update correctly decreases WarehouseAmount for product ID = 1 by the ordered count (1 here), matching the business rule. If you ever change the quantity in the OrderItems insert, consider using the same value here instead of a hard-coded 1 to keep them in sync.


COMMIT;
Loading