Question

More specifically, I am thinking of using PostgreSQL (ActiveRecord) and MongoDB (Mongoid) in a single Rails 4 app.

Also, will associations between models work? Something like

class Customer < ActiveRecord::Base
    has_many :orders
end

class Order
    include Mongoid::Document
    belongs_to :customer
end

I am aware that ActiveRecord and Mongoid can coexist, but is that a good idea?

Was it helpful?

Solution

I would do some hard thinking and try to choose one of the databases, even if you can make them work together technically. You have to think past programming and take a bigger view. One day your app will be in production, I assume. THis implies 2 different backup solutions, 2 different monitoring solutions, double the training for the ops, etc.

Alex Lerner

OTHER TIPS

It's absolutely OK.

If you application have different kind of data and using mongodb improve performance, why not?

OR:

Your application is market. Products in your market have common columns - price, name and etc. Put them in postgresql. Besides, products have many params are not common for all (computer - volume of hdd, monitor - size of display and etc). These data you can store using mongodb.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top