-
Notifications
You must be signed in to change notification settings - Fork 63
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
Showing
1 changed file
with
33 additions
and
0 deletions.
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,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 | ||
) |