From 85211e280ac5df2e96f9cef883ad73d72c7de3bb Mon Sep 17 00:00:00 2001 From: Tetiana Savenko Date: Tue, 2 Jun 2026 14:09:41 +0300 Subject: [PATCH 1/2] 'Solution' --- .idea/.gitignore | 5 ++ .idea/inspectionProfiles/Project_Default.xml | 8 ++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/misc.xml | 7 +++ .idea/modules.xml | 8 ++++ .idea/rda_task_4_database_normalization.iml | 8 ++++ .idea/vcs.xml | 6 +++ task.sql | 48 +++++++++++++------ 8 files changed, 81 insertions(+), 15 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/misc.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..577e8ca --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,8 @@ + + + + \ 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/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..212e86d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ 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..1439764 --- /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..5884b04 100644 --- a/task.sql +++ b/task.sql @@ -9,25 +9,43 @@ CREATE TABLE Countries ( PRIMARY KEY (ID) ); -CREATE TABLE ProductInventory ( +CREATE TABLE Products ( 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, + Name VARCHAR(50), PRIMARY KEY (ID) ); +CREATE TABLE Warehouses ( + ID INT, + Name VARCHAR(50), + Address VARCHAR(50), + CountryID INT, + PRIMARY KEY (ID), + FOREIGN KEY (CountryID) REFERENCES Countries(ID) ON DELETE NO ACTION +); + +CREATE TABLE ProductInventory ( +ProductID INT, + WarehouseID INT, + WarehouseAmount INT, + PRIMARY KEY (ProductID, WarehouseID), -- Складений первинний ключ + FOREIGN KEY (ProductID) REFERENCES Products(ID) ON DELETE CASCADE, + FOREIGN KEY (WarehouseID) REFERENCES Warehouses(ID) ON DELETE CASCADE +); + -- Populate test data -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 Products (ID, Name) VALUES +(1, 'AwersomeProduct'); + +INSERT INTO Warehouses (ID, Name, Address, CountryID) VALUES +(1, 'Warehouse-1', 'City-1, Street-1', 1), +(2, 'Warehouse-2', 'City-2, Street-2', 2); -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 ProductInventory (ProductID, WarehouseID, WarehouseAmount) VALUES +(1, 1, 2), +(1, 2, 5); \ No newline at end of file From 5f3a210ac9cbdbf428818e85b03274e397a4f729 Mon Sep 17 00:00:00 2001 From: Tetiana Savenko Date: Tue, 2 Jun 2026 14:10:21 +0300 Subject: [PATCH 2/2] 'Solution' --- task.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task.sql b/task.sql index 5884b04..5b43f3a 100644 --- a/task.sql +++ b/task.sql @@ -48,4 +48,4 @@ INSERT INTO Warehouses (ID, Name, Address, CountryID) VALUES INSERT INTO ProductInventory (ProductID, WarehouseID, WarehouseAmount) VALUES (1, 1, 2), -(1, 2, 5); \ No newline at end of file +(1, 2, 5);