Question

I am developing stock inventory for Bicycles. I stored Cycles cid,title, desc etc, in CYCLE table, and another STOCK(sid,cid,qty) for storing stock. Now i cam to know that Bicycles can have many colors(Black, Red, Orange etc.) AND sizes. I am confused about storing Stock with respect to Size and Color.

I Modified the STOCK Table

STOCK(sid,cid,qty,color,size).

e.g.

 1,101,12,1,null for Red Color 
 1,101,12,2,null for Green Color

...... (6 records for same cycle with respect to color as there can be 6 colors) PLUS Size medium,Large,Small (3 records for same cycle with respect to size) 1,101,12,null,medium - for Medium size 1,101,12,null,Small - for Small size 1,101,12,null,Large - for Large size

Total 9 records for 1 Cycle product.

I have another design in mind for stock STOCK(sid,cid,qty,red,green,blue,orange,cyan,yellow,medium,Large,Small) and 1 single record in stock. 1,101,0,0,1,3,5,6,3,0,7

My question is, Is this right way to maintain a stock, or i can improve. If you can help to fine tune, i will greatly appreciate.

Was it helpful?

Solution

Your design should be like this:

Cycle table: only 'properties' of the cycle CID, COLOR, SIZE, PRICE etc

You'll set your size to "SMALL", "MEDIUM" etc You'll set your color to "RED", "GREEN" etc

Stock table: only maintain the quantity & related details ID, CID, QTY, DATE_OF_ARRIVAL_OF_SHIPMENT etc

So now, each row in the Cycle table identifies a 'type' of cycle, and each row in the stock table identifies some cycles in stock.

This is good because now, if you have to add another color / size, you only need to create another row in your table, not modify your structure. Also, now you can write simple queries for all your characteristics (e.g. how many cycles of red color across all sizes are in stock?)

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top