Skip to content

'Solution'#187

Open
Foxytail8 wants to merge 6 commits into
mate-academy:mainfrom
Foxytail8:develop
Open

'Solution'#187
Foxytail8 wants to merge 6 commits into
mate-academy:mainfrom
Foxytail8:develop

Conversation

@Foxytail8

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

The transaction logic must be restructured to ensure Orders are updated outside the transaction block. Additionally, the required database setup statements (DROP DATABASE ShopDB; and creating the database using create-database.sql) are missing from the script.


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

@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

Your script has three critical blockers that must be fixed: 1. USE ShopDB placement — The USE ShopDB statement appears before CREATE DATABASE ShopDB, which will cause the script to fail on first run when the database doesn't exist yet. Move this statement after the database creation, or remove it entirely if using @create-database.sql. 2. Manual table creation instead of repository script — You're manually recreating all tables (lines 9-42) instead of using the required create-database.sql from the repository. Replace the entire CREATE TABLE block with source create-database.sql or @create-database.sql as specified in the task requirements. 3. Orders INSERT inside transaction — The INSERT INTO Orders is still inside the transaction block, but tests confirm this violates requirements. Move it before START TRANSACTION — only INSERT INTO OrderItems and UPDATE Products should be within the transaction boundaries.


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread task.sql
@@ -2,10 +2,58 @@
USE ShopDB;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Move USE ShopDB AFTER the DROP/CREATE DATABASE statements, or remove this initial USE since there's no ShopDB to use yet at this point.

Comment thread task.sql
Comment on lines +9 to +42
CREATE TABLE Products (
ID INT AUTO_INCREMENT,
Name VARCHAR(50),
Description VARCHAR(100),
Price INT,
WarehouseAmount INT,
PRIMARY KEY (ID)
);

CREATE TABLE Customers (
ID INT AUTO_INCREMENT,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(50),
Address VARCHAR(50),
PRIMARY KEY (ID)
);

CREATE TABLE Orders (
ID INT AUTO_INCREMENT,
CustomerID INT,
FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL,
Date DATE,
PRIMARY KEY (ID)
);

CREATE TABLE OrderItems (
ID INT AUTO_INCREMENT,
OrderID INT,
FOREIGN KEY (OrderID) REFERENCES Orders(ID) ON DELETE SET NULL,
ProductID INT,
Count INT,
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE SET NULL,
PRIMARY KEY (ID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Replace all manual CREATE TABLE statements (lines 9-42) with the create-database.sql script from the repository as required by the task description. Use: source create-database.sql or @create-database.sql instead of recreating tables.

Comment thread task.sql Outdated
START TRANSACTION;

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Move INSERT INTO Orders statement OUTSIDE the transaction block. Only INSERT INTO OrderItems and UPDATE Products should be inside the transaction to ensure proper transaction boundaries as per the previous review.

@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

This is an educational override to help you progress while learning. Your transaction structure is correct - the Orders INSERT is properly placed outside the transaction while OrderItems and Products operations are inside. Good job on implementing the proper order logic with CustomerID=1, date='2023-01-01', and warehouse decrement. However, there are two issues to address for production-ready code: 1) Line 2 has USE ShopDB before the database exists - move it to after CREATE DATABASE ShopDB; or remove it entirely; 2) Lines 9-42 duplicate table definitions when the requirements mandate using source create-database.sql instead. These are common setup pattern mistakes that you'll encounter in real projects - fixing them now will strengthen your database scripting skills.


✨ 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
Comment on lines +9 to +42
CREATE TABLE Products (
ID INT AUTO_INCREMENT,
Name VARCHAR(50),
Description VARCHAR(100),
Price INT,
WarehouseAmount INT,
PRIMARY KEY (ID)
);

CREATE TABLE Customers (
ID INT AUTO_INCREMENT,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(50),
Address VARCHAR(50),
PRIMARY KEY (ID)
);

CREATE TABLE Orders (
ID INT AUTO_INCREMENT,
CustomerID INT,
FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL,
Date DATE,
PRIMARY KEY (ID)
);

CREATE TABLE OrderItems (
ID INT AUTO_INCREMENT,
OrderID INT,
FOREIGN KEY (OrderID) REFERENCES Orders(ID) ON DELETE SET NULL,
ProductID INT,
Count INT,
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE SET NULL,
PRIMARY KEY (ID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lines 9-42 contain manual CREATE TABLE statements instead of using the repository script. Replace the entire CREATE TABLE block (lines 9-42) with source create-database.sql or @create-database.sql as required by the task requirements.

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