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 #57

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

Solution #57

wants to merge 2 commits into from

Conversation

DavidDubovik
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 SQL script! 😊 While you've done a great job meeting most of the task requirements, there are a few critical issues that need to be addressed to ensure the functionality and integrity of the database:

  1. Column Naming:

    • In the Products table, the column ProductName should be renamed to Name to match the task requirements.
    • In the Orders table, the primary key column should be renamed from OrdersID to ID.
    • In the OrderItems table, the primary key column should be renamed from OrderItemsID to ID.
  2. Data Type Adjustments:

    • The Address column in the Customers table should be changed from VARCHAR(255) to VARCHAR(100) as specified in the requirements.
  3. Foreign Key Constraints:

    • The ProductID in the OrderItems table, OrderID in the OrderItems table, and CustomerID in the Orders table need to be defined as NULL to support the ON DELETE SET NULL behavior.

These changes are necessary to ensure that the database schema aligns with the task requirements and functions correctly. Once these issues are resolved, your solution will be ready for approval. 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.

OrdersID INT AUTO_INCREMENT,
CustomerID INT,
Date DATE,
FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL,

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 in the Orders table uses ON DELETE SET NULL. However, CustomerID is an INT and cannot be set to NULL unless it is explicitly defined as NULL. Consider changing CustomerID INT to CustomerID INT NULL to allow this behavior.

OrderItemsID INT AUTO_INCREMENT,
OrderID INT,
ProductID INT,
FOREIGN KEY (OrderID) REFERENCES Orders(OrdersID) ON DELETE SET NULL,

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 in the OrderItems table uses ON DELETE SET NULL. However, OrderID is an INT and cannot be set to NULL unless it is explicitly defined as NULL. Consider changing OrderID INT to OrderID INT NULL to allow this behavior.

OrderID INT,
ProductID INT,
FOREIGN KEY (OrderID) REFERENCES Orders(OrdersID) ON DELETE SET NULL,
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE SET NULL,

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 in the OrderItems table uses ON DELETE SET NULL. However, ProductID is an INT and cannot be set to NULL unless it is explicitly defined as NULL. Consider changing ProductID INT to ProductID INT NULL to allow this behavior.

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 submission! 🎉 While your SQL script is mostly correct, there are a few critical issues that need to be addressed to fully align with the task requirements:

  1. Column Naming:

    • In the Products table, rename the column ProductName to Name.
    • In the Orders table, rename the primary key column from OrdersID to ID.
    • In the OrderItems table, rename the primary key column from OrderItemsID to ID.
  2. Data Type Adjustments:

    • Change the Address column in the Customers table from VARCHAR(255) to VARCHAR(100).
  3. Foreign Key Constraints:

    • Define ProductID in the OrderItems table, OrderID in the OrderItems table, and CustomerID in the Orders table as INT NULL to support the ON DELETE SET NULL behavior.

These changes are crucial for ensuring that your database schema functions correctly and meets the specified requirements. Please review these comments and make the necessary adjustments to improve your code. Keep up the great work and continue learning from these experiences! 🚀

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

FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(50),
Address VARCHAR(255),

Choose a reason for hiding this comment

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

The Address column in the Customers table should be changed from VARCHAR(255) to VARCHAR(100) as specified in the task requirements.

);

CREATE TABLE Orders (
OrdersID INT AUTO_INCREMENT,

Choose a reason for hiding this comment

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

The primary key column in the Orders table should be renamed from OrdersID to ID to match the task requirements.

OrdersID INT AUTO_INCREMENT,
CustomerID INT,
Date DATE,
FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL,

Choose a reason for hiding this comment

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

The CustomerID column should be defined as INT NULL to support the ON DELETE SET NULL behavior.

);

CREATE TABLE OrderItems (
OrderItemsID INT AUTO_INCREMENT,

Choose a reason for hiding this comment

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

The primary key column in the OrderItems table should be renamed from OrderItemsID to ID to match the task requirements.


CREATE TABLE OrderItems (
OrderItemsID INT AUTO_INCREMENT,
OrderID INT,

Choose a reason for hiding this comment

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

The OrderID column should be defined as INT NULL to support the ON DELETE SET NULL behavior.

CREATE TABLE OrderItems (
OrderItemsID INT AUTO_INCREMENT,
OrderID INT,
ProductID INT,

Choose a reason for hiding this comment

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

The ProductID column should be defined as INT NULL to support the ON DELETE SET NULL behavior.

Copy link

@Alkaponees Alkaponees left a comment

Choose a reason for hiding this comment

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

LGMT!

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.

3 participants