Skip to content

Normalize the database ShopDB#159

Open
AndS9 wants to merge 3 commits intomate-academy:mainfrom
AndS9:develop
Open

Normalize the database ShopDB#159
AndS9 wants to merge 3 commits intomate-academy:mainfrom
AndS9:develop

Conversation

@AndS9
Copy link
Copy Markdown

@AndS9 AndS9 commented Mar 28, 2026

No description provided.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Review Summary

Great job identifying the need to normalize the warehouse data! That's a solid first step. However, this requires changes because the schema isn't fully in the third normal form (3NF) yet, which is causing the automated tests to fail.

The main issue is that ProductName is still in the ProductInventory table, creating data redundancy. To fix this and meet the 3NF requirement, you'll need to:

  1. Create a separate Products table for product information.
  2. Replace ProductName in ProductInventory with a foreign key that references the new Products table.

Also, please remember to add the DROP DATABASE IF EXISTS ShopDB; statement at the beginning of your script, as this was a specific requirement.

Once these changes are made, your solution should pass the tests. You're on the right track!


✨ 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

WarehouseAddress VARCHAR(50),
CountryID INT,
FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION,
WarehouseID INT,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While this table might seem to be in 3NF with ID as the primary key, it doesn't fully meet the goals of normalization. The ProductName column creates data redundancy (e.g., 'AwesomeProduct' is repeated), which can lead to update, insertion, and deletion anomalies. A better 3NF design would involve creating a separate Products table for product information and using a ProductID foreign key in this table instead of ProductName.

Copy link
Copy Markdown

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

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 normalizing the database schema to the third normal form! The new table structure and updated INSERT statements are perfect. However, one critical requirement is missing. The script fails if it's run more than once because it tries to create a database that already exists. To fix this, please add the following command at the very top of your task.sql file:

DROP DATABASE IF EXISTS ShopDB;

This will ensure your script can be run multiple times without errors. After this small change, your solution will be ready for approval!


✨ 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

Copy link
Copy Markdown

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

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 task! I am approving your solution as you have successfully met all the requirements. You've done a great job normalizing the database schema to the third normal form and correctly updating the INSERT statements to work with the new structure. Adding the DROP DATABASE command at the top ensures the script is robust and re-runnable. This is a complete and well-executed solution. Keep up the fantastic work!


✨ 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