Alternative to Mysql that handles increment/decrement with new or existing keys In our application we're looking to store values by ID. In mysql, I might make a table like this:

create table balances {
  address bigint NOT NULL PRIMARY KEY,
  balance double NOT NULL
}


The problem is how we would interact with it. If I move 15 units from address=5 to address=12, address 12 may not exist. So it takes two or three operations:

begin transaction;
subtract 15 from balance where address=5
if address 12 exists
  add 15 to address 12
else
  insert balance=15, address=12
end transaction


Is there a database or storage system that is designed for this sort of tracking that could do this sort of operation more atomically without if-checks?
I'm not sure I fully understand the use-case, but in MySQL you can use:

    INSERT INTO balances (address, balance) VALUES (12, 15)
    ON DUPLICATE KEY 
    UPDATE balance = balance + 15;


... so you may not need a specialized DBMS for this sort of thing.

This type of statement is known as 'merge' (as in the SQL standard) or 'upsert'. See this Wikipedia article for more info, including details about the implementation in other relational database systems.