-
Notifications
You must be signed in to change notification settings - Fork 156
solution1 #160
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
base: main
Are you sure you want to change the base?
solution1 #160
Changes from 1 commit
456c505
b3b844e
726e40e
5cb1c3b
c2cf9b7
ef19a5c
4b7b316
ba21dd9
f4fe43a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,37 @@ | ||
| -- Create database and tables | ||
| CREATE DATABASE ShopDB | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the requirements, the script should first delete the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script will fail because you're trying to use the |
||
| CREATE DATABASE ShopDB; | ||
| USE ShopDB; | ||
|
|
||
| CREATE TABLE Countries ( | ||
| ID INT, | ||
| Name VARCHAR(50), | ||
| PRIMARY KEY (ID) | ||
| ); | ||
| Create Table Countries ( | ||
| ID INT AUTO_INCREMENT, | ||
| PRIMARY KEY (ID), | ||
| NAME VARCHAR(50) | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| CREATE TABLE ProductInventory ( | ||
| ID INT, | ||
| ProductName VARCHAR(50), | ||
| WarehouseAmount INT, | ||
| CREATE TABLE Warehouses ( | ||
| ID INT AUTO_INCREMENT, | ||
| PRIMARY KEY (ID), | ||
| WarehouseName VARCHAR(50), | ||
| WarehouseAddress VARCHAR(50), | ||
| WarehouseAddress VARCHAR(50), | ||
| CountryID INT, | ||
| FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION, | ||
| PRIMARY KEY (ID) | ||
| ); | ||
|
|
||
| -- Populate test data | ||
|
|
||
| INSERT INTO Countries (ID,Name) | ||
| VALUES (1, 'Country1'); | ||
| INSERT INTO Countries (ID,Name) | ||
| VALUES (2, 'Country2'); | ||
|
|
||
| INSERT INTO ProductInventory (ID,ProductName,WarehouseAmount,WarehouseName,WarehouseAddress,CountryID) | ||
| VALUES (1, 'AwersomeProduct', 2, 'Warehouse-1', 'City-1, Street-1',1); | ||
| INSERT INTO ProductInventory (ID,ProductName,WarehouseAmount,WarehouseName,WarehouseAddress,CountryID) | ||
| VALUES (2, 'AwersomeProduct', 5, 'Warehouse-2', 'City-2, Street-2',2); | ||
| FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
|
|
||
| CREATE TABLE ProductInventory ( | ||
| ID INT AUTO_INCREMENT, | ||
| PRIMARY KEY (ID), | ||
| Name VARCHAR(50), | ||
| Amount INT, | ||
| WarehouseID INT, | ||
| FOREIGN KEY (WarehouseID) REFERENCES Warehouses(ID) ON DELETE NO ACTION | ||
| ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
|
|
||
| INSERT INTO Countries (NAME) | ||
| VALUES ('Country1'), ('Country2'); | ||
|
|
||
|
|
||
| INSERT INTO Warehouses (WarehouseName, WarehouseAddress, CountryID) | ||
| VALUES ('Warehouse-1', 'City-1, Street-1', 1), ('Warehouse-2', 'City-2, Street-1', 2); | ||
|
|
||
| INSERT INTO ProductInventory (Name, Amount, WarehouseID) | ||
| VALUES ('Product-1', 2, 1), ('Product-2', 5, 2) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
CREATE DATABASEstatement is missing a semicolon at the end. Each SQL statement should be properly terminated for the script to be valid.