I am having following data :
time | No fabric|BangloreSilk|Chanderi|.... <- fabric types
--------------------------------------------
01/15 | 40 | 25 |...
02/15 | 45 | 30 |...
..... | ... | ... |...
time | No fabric|BangloreSilk|Chanderi|.... <- fabric types
--------------------------------------------
01/15 | 40 | 25 |...
02/15 | 45 | 30 |...
..... | ... | ... |...
And here list of fabric types will be same for both the data.
Now to add this data I created following tables :
fabric_type
id int
fabric_type_name varchar
And then I have two approaches .
fabric_cost
id int
fabric_type_id int (foreign key to fabric_type)
cost int
deying_cost
id int
fabric_type_id int (foreign key to fabric_type)
cost int
fabric_overall_cost
id int
fabric_type_id int (foreign key to fabric_type)
cost int
fabric_or_dyeing bit (to represent 0 for fabric cost and 1 for dyeing cost)
Now the question is which approach will be better??
It really depends on your requirements. Are there other columns that are unique only for the fabric_cost
table? Are there other columns that are unique only for the dyeing_cost
table? Meaning will your 2 tables grow independently?
If yes, approach 1 is better. Otherwise, approach 2 is better because you won't need to do CRUD on 2 separate tables (for easier maintenance).
Another approach would be:
id int
fabric_type_id int (foreign key to fabric_type)
fabric_cost float/double/decimal
dyeing_cost float/double/decimal
This third approach is if you always have both costs. You might not want to use int
for cost. Again, it depends on your requirements.