From 7b3a8a85e0e961d519e3a56949f9d1c90f0ab730 Mon Sep 17 00:00:00 2001 From: Tetiana Savenko Date: Mon, 1 Jun 2026 15:33:49 +0300 Subject: [PATCH 1/3] 'Solution' --- task.sql | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/task.sql b/task.sql index 8adf22b..19931e1 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,18 @@ --- Use our database -USE ShopDB; +USE ShopDB; --- Some data should be created outside the transaction (here) +INSERT INTO Customers (ID, FirstName, LastName, Email, Address) +VALUES (1, 'John', 'Doe', 'john.doe@example.com', '123 Main St'); --- Start the transaction -START TRANSACTION; +INSERT INTO Orders (CustomerID, Date) +VALUES (1, '2023-01-01'); --- And some data should be created inside the transaction +START TRANSACTION; -COMMIT; \ No newline at end of file +INSERT INTO OrderItems (OrderID, ProductID, Count) +VALUES (LAST_INSERT_ID(), 1, 1); + +UPDATE Products +SET WarehouseAmount = WarehouseAmount - 1 +WHERE ID = 1; + +COMMIT; \ No newline at end of file From 650291e5052cb391f75781370df197a46abe697d Mon Sep 17 00:00:00 2001 From: Tetiana Savenko Date: Mon, 1 Jun 2026 15:38:53 +0300 Subject: [PATCH 2/3] 'Solution2' --- task.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/task.sql b/task.sql index 19931e1..a97db5a 100644 --- a/task.sql +++ b/task.sql @@ -1,8 +1,5 @@ USE ShopDB; -INSERT INTO Customers (ID, FirstName, LastName, Email, Address) -VALUES (1, 'John', 'Doe', 'john.doe@example.com', '123 Main St'); - INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); From 90aa38661cd86f75d99be38e51a55ea406e6c05e Mon Sep 17 00:00:00 2001 From: Tetiana Savenko Date: Mon, 1 Jun 2026 15:45:32 +0300 Subject: [PATCH 3/3] 'Solution3' --- task.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task.sql b/task.sql index a97db5a..a11fda4 100644 --- a/task.sql +++ b/task.sql @@ -12,4 +12,4 @@ UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 WHERE ID = 1; -COMMIT; \ No newline at end of file +COMMIT;