Skip to content

solution#109

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

solution#109
xnquaint wants to merge 1 commit into
mate-academy:mainfrom
xnquaint:develop

Conversation

@xnquaint

@xnquaint xnquaint commented Aug 7, 2025

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

Excellent work on this task! Your task.sql script successfully meets all the requirements by correctly normalizing the database schema to the Third Normal Form (3NF).

You've done a fantastic job demonstrating a strong understanding of database design principles. Here are some of the highlights:

  • Excellent Normalization: Creating separate Warehouses and Products tables was the perfect approach. This correctly isolates distinct entities and eliminates the data redundancy and transitive dependencies found in the original structure.
  • Well-Designed Junction Table: The new ProductInventory table perfectly serves as a junction table, using foreign keys to efficiently link products to their stock in specific warehouses.
  • Correct Data Migration: The INSERT statements correctly populate the new tables, ensuring all the original data is preserved in the new, normalized structure.

This is a high-quality, professional solution. As a small suggestion for future projects, you could consider making your scripts idempotent (meaning they can be run multiple times without causing errors). You can do this by adding a DROP DATABASE IF EXISTS ShopDB; command at the top of your script.

DROP DATABASE IF EXISTS ShopDB;
CREATE DATABASE ShopDB;

This is a common best practice that makes scripts easier to re-run during development and testing. It wasn't a requirement here, but it's a useful technique to know.

Overall, this is a fantastic submission. Keep up the great work


✨ 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 +10 to +17
CREATE TABLE Warehouses(
ID INT,
Name VARCHAR(50),
Address VARCHAR(50),
CountryID INT,
FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION,
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.

Excellent work creating a separate Warehouses table. This is a key step in normalization, as it isolates warehouse-specific attributes (Name, Address, CountryID) and eliminates data redundancy from the inventory table.

Comment thread task.sql
Comment on lines +19 to +23
CREATE TABLE Products(
ID INT,
Name VARCHAR(50),
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.

Perfect! Creating a Products table to store product-specific information (Name) is crucial for reaching the third normal form. This avoids data duplication and prevents potential update anomalies.

Comment thread task.sql
Comment on lines 25 to 33
CREATE TABLE ProductInventory (
ID INT,
ProductName VARCHAR(50),
WarehouseAmount INT,
WarehouseName VARCHAR(50),
WarehouseAddress VARCHAR(50),
CountryID INT,
FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION,
ProductID INT,
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE NO ACTION,
WarehouseID INT,
FOREIGN KEY (WarehouseID) REFERENCES Warehouses(ID) ON DELETE NO ACTION,
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.

This is a well-designed junction table. Using foreign keys ProductID and WarehouseID correctly links products to their stock in warehouses, achieving a normalized structure that is both efficient and consistent.

Comment thread task.sql
Comment on lines +40 to +43
INSERT INTO Warehouses(ID, Name, Address, CountryID)
VALUES (1, 'Warehouse-1', 'City-1, Street-1',1);
INSERT INTO Warehouses(ID, Name, Address, CountryID)
VALUES (2, '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.

These INSERT statements correctly populate the new Warehouses table, which is an essential part of migrating the data to the normalized schema.

Comment thread task.sql
Comment on lines +45 to +46
INSERT INTO Products (ID, Name)
VALUES (1, 'AwersomeProduct');

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 correctly populates the Products table with the product data, separating it from the inventory details as required by normalization.

Comment thread task.sql
Comment on lines +48 to +51
INSERT INTO ProductInventory (ID, WarehouseAmount, ProductID, WarehouseID)
VALUES (1, 2, 1, 1);
INSERT INTO ProductInventory (ID, WarehouseAmount, ProductID, WarehouseID)
VALUES (2, 5, 1, 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.

These statements correctly populate the ProductInventory linking table, associating the product with its stock count in each warehouse. This completes the data migration to the new 3NF structure. Well done!

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