Mike
Mike

Reputation: 2601

Ruby on Rails Dynamic Models

I'm working on an application where the end user defines what columns a database table should have based off column names in an Excel spreadsheet that gets uploaded or just by manually defining them before uploading the spreadsheet.

Is this something that AR and MySQL could handle or am I better off using mongodb or couchdb?

In the traditional way, I would basically need a new table each time a user uploaded a document. Am I correct in thinking that with mongodb or couchdb, I would just be defining the document instead of a table?

Thanks!

Upvotes: 2

Views: 527

Answers (2)

Papipo
Papipo

Reputation: 2811

You should checkout PostgreSQL hstore. It stores a key-value field that can be indexed. There is support for ActiveRecord here https://github.com/engageis/activerecord-postgres-hstore, which will allow you to just save a Ruby hash on that field.

Upvotes: 0

Gates VP
Gates VP

Reputation: 45297

SQL, in general, has a few methods for handling such dynamic column assignments. MongoDB is definitely a much easier paradigm under which to store this data.

The big limitation here will be "what do you do when the data is in the system?". MongoDB has a built-in map-reduce, but this is obviously completely different from set-based SQL.

So to get more help, you'll probably want to detail what happens once the data is in.

Upvotes: 2

Related Questions