3 ms·
I deal with inventory systems and there is a difference between your system's key and a 'natural' one--the natural one existed first. The good answer is to supp
by karmakaze 3y ago
I deal with inventory systems and there is a difference between your system's key and a 'natural' one--the natural one existed first. The good answer is to support both and use either as appropriate. There are many ways of ID'ing an item, usually a SKU (literally stock keeping unit) is used. The owner of the items can choose to use an existing one (manufacturer, UPC, etc) but more commonly assigns their own so that interchangeable items with different manufacturer codes can share a SKU. Ideally a system should support as many methods of ID'ing as the user deems useful.
If you do use surrogate keys everywhere, avoid exposing a one if a pair of existing ones will do. e.g. rows of an association table, unless of course that association has attributes and is a well-known thing to itself.
Making every user of your systems always use system generated identifiers (where external ones already in use commonly exist) is kind of like a file-system that only uses tmp-generated names and the user has to do external book-keeping to remember which is which.