I've been trying to figure out how bitcoin exchange services work. Specifically the ones that allow you to exchange btc for fiat money and viceversa.
for example
If I try to buy 2 bitcoin:
1-are they going to give me a coin that they already have ? or
2-are they going to give me a coin that a seller is trying to sell ?
if they give me a coin they already have, how do they now they'll always have enough to supply all the buyers ?
if they give me a coin that a seller is trying to sell, how to they know that they will always have enough volume to satisfy all the transactions ?
finally is this entire thing managed by some type of database, oracle? sql ?
thanks !