diff --git a/task.sql b/task.sql index 0a66d93..1b4d875 100644 --- a/task.sql +++ b/task.sql @@ -1 +1,32 @@ -# 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, + Name VARCHAR(50), + Description VARCHAR(50), + Price INT, + WarehouseAmount INT +); +CREATE TABLE Customers ( + ID INT AUTO_INCREMENT PRIMARY KEY, + FirstName VARCHAR(50), + LastName VARCHAR(50), + Email VARCHAR(50), + Address VARCHAR(50) +); + +CREATE TABLE Orders ( + ID INT AUTO_INCREMENT PRIMARY KEY, + CustomerID INT, + Date DATE, + FOREIGN KEY (CustomerID) REFERENCES Customers(ID) ON DELETE SET NULL +); +CREATE TABLE OrderItems ( + ID INT AUTO_INCREMENT PRIMARY KEY, + OrderID INT, + ProductID INT, + FOREIGN KEY (OrderID) REFERENCES Orders(ID) ON DELETE SET NULL, + FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE SET NULL +);