Reducing redundant columns in tables?

Consider the following scaffold for a virtual machine manager.

rails g scaffold virtualmachine total_memory:integer
total_disk:integer
rails g scaffold plan title:string price_usd:integer
max_memory:integer max_disk:integer

Now this is greatly simplified however I have around 30 values that I
want to track for each virtual machine and for the plans as well.
What would be the best way to do this?

What’s wrong with “normal” way and storing them as columns ? Why do
you think this is wrong approach ?

You can also look at
http://ar.rubyonrails.org/classes/ActiveRecord/Base.html
and read “Saving arrays, hashes, and other non-mappable objects in
text columns”. Of course using :serialize greatly reduces your ability
to easily perform SQL queries about stored values.

Robert Pankowecki
http://robert.pankowecki.pl

Devin M wrote in post #978802:

Consider the following scaffold for a virtual machine manager.

rails g scaffold virtualmachine total_memory:integer
total_disk:integer
rails g scaffold plan title:string price_usd:integer
max_memory:integer max_disk:integer

Now this is greatly simplified however I have around 30 values that I
want to track for each virtual machine and for the plans as well.
What would be the best way to do this?

It actually might depend on your design. Are these 30 some values going
to be a fixed list?

If all virtual machines in your system use the same list of attributes,
then putting them in columns is fine. It’s certainly the simplest design
that could possibly work.

However, if different virtual machines may have a different set of
attributes, or if you want to be able to dynamically add new attributes
to the running system, without code changes, then it might be worth
architecting a more flexible design for your tables.

Im just looking to make my table as dry as possible, I suppose that
the best way would be to store these values columns since that is what
they are.

Thanks for the insight,
Devin Morin

On Feb 1, 12:42am, “Robert Pankowecki (rupert)”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs