[英]Is it a good idea to use multiple database systems and ORMs in a single Rails app?
More specifically, I am thinking of using PostgreSQL (ActiveRecord) and MongoDB (Mongoid) in a single Rails 4 app. 更具体地说,我正在考虑在单个Rails 4应用程序中使用PostgreSQL(ActiveRecord)和MongoDB(Mongoid)。
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? 我知道ActiveRecord和Mongoid 可以共存,但这是个好主意吗?
It's absolutely OK. 绝对可以
If you application have different kind of data and using mongodb improve performance, why not? 如果您的应用程序具有不同类型的数据,并且使用mongodb可以提高性能,那为什么不呢?
OR: 要么:
Your application is market. 您的应用程序是市场。 Products in your market have common columns - price, name and etc. Put them in postgresql.
您市场上的产品具有通用列-价格,名称等。将它们放在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.
您可以使用mongodb存储这些数据。
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.
这意味着2种不同的备份解决方案,2种不同的监视解决方案,对操作人员的培训加倍等等。
Alex Lerner 亚历克斯·勒纳
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.