From 5632ee3f4ab0244960b23f1c9e8accbd90e131ee Mon Sep 17 00:00:00 2001 From: Lysenko Volodymyr Date: Fri, 5 Jun 2026 21:48:09 +0200 Subject: [PATCH 1/4] Solution1 --- .idea/.gitignore | 5 +++++ .idea/inspectionProfiles/Project_Default.xml | 18 ++++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/rda_task_3_transactions.iml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ task.sql | 19 ++++++++++++------- 7 files changed, 63 insertions(+), 7 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_3_transactions.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..d007c13 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rda_task_3_transactions.iml b/.idea/rda_task_3_transactions.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/rda_task_3_transactions.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 8adf22b..fc31f90 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,16 @@ --- Use our database -USE ShopDB; +USE ShopDB; --- Some data should be created outside the transaction (here) +INSERT INTO Orders (CustomerID, Date) +VALUES (1, '2023-01-01'); --- Start the transaction -START TRANSACTION; --- And some data should be created inside the transaction +START TRANSACTION; -COMMIT; \ No newline at end of file +INSERT INTO OrderItems (OrderID, ProductID) +VALUES (1, 1); + +UPDATE Products +SET WarehouseAmount = WarehouseAmount - 1 +WHERE ID = 1; + +COMMIT; From 12ddf591fc9df7f2e54f9887233b9fe213bd0394 Mon Sep 17 00:00:00 2001 From: Lysenko Volodymyr Date: Fri, 5 Jun 2026 21:57:56 +0200 Subject: [PATCH 2/4] Solution2 --- task.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/task.sql b/task.sql index fc31f90..a97db5a 100644 --- a/task.sql +++ b/task.sql @@ -3,14 +3,13 @@ USE ShopDB; INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); - START TRANSACTION; -INSERT INTO OrderItems (OrderID, ProductID) -VALUES (1, 1); +INSERT INTO OrderItems (OrderID, ProductID, Count) +VALUES (LAST_INSERT_ID(), 1, 1); UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; -COMMIT; +COMMIT; \ No newline at end of file From c07fb5a105b48c05e0032f179d894e4facce4be8 Mon Sep 17 00:00:00 2001 From: Lysenko Volodymyr Date: Sun, 7 Jun 2026 17:16:02 +0200 Subject: [PATCH 3/4] Solution3 --- .gitignore | 3 +++ .idea/.gitignore | 5 ----- .idea/inspectionProfiles/Project_Default.xml | 18 ------------------ .idea/inspectionProfiles/profiles_settings.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/rda_task_3_transactions.iml | 8 -------- .idea/vcs.xml | 6 ------ task.sql | 4 ++-- 8 files changed, 5 insertions(+), 53 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_3_transactions.iml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5d51d6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +*.iml +.DS_Store 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 d007c13..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/rda_task_3_transactions.iml b/.idea/rda_task_3_transactions.iml deleted file mode 100644 index d0876a7..0000000 --- a/.idea/rda_task_3_transactions.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 diff --git a/task.sql b/task.sql index a97db5a..4bbb623 100644 --- a/task.sql +++ b/task.sql @@ -1,10 +1,10 @@ USE ShopDB; +START TRANSACTION; + INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); -START TRANSACTION; - INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (LAST_INSERT_ID(), 1, 1); From 483174413e10b3470a9742ec25187185117ce65b Mon Sep 17 00:00:00 2001 From: Lysenko Volodymyr Date: Sun, 7 Jun 2026 17:27:01 +0200 Subject: [PATCH 4/4] Solution4 --- task.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.sql b/task.sql index 4bbb623..a97db5a 100644 --- a/task.sql +++ b/task.sql @@ -1,10 +1,10 @@ USE ShopDB; -START TRANSACTION; - INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); +START TRANSACTION; + INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (LAST_INSERT_ID(), 1, 1);