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..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 +INSERT INTO Orders (CustomerID, Date) VALUES (1, '2023-01-01'); START TRANSACTION; - --- And some data should be created inside the 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