Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion task.sql
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# Write your SQL code for the database creation here. Good luck!
CREATE DATABASE ShopDB;

USE ShopDB;

CREATE TABLE Products (
ID INT AUTO_INCREMENT,
PRIMARY KEY (ID),
Name VARCHAR(50),
Description VARCHAR(200),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The data type for the Description column does not match the requirements. The task specifies using only INT, DATE, VARCHAR(50), or VARCHAR(100). VARCHAR(200) is not on the list.

Price DECIMAL(10, 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.

While DECIMAL is generally a good choice for a price, the task requirements restrict the allowed data types to INT, DATE, VARCHAR(50), or VARCHAR(100). Please choose one of the specified types for the Price column.

WarehouseAmount INT
);

CREATE TABLE Customers (
ID INT AUTO_INCREMENT,
PRIMARY KEY (ID),
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100),
Address VARCHAR(100)
);

CREATE TABLE Orders (
ID INT AUTO_INCREMENT,
PRIMARY KEY (ID),
CustomerID INT,
FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE CASCADE,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The requirements specify using ON DELETE SET NULL for all foreign key relationships. This constraint uses ON DELETE CASCADE instead.

Date DATE
);

CREATE TABLE OrderItems(
ID INT AUTO_INCREMENT,
PRIMARY KEY (ID),
OrderID INT,
FOREIGN KEY (OrderID) REFERENCES Orders(ID) ON DELETE CASCADE,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to the task description, all foreign keys should use the ON DELETE SET NULL clause. Please update this constraint accordingly.

ProductID INT,
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE NO ACTION
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 foreign key constraint should use ON DELETE SET NULL as required by the task description, not ON DELETE NO ACTION.

);
Loading