Skip to content

Solution for Transactions#195

Open
maxmlv wants to merge 1 commit into
mate-academy:mainfrom
maxmlv:develop
Open

Solution for Transactions#195
maxmlv wants to merge 1 commit into
mate-academy:mainfrom
maxmlv:develop

Conversation

@maxmlv

@maxmlv maxmlv commented Jun 22, 2026

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

I am approving your solution because it correctly implements the full transactional flow: creating an order for customer ID = 1, adding an OrderItems row for AwesomeProduct (ProductID = 1, Count = 1), and updating Products.WarehouseAmount inside a single transaction. Functionally, nothing is broken: the inserts and update follow the business rules, and the transaction usage ensures atomicity and consistency. The main concern raised is that you used CURDATE() instead of a fixed literal date like '2023-01-01'; this is not a functional blocker, but it may cause mismatches with strict tests, so I recommend you switch to a hard-coded date in the Orders insert to align perfectly with the task wording. Similarly, if you later change the ordered quantity, it would be more robust to reference that same count in the UPDATE Products statement instead of a hard-coded 1, so they always stay in sync. Overall, your solution demonstrates a solid understanding of transactions and the required schema interactions—only small, non-blocking refinements are suggested.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment thread task.sql
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'.

Comment thread task.sql
-- And some data should be created inside the transaction
INSERT INTO Orders (CustomerID, Date) VALUES(1, CURDATE());
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants