I mean doesn't it have to be online to make sure that wallet isn't already taken?
There is no check. Call me when you create a wallet wich is already taken. It should take like more time than the life of the universe
I don't understand how it works. How does the database know that these wallets/pass keys are being created, if the generator is offline from the database?
It doesn't know, and there is no need for it to know. As i said, call me when that happens
Maybe after the universe death or so...