Inconsistent data problem or non repeatable read problem in transaction processing in SQL: To understand this problem, refer to the diagram given below. In this problem of transaction processing, A receives an order for ITEM 1 for 150 items. He checks the database to find that there are 300 items available In the meanwhile B gets an order for ITEM 1 for 200 items. He selects the ITEMS table to find that there are 300 items available. Then, a few seconds later A accepts the orders for 150 items. After that, B gets an order update for ITEM 2, so he checks the database to find that there are only 100 items for ITEM 2. So he communicates with the client and tells him that he should go for ITEM 1 as there is not enough inventory for ITEM 2. On the other side, A conforms and updates the order for 150 items. Now, he sets the ITEM 1 quantity to be 150. Now, client of B agrees for ITEM 1 as there is not enough inventory for ITEM 2. Now, B selects the ITEMS table and finds that there are only 150 items for ITEM 1. Hence, he cannot proceed with the order. According to the perspective of B database hasn’t been consistent. Hence, this problem is known as inconsistent data problem or non repeatable read problem.
Phantom insert problem in transaction processing: In this problem of transaction processing, A is running a query to find the total number of orders in ORDERS table and he finds the total number of orders. Meanwhile, B is accepting an order of some items. After that, A again runs the same query and finds a new order and the total number of orders is updated. This leads to an inconsistent behavior of the database.