What would be the best way to store barcodes for products? I have a situation where the same product can have many different barcodes, let's say I have 1 product and this product can have 100 different barcodes (which must be unique).

Is it better to store those barcodes in separate table? For example, the following diagram

enter image description here

means I will have 1 product and 100 rows with different barcodes for this product (same name and everything).

Or is it better to have 100 products with the same name, each with barcode column, as shown below?

enter image description here

1 Answer 1


If you have a truly one-to-many relationship between your products and barcodes, it makes sense to keep it in a separate table for barcodes (don't repeat yourself-- your name and description would be identical for each repeated barcode).

IF however there is any variation in the product itself (name or description could vary) then you need to store each as a discrete record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.