mysql - efficient database design inheritance -
i want design database have 2 categories. there 2 subcategories in each category, similar other category like:
preventive equipment maintenance:
- cat1
- id, equipment,model, series, accesories,date, cost, status
- cat 2
- id, equipment,model, series, accesories,date, cost, status
corrective equipment maintenance
- cat1
- id, new equipment, old equipment, borreowed equipment, description
- cat 2
- id, new equipment,model, series, accesories,date, cost, old equipment, borreowed equipment, description
so can see diference between data collected on preventive equipment maintenance cat (either cat1 or cat2). solve thought make table like
create table `preventive_e`( id integer not null primary key, equipment varchar(25) , cat varchar(4) , constraint `uc_info_e` unique (`id`) ); insert `preventive_e` values (1,'nintendo','cat1'); insert `preventive_e` values (2,'psp','cat2');
now in corrective same, not same fields, same fields, if cat1 want store fields, if cat 2 want store same fields more fields
is there way use inheritance or something?, extending fields being able add more particular fields? how query like.
why not call table generic both equipment_maint
, have column acting flag it's usage.
fiddle
create table `equipment_maint`( id integer not null primary key, equipment varchar(25) , cat varchar(50) , type varchar(20), /* usage on type of maintenance */ constraint `uc_info_e` unique (`id`) );
Comments
Post a Comment