一起使用 MySQL 和 Mongodb

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10676397/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:27:06  来源:igfitidea点击:

Using MySQL and Mongodb together

mysqlmongodbunison

提问by WittyPleb

I have worked with MySQL more than MongoDB, but from what I've learned from MongoDB it's just what I needed, but it also has it's limitations that MySQL can do (for instance auto increment)

我使用 MySQL 的次数超过了 MongoDB,但是从我从 MongoDB 中学到的知识来看,这正是我所需要的,但它也有 MySQL 可以做的限制(例如自动增量)

Would it be smart to use MongoDB for everything, and use MySQL for only certain things?

将 MongoDB 用于所有事情并且仅将 MySQL 用于某些事情是否明智?

For instance use MongoDB to store users and everything else, but use MySQL to make for example a ticket system.

例如使用 MongoDB 来存储用户和其他一切,但使用 MySQL 来制作例如票务系统。

回答by ilanco

It sounds perfectly reasonable to use two database technologies in one project. Just make sure you use the right tool for the job.

在一个项目中使用两种数据库技术听起来完全合理。只要确保您使用正确的工具来完成这项工作。

It's common to use MySQL as the primary storage and MongoDB as caching/intermediate storage for speed.

为了提高速度,通常使用 MySQL 作为主存储,使用 MongoDB 作为缓存/中间存储。

You can for example have read-intensive data in MongoDB. The data for generating reports is perfect for a relational system like MySQL.

例如,您可以在 MongoDB 中拥有读取密集型数据。生成报告的数据非常适合像 MySQL 这样的关系系统。

回答by Lynn Langit

There is a pretty good discussion of Use Cases for MongoDB on the main MongoDB site. In general, if your business case includes the need for transactions and heavy T-SQL functionality, then you'd be better served by using a RDBMS such as MySQL.

MongoDB 主站点上对 MongoDB 的用例进行了很好的讨论。一般来说,如果您的业务案例包括对事务和繁重的 T-SQL 功能的需求,那么使用 RDBMS(如 MySQL)会更好地为您服务。

Good Use Cases for MongoDB are as follows: 1) Your data is in a document format, i.e. irregular structure in single documents (that is data doesn't need to be joined) 2) You are considering using a flat file system (again due to the structure of your data), but you would like 'more' in terms of ability to index/query that data. 3) Your project is in a state where you genuinely don't know what the schema or structure of your data will ultimately be. 4) You have specialized data types, such as geo-spatial data, and you want to be able to query against it. 5) You may have a need to quickly and cheaply scale your data storage location.

MongoDB 的良好用例如下:1) 您的数据是文档格式,即单个文档中的不规则结构(即数据不需要连接)2)您正在考虑使用平面文件系统(再次由于到您的数据结构),但您希望在索引/查询该数据的能力方面“更多”。3) 您的项目处于这样一种状态,您真的不知道数据的架构或结构最终会是什么。4) 您拥有专门的数据类型,例如地理空间数据,并且希望能够对其进行查询。5) 您可能需要快速且廉价地扩展您的数据存储位置。

回答by kommradHomer

Here is a well-typed discussion of mongodb usage, by someone who took mongoDb courses

这是参加 mongoDb 课程的人对 mongodb 用法的详细讨论

Considerations for choosing or not choosing MongoDB

选择与不选择MongoDB的注意事项

The blogger mainly says that using mongodb with other DB systems is perfectly fine , yet using it system wide , can be most challenging and almost impossible at some certain scenarios.

博主主要说将mongodb与其他DB系统一起使用非常好,但是在系统范围内使用它可能是最具挑战性的,并且在某些特定场景下几乎是不可能的。

Here are some subtitles :

以下是一些字幕:

Reasons to choose Mongo

选择 Mongo 的理由

  • Document oriented and schemaless
  • Horizontal Scalability and High Availability
  • Fast writes in the fire-and-forget mode
  • Comprehensive Querying and Aggregation Framework
  • Comparatively intuitive architecture
  • 面向文档和无模式
  • 水平可扩展性和高可用性
  • 快速写入即发即忘模式
  • 综合查询聚合框架
  • 比较直观的架构

Reasons not to choose Mongo

不选择 Mongo 的理由

  • No SQL = No Joins
  • No ACID transactions
  • Your indexes would not fit into memory
  • 无 SQL = 无连接
  • 没有 ACID 事务
  • 您的索引不适合内存