-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yuriy P
committed
Feb 5, 2024
1 parent
afc2036
commit 4a9f520
Showing
1 changed file
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,43 @@ | ||
# 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(100), | ||
Description VARCHAR(100), | ||
Price DECIMAL(10 , 2 ), | ||
WarehouseAmount INT | ||
); | ||
|
||
|
||
CREATE TABLE Customers ( | ||
ID INT AUTO_INCREMENT PRIMARY KEY, | ||
FirstName VARCHAR(50), | ||
LastName VARCHAR(50), | ||
Email VARCHAR(100), | ||
Address VARCHAR(100) | ||
); | ||
|
||
|
||
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 | ||
); |