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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all 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
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 (
ProductID INT AUTO_INCREMENT,
Name VARCHAR(50),
Description VARCHAR(50),
Price DECIMAL(10,2),
WarehouseAmount INT,
PRIMARY KEY (ProductID)
);

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

CREATE TABLE Orders (
OrderID INT AUTO_INCREMENT,
CustomerID INT NULL,
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID) ON DELETE SET NULL,
Date DATE,
PRIMARY KEY (OrderID)
);

CREATE TABLE OrderItems (
OrderItemID INT AUTO_INCREMENT,
OrderID INT NULL,
FOREIGN KEY (OrderID) REFERENCES Orders(OrderID) ON DELETE SET NULL,
ProductID INT NULL,
FOREIGN KEY (ProductID) REFERENCES Products(ProductID) ON DELETE SET NULL,
PRIMARY KEY (OrderItemID)
);
Loading