Skip to content
Open
Changes from 2 commits
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
29 changes: 28 additions & 1 deletion task.sql
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
# Write your SQL code for the database creation here. Good luck!
use ShopDB;
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 task requires the script to create the database named ShopDB. Add CREATE DATABASE ShopDB; (optionally IF NOT EXISTS) before the USE ShopDB; statement so the schema is created on a fresh server and the rest of the script runs within ShopDB.

CREATE TABLE Products(
ID INT PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(50) NOT NULL,
Description TEXT,
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 Description column uses type TEXT, which is not allowed by the requirements. Choose one of the permitted types (INT, DATE, VARCHAR(50), or VARCHAR(100)); VARCHAR(100) is appropriate for a product description per the checklist.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Description is defined as TEXT, but the assignment restricts column types to INT, DATE, VARCHAR(50), or VARCHAR(100). Change this to an allowed type, for example VARCHAR(100).

Price DECIMAL(10, 2) NOT NULL,
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 Price column uses DECIMAL(10, 2), which is not one of the allowed types. Use one of the allowed types (for example, INT if storing price in cents, or VARCHAR(50) if textual) to satisfy the requirement that column types be limited to INT, DATE, VARCHAR(50), or VARCHAR(100).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Price is currently DECIMAL(10, 2), which is not an allowed type. Use one of the permitted types (for example INT if you store price in cents, or VARCHAR(50)), e.g. Price INT NOT NULL.

WarehouseAmount INT NOT NULL
);
CREATE TABLE Customers(
ID INT PRIMARY KEY AUTO_INCREMENT,
FirstName VARCHAR(50),
LastName VARCHAR(50),
email VARCHAR(50),
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 Customers table must have a column named Email (capital E) per the requirements. This line defines email (lowercase) — rename it to Email to match the specification exactly.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Column name email uses lowercase. The requirement expects exact capitalization Email. Rename this column to Email to match the specification.

address VARCHAR(100)
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 Customers table must have a column named Address (capital A) per the requirements. This line defines address (lowercase) — rename it to Address to match the specification exactly.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Column name address uses lowercase. The requirement expects exact capitalization Address. Rename this column to Address to match the specification.

);
CREATE TABLE Orders(
ID INT PRIMARY KEY AUTO_INCREMENT,
CustomerID INT,
Date DATE,
foreign key (CustomerID) references Customers(ID) on delete set null
);
CREATE TABLE OrderItems(
ID INT PRIMARY KEY AUTO_INCREMENT,
OrderID INT,
ProductID INT,
foreign key (OrderID) references Orders(ID) on delete set null,
foreign key (ProductID) references Products(ID) on delete set null
);
Loading