From 4ab80bd7696515aafa3f0467a90cac48a6daf67f Mon Sep 17 00:00:00 2001 From: Yuriy Mishchuk Date: Wed, 22 Apr 2026 16:53:57 +0300 Subject: [PATCH 1/2] My solution --- create-database.sql | 1 + task.sql | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/create-database.sql b/create-database.sql index 342a055..a08719b 100644 --- a/create-database.sql +++ b/create-database.sql @@ -1,6 +1,7 @@ CREATE DATABASE ShopDB; USE ShopDB; + CREATE TABLE Products ( ID INT AUTO_INCREMENT, Name VARCHAR(50), diff --git a/task.sql b/task.sql index 8adf22b..ef187ce 100644 --- a/task.sql +++ b/task.sql @@ -5,7 +5,7 @@ USE ShopDB; -- Start the transaction START TRANSACTION; - --- And some data should be created inside the transaction - +INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); +INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (1, 1, 1); +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; COMMIT; \ No newline at end of file From 29a958e88e223d9571fa83bb5f8b4764e7eefaac Mon Sep 17 00:00:00 2001 From: Yuriy Mishchuk Date: Wed, 22 Apr 2026 17:00:58 +0300 Subject: [PATCH 2/2] My solution fixed --- task.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task.sql b/task.sql index ef187ce..297e4dc 100644 --- a/task.sql +++ b/task.sql @@ -4,8 +4,8 @@ USE ShopDB; -- Some data should be created outside the transaction (here) -- Start the transaction -START TRANSACTION; INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); +START TRANSACTION; INSERT INTO OrderItems (OrderID, ProductID, Count) VALUES (1, 1, 1); UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; COMMIT; \ No newline at end of file