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:

  1. store "instances" in same table , store related information similarly.
  2. 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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -