简体   繁体   English

在一个Rails应用程序中使用多个数据库系统和ORM是一个好主意吗?

[英]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.

相关问题 使用Couchbase和Rails是个好主意吗? - Is a good idea use Couchbase with Rails? 多个Rails应用程序,单个MySQL数据库 - Multiple Rails app, single MySQL database 滑轨。 在数据库中保存列表是个好主意吗? 我应该使用什么关系? - Rails. Keeping list in database is it good idea? What relation I should use? 多个Rails应用程序读取另一个Rails应用程序的单个数据库/表 - Multiple Rails apps read single database/table of another Rails app 将 ApplicationJob 用于 Rails 后台作业中使用的常用功能是个好主意吗? - Is it good idea to use ApplicationJob for common functions used in background jobs in Rails? 在Rails应用程序而不是单个数据库中使用单独的数据库是否更好? - Is it better to use separate databases in a Rails app instead of a single database? 在rails中使用has_one嵌套属性是一个好主意吗? - Is it a good idea to use has_one nested attributes in rails? 使用Rails时仅在某些页面中使用emberjs是个好主意吗? - Is it a good idea to use emberjs only in some pages when using rails? 如何在跨数据库系统工作的Rails 3中使用WHERE IN? - How to use WHERE IN in Rails 3 that works across database systems? 使用多个数据库Rails 4 - Use Multiple Database Rails 4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM