Banks do not share databases typically. Sending money goes through some system, and that transaction is recorded on both sides, and possibly a third party. Then, once the money "leaves" one bank's system, it no longer becomes their problem, and they do not need to and they likely do not keep track of account balances in other banks. If someone claims that they have money in a bank but the bank says that they do not, then the bank statements and records sent out to customers will prove that the customer has that amount in the bank account and that the bank screwed up.
Suppose that I'm a bank and have my customer's deposit registered in my database, it has nothing to do with any other banks. I just run FRB and my customer will never know if I have money in the bank until a large scale of withdraw happens (And I can borrow money if they withdraw). All the transactions between my customers are just some number change in my own database without the moving of any money
However, if one of my customer Bob want to send $500 to his account at bank B, he would either withdraw cash and then deposit it to bank B (which is very rare), or he uses bank's online service to do a wire transfer. In wire transfer, I will subtract $500 from his account balance in my database, and bank B must add $500 to his account balance at the same day. In order to do that, I must establish some relationship with bank B and have a common communication protocol, which is the clearing system
However, even the communication protocol is reliable, I could still send 2 billion dollar into bank B, without subtracting same amount of numbers in my database, what I do with my database is totally up to me, if no one is overseeing it
And by doing this I could double spend 2 billions. So I guess banks must have a means to control this kind of risk, either through someone overseeing all the banks' databases (which is very unlikely), or through some mutual contract between banking members? Or they don't control it at all and double spending is a daily business?