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: 202

Filed under:
|

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:

  1. just hashing all the custom data in a data field (pro: writing is easier, con: reading back out may be harder);

  2. children fields (the model will have multiple fields of strings, fields of text, and fields for file path);

  3. fixed number of custom fields in the same table with a key mapping data hash stored in the same row;

  4. 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

Related posts about ruby

Related posts about ruby-on-rails