Skip to content

Solution#122

Open
VladislaveUst wants to merge 5 commits into
mate-academy:mainfrom
VladislaveUst:feature/add-instruction
Open

Solution#122
VladislaveUst wants to merge 5 commits into
mate-academy:mainfrom
VladislaveUst:feature/add-instruction

Conversation

@VladislaveUst

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

Great job starting the database normalization process! You've correctly identified the need for new tables like Products and Warehouses. However, the current SQL script has a few critical issues that prevent it from running successfully.

To get it working, please address the following:

  1. Missing Semicolon: The script fails immediately because of a missing semicolon at the end of the DROP DATABASE statement on line 2.
  2. Missing Warehouses Table: Your ProductInventory table and an INSERT statement both reference a Warehouses table, but the CREATE TABLE statement for it is missing from the script.
  3. Duplicate Table Definition: The ProductInventory table is defined twice (starting on line 12 and line 26). Please remove the first, unnormalized definition.
  4. Incorrect Column Name: The final INSERT statement (line 43) uses the column name Amount, but your new ProductInventory table definition uses WarehouseAmount. These need to match.

Once these items are fixed, your normalized database schema should work as intended. Keep up the great work!


✨ 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
@@ -1,5 +1,5 @@
-- Create database and tables

DROP DATABASE IF EXISTS 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.

It's a good practice to end every SQL statement with a semicolon. This line is missing one.

Comment thread task.sql
Comment on lines +29 to +37
CREATE TABLE ProductInventory (
ID INT AUTO_INCREMENT,
ProductID INT NOT NULL,
WarehouseID INT NOT NULL,
WarehouseAmount INT NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE CASCADE,
FOREIGN KEY (WarehouseID) REFERENCES Warehouses(ID) ON DELETE CASCADE
);

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 ProductInventory table definition is a good step towards normalization! However, it has a dependency on a Warehouses table (see the foreign key on line 36), which is never created in this script. As part of normalizing the database to the third normal form, you need to extract warehouse information (WarehouseName, WarehouseAddress) into its own Warehouses table and create it here.

Comment thread task.sql
Comment on lines +43 to +44
INSERT INTO Warehouses (Name, Address, CountryID)
VALUES ('Warehouse-1', 'City-1, Street-1', 1), ('Warehouse-2', 'City-2, Street-2', 2);

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 INSERT statement will fail because the Warehouses table it's trying to add data to has not been created. You'll need to add a CREATE TABLE Warehouses statement before this line for the script to work.

Comment thread task.sql Outdated
Comment on lines +49 to +50
INSERT INTO ProductInventory (ProductID, WarehouseID, Amount)
VALUES (1, 1, 2), (1, 2, 5);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's a small mismatch here that will cause an error. The INSERT statement refers to a column named Amount, but in your new ProductInventory table definition on line 33, the column is named WarehouseAmount. These names need to match for the query to succeed.

@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

Excellent work on this submission! You've successfully addressed all the feedback from the previous review, and your task.sql script now fully meets all requirements. The database schema is correctly normalized to the Third Normal Form, with all tables and constraints created properly. The test data is also inserted correctly into the new structure. Your script is clean, logical, and ready to go. Great job!


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

Footnotes

  1. Rate AI review example

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