On 12 September 2013 16:44, Yash Ladia <ladiay...@gmail.com> wrote:

> Thanx for your reply.My problem is that at a later point of time this
> would account for very large data set as the users will increase. I want to
> optimize my website and want to save time on data query from the
> database.Also, i will be looking for similar user profile based on user's
> attribute like(taste in music,movies,interests etc).I want this to be done
> very efficiently and in a proper manner so that there is less complexity in
> writing the code.
>

Having a large amount of simple data is not the same problem as having
complex data. If all you are storing is key value pairs you could have a
table like this

class Interest < ActiveRecord::Migration
  def change
    create_table :interests do |t|
      t.integer :user_id, :null => false
      t.string :type, :null => false
      t.string :value, :null => false
      t.timestamps
    end
  end
end

And you would store it as:

Interest.create(:user_id => user.id, :type => 'music', :value => 'Status
Quo')
Interest.create(:user_id => user.id, :type => 'movie', :value => 'The Color
Purple')
Interest.create(:user_id => user.id, :type => 'hobby', :value => 'Fishing')
Interest.create(:user_id => user.id, :type => 'food', :value => 'Cheese')

and have a has_many link from the User model to retrieve the data. This
sort of data is exactly what an RDBMS is best suited for. Of course if it
is just key value pairs then something like Redis is also a good tool too.

MongoDBs strength is document storage for unstructured data. The problem is
that the data you have is neither a document nor unstructured. This is not
to say that you cannot store key value pairs in MongoDB but it is not the
best tool for the problem you describe.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CALxYQy52buNt36z7FZ4Jew1OvDnafuPUe%3DmfDWLfrBCgjBn7NQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to