Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #56

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Solution #56

wants to merge 2 commits into from

Conversation

fredisson11
Copy link

No description provided.

Copy link

@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.


Thank you for your hard work on this task! 😊 However, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Normalization to 3NF: The task requires the database to be normalized to the third normal form (3NF). While you have made progress by splitting the tables, the current structure does not fully comply with the task description. Specifically, ensure that all non-key attributes are fully functionally dependent only on the primary key.

  2. INSERT Statements: The INSERT statements should match the new database structure. Currently, they do not align with the structure described in the task, particularly regarding the ProductInventory table.

  3. Missing DROP Statement: The task specifies that the existing ShopDB database should be dropped if it exists. Please include a DROP DATABASE ShopDB; statement at the beginning of your script.

  4. AUTO_INCREMENT for IDs: Consider adding AUTO_INCREMENT to the ID columns to ensure unique IDs are automatically generated for new entries.

  5. Foreign Key Constraints: Review the ON DELETE NO ACTION constraints. If you want to allow deletions and automatically remove associated records, consider using ON DELETE CASCADE.

Please address these issues to meet the task requirements. Once these changes are made, your solution will be much closer to the desired outcome. Keep up the great work, and don't hesitate to reach out if you need further assistance! 🚀

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

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

task.sql Outdated
ID INT,
Name VARCHAR(50),
PRIMARY KEY (ID)
ID INT,

Choose a reason for hiding this comment

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

Consider adding AUTO_INCREMENT to the ID column to automatically generate unique IDs for new entries.

Copy link
Author

Choose a reason for hiding this comment

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

Done

task.sql Outdated
);

CREATE TABLE Warehouses (
ID INT,

Choose a reason for hiding this comment

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

Consider adding AUTO_INCREMENT to the ID column to automatically generate unique IDs for new entries.

Copy link
Author

Choose a reason for hiding this comment

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

Done

task.sql Outdated
);

CREATE TABLE Products (
ID INT,

Choose a reason for hiding this comment

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

Consider adding AUTO_INCREMENT to the ID column to automatically generate unique IDs for new entries.

Copy link
Author

Choose a reason for hiding this comment

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

Done

task.sql Outdated
CountryID INT,
FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION,
PRIMARY KEY (ID)
ID INT,

Choose a reason for hiding this comment

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

Consider adding AUTO_INCREMENT to the ID column to automatically generate unique IDs for new entries.

Copy link
Author

Choose a reason for hiding this comment

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

Done

task.sql Outdated
CountryID INT,

PRIMARY KEY (ID),
FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION

Choose a reason for hiding this comment

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

The ON DELETE NO ACTION constraint means that you cannot delete a country if there are warehouses associated with it. Ensure this is the desired behavior. If you want to allow deletion and automatically remove associated warehouses, consider using ON DELETE CASCADE.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

task.sql Outdated
WarehouseID INT,

PRIMARY KEY (ID),
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE NO ACTION,

Choose a reason for hiding this comment

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

The ON DELETE NO ACTION constraint means that you cannot delete a product if there are inventory records associated with it. Ensure this is the desired behavior. If you want to allow deletion and automatically remove associated inventory records, consider using ON DELETE CASCADE.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

task.sql Outdated

PRIMARY KEY (ID),
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE NO ACTION,
FOREIGN KEY (WarehouseID) REFERENCES Warehouses(ID) ON DELETE NO ACTION

Choose a reason for hiding this comment

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

The ON DELETE NO ACTION constraint means that you cannot delete a warehouse if there are inventory records associated with it. Ensure this is the desired behavior. If you want to allow deletion and automatically remove associated inventory records, consider using ON DELETE CASCADE.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link

@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.

Great job on your SQL script! 🎉 You've made significant progress in addressing previous issues, and your code meets the task requirements. Here are some key points and areas for improvement:

  1. Normalization to 3NF: Your database is well-structured and normalized to the third normal form. The separation into tables like Countries, Warehouses, Products, and ProductInventory ensures that all non-key attributes are fully functionally dependent only on the primary key. Keep up the good work!

  2. INSERT Statements: The INSERT statements are correctly aligned with the table structure and populate the tables with the required test data. This is a crucial step for maintaining data integrity.

  3. AUTO_INCREMENT for IDs: You've correctly implemented AUTO_INCREMENT for ID columns, ensuring unique IDs for new entries. This is essential for maintaining data consistency.

  4. Foreign Key Constraints: The use of ON DELETE CASCADE for foreign key constraints is appropriate for maintaining referential integrity. This ensures that deletions are handled correctly and related records are automatically removed.

  5. Critical Issue - Missing DROP Statement: One critical area to address is the missing DROP DATABASE IF EXISTS ShopDB; statement. Including this at the beginning of your script will ensure that the database is dropped if it already exists, preventing potential conflicts.

Overall, your solution is solid, and the decision to approve is to help you move forward with your learning. Please review the comments to improve your code further. Addressing the critical issue mentioned will enhance the functionality and robustness of your script. Keep up the great work, and continue to learn from your experiences! 🚀

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

@@ -1,33 +1,55 @@
-- Create database and tables

CREATE DATABASE ShopDB;

Choose a reason for hiding this comment

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

Consider adding DROP DATABASE IF EXISTS ShopDB; before creating the database to ensure it is dropped if it already exists.

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