diff --git a/task.sql b/task.sql index 8adf22b..bf60765 100644 --- a/task.sql +++ b/task.sql @@ -1,11 +1,19 @@ -- Use our database -USE ShopDB; +USE ShopDB; --- Some data should be created outside the transaction (here) +-- ShopDB should be created by running create-database.sql before this script. +-- AwersomeProduct with ID 1 and customer with ID 1 are inserted there as initial data. --- 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 the transaction +START TRANSACTION; -COMMIT; \ No newline at end of file +INSERT INTO OrderItems (OrderID, ProductID, Count) +VALUES (1, 1, 1); + +UPDATE Products SET WarehouseAmount = WarehouseAmount - 1 +WHERE ID = 1; + +COMMIT;