ProductID column for Product Identification and index or a separate generated ID ?

  • I am creating a product management system and a shopping cart. I would like to know if it is better to add another column and use this column and the ProductID or should I just use the standard Key, Index for the ProductID ?

    I was not sure if this is the absolute way of doing this or not.

    What brought this to my attention is that I would hate to start taking orders online and all the sudden something happens to where the index, pk, productID is no longer what it was at the time of purchase, "Like two years earlier or something."

    Just checking before I commit this design.

    Thanks a lot.

    Erik

    Dam again!

  • Shopping cart is one of the most complex features in a web application so I think you should start with existing code from Microsoft like in the commerce starter kit and add columns as needed. The reason is the shopping cart is about seven very small tables.

    I just remembered the attachment feature so I have uploaded the file for you, it includes all you need.

    Kind regards,
    Gift Peddie

  • I have really worked with that adventureworks database ever since MS released it a couple of years ago. And I model a great deal of my work after that wonderful piece of work. It is great for starters on product management.

    I have attached my products table, and a screen shot of my back end..

    I was just really concerned if I should keep the productID and the key,index and the main identifier, or if I should create a productNumber column and generate a random number after every new product is inserted.

    Erik

    Dam again!

  • You need both ProductID and ProductNumber because both are needed and I think ProductNumber is Nvarchar and not INT as IDENTITY. The product table in both the commerce starter kit docs and the AdventureWorks table comes with ProductNumber column just different name is used in both places.

    Kind regards,
    Gift Peddie

Viewing 4 posts - 1 through 3 (of 3 total)

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