4 ms·
Genuine question: What's the proposal for items in an API which have no concept of a "slug"? We could generate a separate mapping of "public ids" to the databa
by fjni 7y ago
Genuine question:
What's the proposal for items in an API which have no concept of a "slug"?
We could generate a separate mapping of "public ids" to the database internal ones, but I don't even see how that would solve any of the issues here.
- theoh 7y agoI'm not a database expert, but concepts like surrogate and natural keys come to mind. A unique slug is a natural key, but for most, if not all, items, you can come up with a natural key by combining a few bits of data (I've seen name * date of birth used by doctors in general practice, for example). Often there's a pre-existing unique code external to the app which can be used, like a driver's licence number or something like that. That removes the need for a surrogate key in the database. The tricky case is something like email drafts: it's possible for a user to create and then save a draft with no addressee, subject or content. In that case there is little alternative but to make the system use a surrogate key (a database internal key) because the other possible unique identifying values (e.g. time of creation of the draft) are sort of unsatisfactory, because they don't really have a strong, meaningful connection with the content of the item.