From b3593430a59f79c06aeedf069aa7eb5911b3e1ae Mon Sep 17 00:00:00 2001 From: Lysenko Volodymyr Date: Fri, 5 Jun 2026 23:18:34 +0200 Subject: [PATCH 1/3] Solution2 --- .idea/.gitignore | 5 ++ .idea/inspectionProfiles/Project_Default.xml | 18 ++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/modules.xml | 8 +++ .idea/rda_task_4_database_normalization.iml | 8 +++ .idea/vcs.xml | 6 ++ task.sql | 64 ++++++++++++------- 7 files changed, 91 insertions(+), 24 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/rda_task_4_database_normalization.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..c7bd4da --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,18 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2389036 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rda_task_4_database_normalization.iml b/.idea/rda_task_4_database_normalization.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/rda_task_4_database_normalization.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/task.sql b/task.sql index cc65344..097e7a6 100644 --- a/task.sql +++ b/task.sql @@ -1,33 +1,49 @@ --- Create database and tables - -CREATE DATABASE ShopDB; +CREATE DATABASE IF NOT EXISTS ShopDB; USE ShopDB; CREATE TABLE Countries ( - ID INT, - Name VARCHAR(50), + ID INT AUTO_INCREMENT, + Name VARCHAR(50) NOT NULL, PRIMARY KEY (ID) ); -CREATE TABLE ProductInventory ( - ID INT, - ProductName VARCHAR(50), - WarehouseAmount INT, - WarehouseName VARCHAR(50), - WarehouseAddress VARCHAR(50), - CountryID INT, - FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION, +CREATE TABLE Products ( + ID INT AUTO_INCREMENT, + Name VARCHAR(50) NOT NULL, 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); +CREATE TABLE Warehouses ( + ID INT AUTO_INCREMENT, + WarehouseName VARCHAR(50) NOT NULL, + WarehouseAddress VARCHAR(50) NOT NULL, + CountryID INT, + PRIMARY KEY (ID), + FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE SET NULL +); + +CREATE TABLE ProductInventory ( + ID INT AUTO_INCREMENT, + ProductID INT, + WarehouseID INT, + WarehouseAmount INT NOT NULL, + PRIMARY KEY (ID), + FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE SET NULL, + FOREIGN KEY (WarehouseID) REFERENCES Warehouses(ID) ON DELETE SET NULL +); + + +INSERT INTO Countries (ID, Name) VALUES (1, 'Country1'); +INSERT INTO Countries (ID, Name) VALUES (2, 'Country2'); + +INSERT INTO Products (ID, Name) VALUES (1, 'AwersomeProduct'); + +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 ProductInventory (ID, ProductID, WarehouseID, WarehouseAmount) + VALUES (1, 1, 1, 2); +INSERT INTO ProductInventory (ID, ProductID, WarehouseID, WarehouseAmount) + VALUES (2, 1, 2, 5);. From d57f628d89ee74a2fc7ad801211fbb2a4729cbc0 Mon Sep 17 00:00:00 2001 From: Lysenko Volodymyr Date: Fri, 5 Jun 2026 23:23:53 +0200 Subject: [PATCH 2/3] Solution3 --- task.sql | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/task.sql b/task.sql index 097e7a6..624dd52 100644 --- a/task.sql +++ b/task.sql @@ -2,41 +2,41 @@ CREATE DATABASE IF NOT EXISTS ShopDB; USE ShopDB; CREATE TABLE Countries ( - ID INT AUTO_INCREMENT, - Name VARCHAR(50) NOT NULL, + ID INT, + Name VARCHAR(50), PRIMARY KEY (ID) ); CREATE TABLE Products ( - ID INT AUTO_INCREMENT, - Name VARCHAR(50) NOT NULL, + ID INT, + ProductName VARCHAR(50), PRIMARY KEY (ID) ); CREATE TABLE Warehouses ( - ID INT AUTO_INCREMENT, - WarehouseName VARCHAR(50) NOT NULL, - WarehouseAddress VARCHAR(50) NOT NULL, + ID INT, + WarehouseName VARCHAR(50), + WarehouseAddress VARCHAR(50), CountryID INT, PRIMARY KEY (ID), - FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE SET NULL + FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION ); CREATE TABLE ProductInventory ( - ID INT AUTO_INCREMENT, + ID INT, ProductID INT, WarehouseID INT, - WarehouseAmount INT NOT NULL, + WarehouseAmount INT, PRIMARY KEY (ID), - FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE SET NULL, - FOREIGN KEY (WarehouseID) REFERENCES Warehouses(ID) ON DELETE SET NULL + FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE NO ACTION, + FOREIGN KEY (WarehouseID) REFERENCES Warehouses(ID) ON DELETE NO ACTION ); INSERT INTO Countries (ID, Name) VALUES (1, 'Country1'); INSERT INTO Countries (ID, Name) VALUES (2, 'Country2'); -INSERT INTO Products (ID, Name) VALUES (1, 'AwersomeProduct'); +INSERT INTO Products (ID, ProductName) VALUES (1, 'AwersomeProduct'); INSERT INTO Warehouses (ID, WarehouseName, WarehouseAddress, CountryID) VALUES (1, 'Warehouse-1', 'City-1, Street-1', 1); @@ -46,4 +46,4 @@ INSERT INTO Warehouses (ID, WarehouseName, WarehouseAddress, CountryID) INSERT INTO ProductInventory (ID, ProductID, WarehouseID, WarehouseAmount) VALUES (1, 1, 1, 2); INSERT INTO ProductInventory (ID, ProductID, WarehouseID, WarehouseAmount) - VALUES (2, 1, 2, 5);. + VALUES (2, 1, 2, 5); From c9f3fa605420fcc279a7aefdc889e27a80d4aa9e Mon Sep 17 00:00:00 2001 From: Lysenko Volodymyr Date: Sun, 7 Jun 2026 17:56:09 +0200 Subject: [PATCH 3/3] Solution3 --- .gitignore | 0 .idea/.gitignore | 5 ----- .idea/inspectionProfiles/Project_Default.xml | 18 ------------------ .idea/inspectionProfiles/profiles_settings.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/rda_task_4_database_normalization.iml | 8 -------- .idea/vcs.xml | 6 ------ 7 files changed, 51 deletions(-) create mode 100644 .gitignore delete mode 100644 .idea/.gitignore delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/rda_task_4_database_normalization.iml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index b58b603..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index c7bd4da..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 2389036..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/rda_task_4_database_normalization.iml b/.idea/rda_task_4_database_normalization.iml deleted file mode 100644 index d0876a7..0000000 --- a/.idea/rda_task_4_database_normalization.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file