Skip to content

Commit

Permalink
fix error with create sql table shopDB
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksimGolev committed Nov 3, 2024
1 parent 8ebc6cf commit 99c36b4
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions task.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,32 @@ CREATE TABLE Warehouses (
PRIMARY KEY (ID)
);

CREATE TABLE Products (
ID INT,
Name VARCHAR(50),
PRIMARY KEY (ID)
);

CREATE TABLE ProductInventory (
ID INT,
ProductName VARCHAR(50),
ProductID VARCHAR(50),
WarehouseAmount INT,
WarehousesID INT,
FOREIGN KEY (WarehousesID) REFERENCES Warehouses(ID) ON DELETE NO ACTION,
FOREIGN KEY (WarehousesID) REFERENCES Warehouses(ID) ON DELETE NO ACTION,
FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE NO ACTION,
PRIMARY KEY (ID)
);

INSERT INTO Countries (ID,Name)
VALUES (1, 'Country1');
INSERT INTO Countries (ID,Name)
VALUES (2, 'Country2');
INSERT INTO Countries (ID, Name)
VALUES (1, 'Country1'), (2, 'Country2');

INSERT INTO Warehouses (ID,WarehouseName,WarehouseAddress,CountryID)
VALUES (1, 'Warehouse-1', 'City-1, Street-1',1);
INSERT INTO Warehouses (ID,WarehouseName,WarehouseAddress,CountryID)
VALUES (2, 'Warehouse-2', 'City-2, Street-2',2);
INSERT INTO Warehouses (ID, WarehouseName, WarehouseAddress, CountryID)
VALUES (1, 'Warehouse-1', 'City-1, Street-1', 1),
(2, 'Warehouse-2', 'City-2, Street-2', 2);

INSERT INTO Products (ID, ProductName)
VALUES (1, 'AwersomeProduct');

INSERT INTO ProductInventory (ID,ProductName,WarehouseAmount,WarehousesID)
VALUES (1, 'AwersomeProduct', 2, 1);
INSERT INTO ProductInventory (ID,ProductName,WarehouseAmount,WarehousesID)
VALUES (2, 'AwersomeProduct', 5, 2);
INSERT INTO ProductInventory (ID, ProductID, WarehouseAmount, WarehousesID)
VALUES (1, 1, 2, 1),
(2, 1, 5, 2);

0 comments on commit 99c36b4

Please sign in to comment.