While designing a DB for grocery shop, I came across a requirement of "same product available in different measurements" – e.g., Lets say, Green Peas available in 250gms, 500gms, 1Kg and so.
My question is :
Is it good practice to have duplicate entry of product with different measurement in products table or keeping the measurements in different table with product id?
Best Answer
Using
postgresql-unit
I'm big on types. I would use an extension for this. If you're not in the US and working with Imperial Units, take a look at Christoph Berg's brainchild postgresql-unit. First build the extension
Then install the extension on your DB and configure your table.
Likewise you can
INSERT
in other units if need be. They'll get stored in those units, but you can select in any unit you want.