Jump to content

The ultimate community for Ruby on Rails developers.


Photo

hstore vs relational for storing invoice items


  • Please log in to reply
No replies to this topic

#1 denym_

denym_

    Passenger

  • Members
  • 3 posts

Posted 12 June 2014 - 11:44 AM

create_table :invoices do |t|  t.string :name
  t.string :invoice_name
  t.hstore :invoice_item
end

vs

create_table :invoices do |t|  t.string :name
  t.string :invoice_name
end

create_table :invoices do |t|  t.string :name
  t.string :amount
  t.string :description
  t.string :price
  t.integer :invoice_id
end

Whats the better solution? storing all the invoice items along side with the invoice_id in a seperate table? Or using the hstore alongside the invoice itself like:

{ "amount"=>"2", "description"=>"bliblablub", "price"=>"10" } { "amount"=>"10", "description"=>"other bliblablub", "price"=>"20" }

Any hints, suggestions or tips for that? Maybe there is a better common solution than these two. 

 

best regards

denym 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users