From 97fa58b4e0bec3cbfa65b85130860ec69f194d4e Mon Sep 17 00:00:00 2001 From: dianahorban Date: Sat, 16 May 2026 13:28:56 +0200 Subject: [PATCH 1/8] The solution --- task.sql | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/task.sql b/task.sql index cc65344..555d02a 100644 --- a/task.sql +++ b/task.sql @@ -9,25 +9,50 @@ CREATE TABLE Countries ( PRIMARY KEY (ID) ); -CREATE TABLE ProductInventory ( +CREATE TABLE Warehouse ( ID INT, - ProductName VARCHAR(50), WarehouseAmount INT, WarehouseName VARCHAR(50), - WarehouseAddress VARCHAR(50), + WarehouseAddress VARCHAR(50), CountryID INT, - FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION, + FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION, PRIMARY KEY (ID) ); +CREATE TABLE Product ( + ID INT, + Name VARCHAR(50), + PRIMARY KEY (ID) +); + +CREATE TABLE ProductInventory ( + ID INT, + ProductID INT, + WarehouseID INT, + FOREIGN KEY (ProductID) REFERENCES Product(ID) ON DELETE NO ACTION, + FOREIGN KEY (WarehouseID) REFERENCES Warehouse(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); + +INSERT INTO Product(ID,Name) + VALUES (1, 'AwersomeProduct'); +INSERT INTO Product(ID,Name) + VALUES (2, 'AwersomeProduct'); + +INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) + VALUES (1, 1 , 'Street-1'); +INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) + VALUES (2, 2, 'Street-2'); +INSERT INTO Warehouse (WarehouseAmount,WarehouseName, WarehouseAddress, CountryID) + VALUES (2, 'Warehouse-1', 'City-1', 1); +INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseName, WarehouseAddress, CountryID) + VALUES (2, 5, 'Warehouse-2', 'City-2', 2); + + INSERT INTO ProductInventory (ID, ProductID, WarehouseID) +VALUES (1, 1, 1); From 298e3325331f59fd981264fec53126e404439a88 Mon Sep 17 00:00:00 2001 From: dianahorban Date: Sat, 16 May 2026 13:31:21 +0200 Subject: [PATCH 2/8] The solution --- task.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 555d02a..19a5df8 100644 --- a/task.sql +++ b/task.sql @@ -46,9 +46,9 @@ INSERT INTO Product(ID,Name) VALUES (2, 'AwersomeProduct'); INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) - VALUES (1, 1 , 'Street-1'); + VALUES (1, 1, 'Street-1', 1); INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) - VALUES (2, 2, 'Street-2'); + VALUES (2, 2, 'Street-2', 2); INSERT INTO Warehouse (WarehouseAmount,WarehouseName, WarehouseAddress, CountryID) VALUES (2, 'Warehouse-1', 'City-1', 1); INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseName, WarehouseAddress, CountryID) From a6e91b5ac8c881affb6ee953b558c8b5c5750b38 Mon Sep 17 00:00:00 2001 From: dianahorban Date: Sat, 16 May 2026 13:33:31 +0200 Subject: [PATCH 3/8] The solution --- task.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 19a5df8..61d5517 100644 --- a/task.sql +++ b/task.sql @@ -49,8 +49,8 @@ INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) VALUES (1, 1, 'Street-1', 1); INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) VALUES (2, 2, 'Street-2', 2); -INSERT INTO Warehouse (WarehouseAmount,WarehouseName, WarehouseAddress, CountryID) - VALUES (2, 'Warehouse-1', 'City-1', 1); +INSERT INTO Warehouse (ID, WarehouseAmount,WarehouseName, WarehouseAddress, CountryID) + VALUES (1, 2, 'Warehouse-1', 'City-1', 1); INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseName, WarehouseAddress, CountryID) VALUES (2, 5, 'Warehouse-2', 'City-2', 2); From a4d32bf3ba14fa09923e360b51381daa3b3db119 Mon Sep 17 00:00:00 2001 From: dianahorban Date: Sat, 16 May 2026 13:35:26 +0200 Subject: [PATCH 4/8] The solution --- task.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 61d5517..745c731 100644 --- a/task.sql +++ b/task.sql @@ -50,9 +50,9 @@ INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) VALUES (2, 2, 'Street-2', 2); INSERT INTO Warehouse (ID, WarehouseAmount,WarehouseName, WarehouseAddress, CountryID) - VALUES (1, 2, 'Warehouse-1', 'City-1', 1); + VALUES (2, 'Warehouse-1', 'City-1', 1); INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseName, WarehouseAddress, CountryID) - VALUES (2, 5, 'Warehouse-2', 'City-2', 2); + VALUES (5, 'Warehouse-2', 'City-2', 2); INSERT INTO ProductInventory (ID, ProductID, WarehouseID) VALUES (1, 1, 1); From 23e3916100c0ea3aa4daa347187c224e9e58f00e Mon Sep 17 00:00:00 2001 From: dianahorban Date: Sat, 16 May 2026 13:37:37 +0200 Subject: [PATCH 5/8] The solution --- task.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 745c731..99ab1aa 100644 --- a/task.sql +++ b/task.sql @@ -50,9 +50,9 @@ INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) VALUES (2, 2, 'Street-2', 2); INSERT INTO Warehouse (ID, WarehouseAmount,WarehouseName, WarehouseAddress, CountryID) - VALUES (2, 'Warehouse-1', 'City-1', 1); + VALUES (3, 2, 'Warehouse-1', 'City-1', 1); INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseName, WarehouseAddress, CountryID) - VALUES (5, 'Warehouse-2', 'City-2', 2); + VALUES (4, 5, 'Warehouse-2', 'City-2', 2); INSERT INTO ProductInventory (ID, ProductID, WarehouseID) VALUES (1, 1, 1); From 7870098ab4c42df944673e877d195ab67d3892b7 Mon Sep 17 00:00:00 2001 From: dianahorban Date: Sat, 16 May 2026 13:40:18 +0200 Subject: [PATCH 6/8] The solution --- task.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 99ab1aa..9d22e9b 100644 --- a/task.sql +++ b/task.sql @@ -29,6 +29,7 @@ CREATE TABLE ProductInventory ( ID INT, ProductID INT, WarehouseID INT, + Amount INT, FOREIGN KEY (ProductID) REFERENCES Product(ID) ON DELETE NO ACTION, FOREIGN KEY (WarehouseID) REFERENCES Warehouse(ID) ON DELETE NO ACTION, PRIMARY KEY (ID) @@ -54,5 +55,5 @@ INSERT INTO Warehouse (ID, WarehouseAmount,WarehouseName, WarehouseAddress, Coun INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseName, WarehouseAddress, CountryID) VALUES (4, 5, 'Warehouse-2', 'City-2', 2); - INSERT INTO ProductInventory (ID, ProductID, WarehouseID) -VALUES (1, 1, 1); + INSERT INTO ProductInventory (ID, ProductID, WarehouseID, Amount) +VALUES (1, 1, 1, 10); From 748c3ff97341d45ce79d521268956a3c312484e2 Mon Sep 17 00:00:00 2001 From: dianahorban Date: Sat, 16 May 2026 13:52:22 +0200 Subject: [PATCH 7/8] The solution --- task.sql | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/task.sql b/task.sql index 9d22e9b..612e44b 100644 --- a/task.sql +++ b/task.sql @@ -46,14 +46,14 @@ INSERT INTO Product(ID,Name) INSERT INTO Product(ID,Name) VALUES (2, 'AwersomeProduct'); -INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) - VALUES (1, 1, 'Street-1', 1); -INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseAddress, CountryID) - VALUES (2, 2, 'Street-2', 2); -INSERT INTO Warehouse (ID, WarehouseAmount,WarehouseName, WarehouseAddress, CountryID) - VALUES (3, 2, 'Warehouse-1', 'City-1', 1); INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseName, WarehouseAddress, CountryID) - VALUES (4, 5, 'Warehouse-2', 'City-2', 2); - - INSERT INTO ProductInventory (ID, ProductID, WarehouseID, Amount) -VALUES (1, 1, 1, 10); +VALUES (1, 2, 'Warehouse-1', 'City-1, Street-1', 1); +INSERT INTO Warehouse (ID, WarehouseAmount, WarehouseName, WarehouseAddress, CountryID) +VALUES (2, 5, 'Warehouse-2', 'City-2, Street-2', 2); + +INSERT INTO ProductInventory (ID, ProductID, WarehouseID, Amount) + VALUES (1, 1, 1, 10); +INSERT INTO ProductInventory (ID, ProductID, WarehouseID, Amount) + VALUES (2, 1, 1, 20); +INSERT INTO ProductInventory (ID, ProductID, WarehouseID, Amount) + VALUES (3, 2, 2, 20); From 520f4ce37f3c47a589f2d7e9631fc19649deee35 Mon Sep 17 00:00:00 2001 From: dianahorban Date: Sat, 16 May 2026 13:54:33 +0200 Subject: [PATCH 8/8] The solution --- task.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/task.sql b/task.sql index 612e44b..61074a7 100644 --- a/task.sql +++ b/task.sql @@ -55,5 +55,3 @@ INSERT INTO ProductInventory (ID, ProductID, WarehouseID, Amount) VALUES (1, 1, 1, 10); INSERT INTO ProductInventory (ID, ProductID, WarehouseID, Amount) VALUES (2, 1, 1, 20); -INSERT INTO ProductInventory (ID, ProductID, WarehouseID, Amount) - VALUES (3, 2, 2, 20);