User-defined columns

I am breaking ground on a new project and one of the issues I expect to
encouter
is the ability of users to define their own columns. For example, one of
the
features of this application will be the ability to store information
about
people’s skills and then search for and schedule them based on this
information.
Since every organization’s needs are different, it would be ideal to
allow each
organization to extend the basic schema dynamically.

Has anyone else dealt with this scenario in Rails? Are there advantages
to using
a particular database for this?

Jason C. wrote:

I am breaking ground on a new project and one of the issues I expect to encouter
is the ability of users to define their own columns. For example, one of the
features of this application will be the ability to store information about
people’s skills and then search for and schedule them based on this information.
Since every organization’s needs are different, it would be ideal to allow each
organization to extend the basic schema dynamically.

Has anyone else dealt with this scenario in Rails? Are there advantages to using
a particular database for this?

Why not instead use a tagging system? You can store arbitrary key/value
pairs in the database in a generic way, e.g., have a table called
“tags.” There are plenty of resources out there about how to do this,
just search Google for Rails+tagging.


Jesse F. [email protected]
University of Chicago - NSIT Web Services
AIM: farmerje
Jabber: [email protected]
Phone: (773)363-1058

Jesse F. <farmerje@…> writes:

Why not instead use a tagging system? You can store arbitrary key/value
pairs in the database in a generic way, e.g., have a table called
“tags.” There are plenty of resources out there about how to do this,
just search Google for Rails+tagging.

Tagging is an interesting option that I hadn’t considered. I don’t have
the
requirements solidified yet, but it might be sufficient. However, simple
key/value pairing might not offer enough control. For instance, it might
be
necessary to indicate level of skill/proficiency, meaning that the
end-user
could define custom attributes with custom defined values. Is that
something
that tagging would provide?

Jason C. wrote:

Jesse F. <farmerje@…> writes:

Why not instead use a tagging system? You can store arbitrary key/value
pairs in the database in a generic way, e.g., have a table called
“tags.” There are plenty of resources out there about how to do this,
just search Google for Rails+tagging.

Tagging is an interesting option that I hadn’t considered. I don’t have
the
requirements solidified yet, but it might be sufficient. However, simple
key/value pairing might not offer enough control. For instance, it might
be
necessary to indicate level of skill/proficiency, meaning that the
end-user
could define custom attributes with custom defined values. Is that
something
that tagging would provide?

Polymorphic associations (from edgerails) might also work well for this.
However…

There is no reason that rails can’t add/drop table columns through SQL
calls. Since ActiveRecord is good at picking up things from the table
structure, it would probably work pretty well. You would have to do
some introspection to know what columns had been added, but that is
pretty easy with RoR.

_Kevin

Larry W. <larrywright@…> writes:


Rails mailing list
Rails@…
http://lists.rubyonrails.org/mailman/listinfo/rails

I share that concern as well. The application I am designing would also
be a
multi-user database. I guess it would be possible to create a new
instance of
the application for each customer, but surely that would become
unmanageable
with any level of success.

For sake of discussion, can anyone provide a sample of how creating
columns via
ActiveRecord might be implemented? I am fairly new to Rails, so I’m not
completely familiar with how you do introspection and such. In C# I
handle
Reflection with precision and ease, but these dynamic languages are
still a
mental stretch for me.

On 1/13/06, Kevin O. [email protected] wrote:

_Kevin


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

I’ve got a similar need potentially, so I’m glad to see some discussion
around this topic. The only issue with adding the fields dynamically is
how
to handle multi-user systems. Take Basecamp for example, if they allowed
for
adding custom fields. Certainly there is only one database for everyone
using Basecamp, as doing otherwise would likely not be feasible. So how
do
you handle it for these situations?

I too posted a similar problem. Has anyone found a solution or has any
clues?

tia,

Roberto

jason cartwright wrote:

Larry W. <larrywright@…> writes:


Rails mailing list
Rails@…
http://lists.rubyonrails.org/mailman/listinfo/rails

I share that concern as well. The application I am designing would also
be a
multi-user database. I guess it would be possible to create a new
instance of
the application for each customer, but surely that would become
unmanageable
with any level of success.

For sake of discussion, can anyone provide a sample of how creating
columns via
ActiveRecord might be implemented? I am fairly new to Rails, so I’m not
completely familiar with how you do introspection and such. In C# I
handle
Reflection with precision and ease, but these dynamic languages are
still a
mental stretch for me.

I just found this thread after posting a similar topic. Was any decent
solution found for the problem of user-defined columns?

Allowing the application to add/remove columns is not an option for me.
The database will be shared among many users.

Tagging as I understand it doesn’t provide what I’m looking for either.
I’ll need a key/value pair for rows in a database. The keys will be
user-defined for the entire account and will only be mutable by the
administrator of that particular account.

Jake