与关系数据库相比,使用无模式数据库(如MongoDB)有什么优势? [英] What are the advantages of using a schema-free database like MongoDB compared to a relational database?
问题描述
我习惯于使用像MySQL或PostgreSQL这样的关系数据库,结合MVC框架,如Symfony,RoR或Django,我认为它工作的很好。
I'm used to using relational databases like MySQL or PostgreSQL, and combined with MVC frameworks such as Symfony, RoR or Django, and I think it works great.
但最近我听说过很多关于MongoDB的非关系数据库,或者引用正式定义
But lately I've heard a lot about MongoDB which is a non-relational database, or, to quote the official definition,
一个可扩展,高性能,开放的
源,无模式,面向
数据库。
a scalable, high-performance, open source, schema-free, document-oriented database.
我真的有兴趣在边缘,想知道所有的选项,
I'm really interested in being on edge and want to be aware of all the options I'll have for a next project and choose the best technologies out there.
在哪些情况下使用MongoDB(或类似数据库)比使用经典关系数据库更好?
MongoDB和MySQL的优势一般是什么?
或至少,为什么这么不同?
In which cases using MongoDB (or similar databases) is better than using a "classic" relational databases? And what are the advantages of MongoDB vs MySQL in general? Or at least, why is it so different?
如果你有指向文档和/或示例的指针,这将是很大的帮助。 p>
If you have pointers to documentation and/or examples, it would be of great help too.
推荐答案
以下是MongoDB构建Web应用程序的一些优点:
Here are some of the advantages of MongoDB for building web applications:
- 基于文档的数据模型。存储的基本单元类似于JSON,Python字典,Ruby哈希等。这是一个丰富的数据结构,能够保存数组和其他文档。这意味着您通常可以在单个实体中表示一个构造,该构造需要几个表在关系数据库中正确表示。如果您的数据不可变,这是非常有用的。
- 深度查询能力。 MongoDB支持使用基于文档的查询语言对文档进行动态查询,查询语言几乎与SQL一样强大。
- 无模式迁移。由于MongoDB是无模式的,因此您的代码定义了您的模式。
- 横向可伸缩性的明确路径。
- A document-based data model. The basic unit of storage is analogous to JSON, Python dictionaries, Ruby hashes, etc. This is a rich data structure capable of holding arrays and other documents. This means you can often represent in a single entity a construct that would require several tables to properly represent in a relational db. This is especially useful if your data is immutable.
- Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language that's nearly as powerful as SQL.
- No schema migrations. Since MongoDB is schema-free, your code defines your schema.
- A clear path to horizontal scalability.
$ b b
您需要详细了解它,并使用它来获得更好的主意。以下是在线演示:
You'll need to read more about it and play with it to get a better idea. Here's an online demo:
这篇关于与关系数据库相比,使用无模式数据库(如MongoDB)有什么优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!