Skip to content

Commit

Permalink
Modified task.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
L1mbxbx committed Nov 19, 2024
1 parent afc2036 commit 2c1e245
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions task.sql
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# 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) NOT NULL,
Description VARCHAR(100),
Price DECIMAL(10, 2) NOT NULL,
WarehouseAmount INT
);

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

CREATE TABLE Orders (
ID INT AUTO_INCREMENT PRIMARY KEY,
CustomerID INT,
Date DATE NOT NULL,
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
)

0 comments on commit 2c1e245

Please sign in to comment.