Does some counter in one database get decreased by 1, and another counter is increased? Surely it must be more sophisticated.
Also, how can two brokers trade securities between each other?
How can you prevent somebody from duplicating a stock like you would duplicate a file?
Internally, a company would be decreasing the number of shares for an individual. They might send the order to a broker or if they are a broker, then to the market. I think Swift messages are part of that communication. They usually are sent to custodial banks. I forget if the broker or custodial bank holds the certificate. Then theres a whole clearing process which takes 2 days. Dark pools and other agents can be involved. I think CFA foundations has details on the whole process.
There's also a similar process for funds. Sometimes the orders don't need to be sent to the market. Basically if fund A is selling a stock and fund B is buying the same stock, then only the net order is sent to the market.
Symbiont is working on blockchain tech to shorten the settle time make the records immutable. Sort of interesting stuff.
This article below will hopefully help you understand things a bit more clearly.
https://www.bloomberg.com/opinion/articles/2015-07-14/banks-...
EDIT: I pasted the wrong link. See below.
https://smithonstocks.com/part-8-illegal-naked-shorting-seri...