Universal Product Codes: a Database Primer

  • The article re UPC structure needs updating and correcting.

    As I grocery retailer DB admin while I also maintained the item DB, the last 5 digits were never structured as described, at least in the companies we dealt with. Worse, some companies just made up numbers!

    Our biggest problem was company reps who thought the first digit was a check digit, and did not tell us, therefore we would setup that item with a (default) of 0 for the first digit. Obviously, this caused issues at point of sale!

    The FIRST DIGIT, along with the next 5, denote the company. This is true for first digits 0, 6, and 7. This gives each company 100K numbers to use - 00000 is valid

    With digits 8 and 9, GS1 uses the first 6, and maybe more, to denote the company. The company tells GS1 how many digits they will use internally, and are assigned blocks in length of 1 thru 5 digits. Knowing which company has that item gets more complicated.

    Some other digits have special uses:

    1 is reserved for use as order numbers that are in EPU-E format.

    2 is used in scales and other devices that assign the price for variable amount, such as scales at service delis.

    3 is used for medicines. The rest of the number is the number assigned by the feds (NDC). The next 4 digits are the company and the last 6 are for use internally. Some companies use them as such: of the last 6, the first 4 are the product, and the last 2 relate to the size.

    4: is reserved for any company to use for any product they choose, providing the these numbers may be used ONLY within that company's stores!

    5: is reserved for scannable coupons, although a new format is being adopted.

    Bill

  • Bill Reynolds-362342 (2/28/2013)


    The article re UPC structure needs updating and correcting ... the last 5 digits were never structured as described, at least in the companies we dealt with. Worse, some companies just made up numbers!

    Yes, companies can and do make up numbers. Any company is free to use any barcode system, even its own custom in-house designed system, for internal usage. It is only if the product is sold through retail outlets that they have to adhere to a universal code system. As far as the universal code system is concerned, the digits are used as described in the article. Besides my own experience, an Internet search for the subject reveals many websites that are in agreement. Here is one: http://en.wikipedia.org/wiki/Universal_Product_Code

    Hakim Ali
    www.sqlzen.com

  • The Wikipedia article is excellent.

    Hakim, the problem we encountered was the company in question used a 6 digit ID internally. They just converted those numbers as if they were UPC-E! The result ended up that, of the 8 products we carried, there were 6 different compamy codes!

    Another problem was when one bakery merged with another, they started using the same UPC for an item that was sold in one area under one brand, and the other area as the other brand! As were had stores in each, we had to set the description to handle either!

    Bill

    easyrider@me.com

  • This is a great article, but it appears there's some confusion over various standards that float within UPC-A depending on the prefix. Where the article states the following, "The three digits after that (333) represent the product family code." is only correct in the case where the UPC-A is a type 5, meaning it's a coupon, and by extension the next 2 digits before the check digit is the UCC value code. Otherwise, when it's not a type 5 UPC, that position PMMMMM[highlight=#ffff11]III[/highlight]IIC highlighted is not a family code. There are of course additional quirks within the UPC stardards that are poorly documented but this was the only piece of information in the article that I saw which was technically incorrect and needed clarification.

  • Of course, you are correct regarding coupon codes. I don't know of any retailer that was using the family code for validation, as it could have been very costly to have that data, and that was never included in the info we received.

  • for those interested you should go to the GS1 web site

    http://www.gs1us.org/

    by talking about the UPC-a, upc-e, ean, etc you are really talking about the Visual representation of a 14 position GTIN (global trade item number).

    in your data base all GTINS are stored in the 14 position format.

    you can the send the 14 digit number to a barcode printer, scanner, etc and it can render the GTIN in the appropriate format.

    Also noted in the article was that 5 digits of the number are the manufacturer. That is incorrect since 2001. the manufacturer portion of the number is now variable in length to allow for larger sets of items, or smaller.

    so the number of items you can represent for a given mfg number can be anywhere from only 10 on up to larger numbers. Please see the web site.

    so your calculation of the check digit does not vary with the 14 digit code it is always the same.

  • jreinhardt 93303

    The variable length company, at this time, applies only to numbers starting with 8 or 9.

    Bill

    easyrider@me.com

  • Dohan has it correct: The UPC algorithm is that the check digit is the number that needs to be *added* to the weighted sums to equal the next higher multiple of 10, which is not the same as modulo, which is the integer remainder after dividing one number by another.

    Suppose you had a UPC code that evaluated to 59. The next higher multiple of 10 is 60, which means the check digit would be 1, but 59 mod 10 = 9.

    ____________
    Just my $0.02 from over here in the cheap seats of the peanut gallery - please adjust for inflation and/or your local currency.

  • larry.shanahan (2/28/2013)


    Dohan has it correct: The UPC algorithm is that the check digit is the number that needs to be *added* to the weighted sums to equal the next higher multiple of 10, which is not the same as modulo, which is the integer remainder after dividing one number by another.

    Suppose you had a UPC code that evaluated to 59. The next higher multiple of 10 is 60, which means the check digit would be 1, but 59 mod 10 = 9.

    Ok, if that is the way it was defined in words then the calculation is correct.

    But stopping at plain mod 10 would have been sufficient for calculating the check digit. The extra calculation is just a one-to-one mapping and does not provide an added layer of insurance to the check digit.

  • Dohsan (2/28/2013)


    I believe the algorithm for calculating the check digit takes the difference between the 'weighted sum' and the nearest multiple of 10 that is equal or higher.

    if the sum was 55, the nearest multiple of 10 that is equal or higher is 60

    so 60-55 = 5 is the check digit

    this can be changed to (10 - (sum mod 10)) mod 10

    The reason for the second MOD is that in cases where the weighted sum is a multiple of 10, you would get a check digit of 10, which is too many digits. The second mod will then return this as 0.

    So, the entire IF/ELSE block with its repetitive algortihm can be reduced to:

    set @checkdigit = convert(varchar(1), (10-((((@sum_of_odds * 3) + (@sum_of_evens)))%10 ))%10)

Viewing 10 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic. Login to reply