▲ | saagarjha a day ago | |||||||||||||||||||||||||
Allowing the client to generate IDs for you seems like a bad idea? | ||||||||||||||||||||||||||
▲ | morshu9001 a day ago | parent | next [-] | |||||||||||||||||||||||||
Client = backend here, right? So you could make a bunch of rows that relate to each other then insert, without having to ping the DB each time to assign a serial ID. Normally the latter is what I do, but I can imagine a scenario where it'd be slow. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | clintonb 8 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
Client-generated IDs are necessary for distributed or offline-first systems. My company, Vori, builds a POS for grocery stores. The POS generates UUIDv7 IDs for all data it creates and that data is eventually synced to our backend. The sync time can range from less than 1 second for a store with fast Internet to hours if a store is offline. Is a collision possible? Yes, but the likelihood of a collision is so low that it's not worth agonizing over (although I did when I was designing the system). | ||||||||||||||||||||||||||
▲ | bramhaag a day ago | parent | prev | next [-] | |||||||||||||||||||||||||
It can be quite elegant. You can avoid the whole temporary or external ID mess when the client generates the ID, this is particularly useful for offline-first clients. Of course you need to be sure the server will accept the ID, but that is practically guaranteed by the uniqueness property of UUIDs. | ||||||||||||||||||||||||||
▲ | coolspot a day ago | parent | prev | next [-] | |||||||||||||||||||||||||
“client” here may refer to a backend app server. So you can have 10-100s of backend servers inserting into a same table without having a single authority coordinating IDs. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
▲ | markstos a day ago | parent | prev [-] | |||||||||||||||||||||||||
Why? |