Manthan Dave
Manthan Dave

Reputation: 153

How are products stored in database?

I have a database to store different types of products for a shop. Do I keep record of every instance of the product? Or do I just decrease the quantity count every time a product is sold? I also want to store barcodes in the database. Is the barocde printed on the product unique to every instance? or is it just unique to product. For instance if I have 4 cans of Heinz Tomato soup, will they have same barcode value? If yes then how do I identify every instance uniquely? If no then how do I guarantee that the barcode value on the Heinz Tomato Soup can will not match barcode of any other product in a given shop?

Any help will be appreciated. Thank you. :D

Upvotes: 0

Views: 832

Answers (1)

Tibor Kiray
Tibor Kiray

Reputation: 108

You don't need a record for every instance of a product.

You should have an instance for a product with a stock quantity column for each record and work with the quantity field once a product gets sold or the stock gets replenished.

By definition the the barcode on the products is unique (not per instance) so you should be safe with it: Heinz Tomato Soup will have a code and Heinz Chicken Soup will have another one.

This might help you more: http://www.daveegerton.com/assets/images/database-schema-prestashop.png This is the database schema used by an eCommerce (Prestashop). Your questions answer is in the right bottom square the one in light brown :)

Upvotes: 1

Related Questions