mysql - Handling custom user fields with possibility of grow and shrink -


this question how do, idea etc.

i have situation user can create many custom fields can of type number, text, or date, , use make form. have make/design table model can handle , store value query can done on these values once saved.

previously have hard coded format 25 user defined fields (udf). make table 25 column 10 number, 10 text, , 5 date type , store label in if user makes use of field. map other table has same format , store value. mapping done know field having label not efficient way, hope.

any suggestion appreciated.

users have permissions creating number of udf of above types. can used make forms again n numbers , have save data each form types.

e.g. let's user created 10 number 10 date , 10 text fields used first 5 of each make form1 , 10 make form2 saved data.

my thoughts on it:

make table1 [id,name(as udf_xxx xxx data type),userlabel ]

table2 map form , table1 [id(f_key table1_id), f_id(form id)]

and make 1 table of each data type [ id(f_key of table1),f_id(form number),r_id(row id data, same data type),value]

thanks i'm going implement, both dataset entry , json approach looks gives wider extension-ability. still i've figure out best fit existing format.

there 2 approaches have used.

  1. xml: create dynamic user attribute, may use xml. xml stores in clob column - say, user_attributes. store entire user-data in xml key-value pair, type attribute or field. give maximum freedom.

    you can use xom or other xml object model api display or operate on data. typical node like

    <userdata>   ...   ...   <datanode>     <key type="date">user birth</key>     <value>1994-02-25</value>   </datanode>   ... </userdata> 
  2. attribute-attributevalue same thing above using tables. create table -- attributes fk user_id, table attribute_values fk attribute_id.

    attributes contains multiple field-names , types each user , attribute_values contains values of attributes. basically,

    users   user_id  attributes   attr_id   user_id (fk)   attr_type   attr_name  attribute_values   attr_val_id   attr_id (fk)   attr_val 

if see in both approached not limited how-many or type of data have. there down-side of parsing. in either of case, have to small amount of processing display or analyze data.

the best of both worlds (having rigid column structure vs having dynamic data) approach have users table must-have columns (like user_name, age, sex, address etc) , have user-created data (like favorite pet house etc.) in either xml or attribute-attribute_value.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -