3

We use a unique id to sync products between our application and retailers.

Most of application are using SKU to identify the product, BUT why should we use a second id (SKu) if we already have one (primary incremental id key) ?

ImadT
  • 491
  • 1
  • 5
  • 21
  • 2
    One reason would be a SKU is much more difficult to guess (unless they are also incremental) – Kevin B Mar 17 '14 at 17:56
  • This question appears to be off-topic because it is not about programming, as defined in the [help center](http://stackoverflow.com/help/on-topic). – Barranka Mar 17 '14 at 17:58
  • 1
    Another question would be, if you already have unique sku#'s, why do you need an incrementing id? This argument can be looked at in both directions. If the SKU# isn't unique, then that would be a clear reason as to why you would need an incrementing id + sku – Kevin B Mar 17 '14 at 17:59
  • 1
    so it is about what then :)? of course it is about programming. and please don't put a -1 in less than 2min. you are not encouraging people to ask question by doing this btw – ImadT Mar 17 '14 at 18:02
  • Your question can only be answered by the people who wrote the applications you are using. All we can do is speculate. If all products have a SKU#, and all SKU#'s are unique, why do you need an incremental id in the first place? this may be why the other applications use the SKU#. – Kevin B Mar 17 '14 at 18:03
  • it isn't about my application, most of e-commerce are using both, and we are dealing with a lot of retailers. every time we ask them to provide a unique code they provide both ids :/ – ImadT Mar 17 '14 at 18:05
  • 1
    It's also possible the sku will change or it's mistyped. Indexing might work faster with an int, because sku's may have text. Also it's possible you don't know all the sku's when you insert the product. So, I'd advice not to use sku as a key. – viljun Mar 17 '14 at 20:24

2 Answers2

1

SKU means a Stock Keeping Unit - a item or product that you stock. The question is what identifier(s) will customers and business users be using to identify SKUs. Often that's called a SKU code or just SKU for short. If you already have such an identifier then maybe you don't need another one, although it's perfectly reasonable and not uncommon to have different identifiers for different purposes (e.g. a bar code and a customer-friendly product code).

nvogel
  • 24,981
  • 1
  • 44
  • 82
1

Primary keys are mainly for database use. When a database references an item, it does not care for the structure of the primary key, on that it's unique

Although this could mean we could use many different forms, the reality is you want to keep your architecture as efficient & simple as possible. SKU's and other details (as referenced by sqlvogel) are attributes of particular database objects, and can change with time. Primary keys do not

Richard Peck
  • 76,116
  • 9
  • 93
  • 147