mysql - Database design - best way to store templates and instances -
our database calls having templates, instance having meeting template group of people attend meeting along base meeting name. meeting can "instantiated" can make copies of meeting , modify attributes. best ways can think of doing to:
- store "instances" in same table , store related information similarly.
- make different tables same attributes , store templates in 1 table , "instances" in table.
how using 1 table, adding flag field "istemplate" table, serve identify record default or 'template' record.
you create new record has default parameters, , set istemplate "1" or true or yes or whatever.
when creating new meeting, create copy of template, so:
insert meetings(place,people,time) (select place,people,time meetings istemplate = '1')
if have multiple templates, list of available templates as:
select * meetings istemplate = '1'
and instantiate 1 of templates primary key rather 'istemplate':
insert meetings(place,people,time) (select place,people,time meetings id = 'xxxx')
Comments
Post a Comment