Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having following data :

Fabric Cost
time     |   No fabric|BangloreSilk|Chanderi|.... <- fabric types
--------------------------------------------
01/15    |         40 |         25 |...
02/15    |         45 |         30 |...
.....    |        ... |        ... |...


Dyeing Cost
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 .
Approach 1 :

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



Approach 2 :

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??
Posted

1 solution

I would have use 3 table
1. FabricType
2. FabricCost
3. CostType

Cost type table you can have two entries now, you can add more in future if needed.
Primary Key of Cost Type and FabricType can used in Fabric cost table record as foreign keys.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900