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

Added new task.sql #73

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

Added new task.sql #73

wants to merge 3 commits into from

Conversation

tkudinov
Copy link

@tkudinov tkudinov commented Feb 9, 2025

Script for database and tables creation.

Script for database and tables creation.
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 SQL script! 😊 While you've made a great start by setting up the database and tables, there are a few critical issues that need to be addressed to meet the task requirements:

  1. Database Naming: The database is named DBShop instead of ShopDB as specified in the requirements. It's important to follow naming conventions to ensure consistency.

  2. Data Type for Price: The Price column in the Products table is currently set as VARCHAR(50). This is not suitable for storing numerical values. Please consider using a numeric data type like DECIMAL or FLOAT for accurate price representation.

  3. Foreign Key Constraints: The foreign key constraints are using ON DELETE NO ACTION, whereas the requirements specify ON DELETE SET NULL. This behavior is crucial for maintaining data integrity according to the specified business logic.

These changes are essential to ensure the database functions correctly and aligns with the task requirements. Once these issues are resolved, your solution will be much stronger. Keep up the great work, and don't hesitate to reach out if you need further guidance! 🚀

✨ 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 AUTO_INCREMENT,
Name VARCHAR(50),
Description VARCHAR(100),
Price VARCHAR(50),

Choose a reason for hiding this comment

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

The 'Price' column is defined as VARCHAR(50), which is not suitable for storing numerical values. Consider using a numeric data type such as DECIMAL or FLOAT for storing prices.

task.sql Outdated
CREATE TABLE Orders (
ID INT AUTO_INCREMENT,
CustomerID INT,
FOREIGN KEY (CustomerID) REFERENCES Customers(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 foreign key constraint on 'CustomerID' uses 'ON DELETE NO ACTION'. Consider whether 'NO ACTION' is the desired behavior when a customer is deleted. You might want to use 'CASCADE' or 'SET NULL' depending on the business logic.

task.sql Outdated
CREATE TABLE OrderItems (
ID INT AUTO_INCREMENT,
OrderID INT,
FOREIGN KEY (OrderID) REFERENCES Orders(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 foreign key constraint on 'OrderID' uses 'ON DELETE NO ACTION'. Consider whether 'NO ACTION' is the desired behavior when an order is deleted. You might want to use 'CASCADE' or 'SET NULL' depending on the business logic.

task.sql Outdated
OrderID INT,
FOREIGN KEY (OrderID) REFERENCES Orders(ID) ON DELETE NO ACTION,
ProductID INT,
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 foreign key constraint on 'ProductID' uses 'ON DELETE NO ACTION'. Consider whether 'NO ACTION' is the desired behavior when a product is deleted. You might want to use 'CASCADE' or 'SET NULL' depending on the business logic.

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.

Review Summary

Great job on updating the SQL script! 🎉 Your code in the task.sql file meets the task requirements and constraints as specified. Here's a brief overview:

  • Database Naming: The database is correctly named ShopDB.
  • Table Creation: All required tables (Products, Customers, Orders, OrderItems) are created with the specified columns.
  • Data Types: The data types for each column are appropriately chosen, with Price set as FLOAT, which is suitable for numerical values.
  • Foreign Key Constraints: The foreign key constraints use ON DELETE SET NULL, ensuring data integrity according to the specified business logic.

Your script is well-structured and fulfills all the specified requirements. There are no missing or incorrect elements based on the task description.

Although the decision is to APPROVE to help you move forward with your learning, please review any comments provided to improve your code further. If there are any critical issues, ensure they are addressed in future tasks to avoid similar problems. Keep up the good work and continue learning from your experiences! 🚀

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

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