sql - Creating new table vs adding new field -
i 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 same both data.
add data created following tables :
fabric_type
id int fabric_type_name varchar and have 2 approaches .
approach 1 :
fabric_cost
id int fabric_type_id int (foreign key fabric_type) cost int deying_cost
id int fabric_type_id int (foreign key fabric_type) cost int approach 2 :
fabric_overall_cost
id int fabric_type_id int (foreign key fabric_type) cost int fabric_or_dyeing bit (to represent 0 fabric cost , 1 dyeing cost) now question approach better??
it depends on requirements. there other columns unique fabric_cost table? there other columns unique dyeing_cost table? meaning 2 tables grow independently? if yes, approach 1 better. otherwise, approach 2 better because won't need crud on 2 separate tables (for easier maintenance). approach be:
id int fabric_type_id int (foreign key fabric_type) fabric_cost float/double/decimal dyeing_cost float/double/decimal this third approach if have both costs. might not want use int cost. again, depends on requirements.
Comments
Post a Comment