To me, there are two possibilities: either switching to a less-
normalized design (serialized columns) or
a different database idea entirely (CouchDB, for instance).

I haven't used CouchDB personally, but check it out:

http://couchdb.apache.org/ (the main project)
http://github.com/arunthampi/activecouch/tree/master (an ActiveRecord-
like wrapper)

It's a "document database", which can store arbitrary key-value pairs
for each "document".
Sounds like it might be a better match for what you're trying to do.
--

Staying within Rails, if you don't have a need to search by specific
column values (which you haven't
mentioned), you could just store the data in a single serialized
field:

Sheets
- id (int)
- name (string)
Columns
- id (int)
- sheet_id (int)
- column_group_id (int)
- name (string)
ColumnGroups
- id (int)
- name (string)
Data
- id (int)
- sheet_id (int)
- tool_number (string)
- row_data (text, serialized)

Then keep the data in Data#row_data, as a Hash of (column_name =>
value) [or column_id => value] pairs.
That would keep all of the ToolNumber stuff grouped together.

BTW, if you need columns in a particular order, take a look at
acts_as_list - it should work great for what
you're doing here.
--

In conclusion (this has gotten rather long), I'd recommend first that
you take a look at CouchDB. It seems
like a much better match to the idea you're looking for. The
serialized-column approach is a little more of a
hack, but should work if nothing else is possible.

--Matt Jones


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to