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? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Pankowecki (rupert)
2011-Feb-01 08:42 UTC
Re: Reducing redundant columns in tables?
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 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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:42 am, "Robert Pankowecki (rupert)" <robert.pankowe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> What''s wrong with "normal" way and storing them as columns ? Why do > you think this is wrong approach ? > > You can also look athttp://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 Pankoweckihttp://robert.pankowecki.pl-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.