Dynamic Custom Fields for Data Model
Posted
by Jerry Deng
on Stack Overflow
See other posts from Stack Overflow
or by Jerry Deng
Published on 2010-04-07T14:42:29Z
Indexed on
2010/04/07
16:33 UTC
Read the original article
Hit count: 198
ruby
|ruby-on-rails
I am in the process of creating a dynamic database where user will be able to create resource type where he/she can add custom fields (multiple texts, strings, and files)
Each resource type will have the ability to display, import, export its data;
I've been thinking about it and here are my approaches. I would love to hear what do you guys think.
Ideas:
just hashing all the custom data in a data field (pro: writing is easier, con: reading back out may be harder);
children fields (the model will have multiple fields of strings, fields of text, and fields for file path);
fixed number of custom fields in the same table with a key mapping data hash stored in the same row;
Non-SQL approach, but then the problem would be generating/changing models on the fly to work with different custom fields;
© Stack Overflow or respective owner