mysql - 何时使用 MongoDB 或其他面向文档的数据库系统?

我们为视频和音频剪辑、照片和矢量图提供平台。我们从 MySQL 作为数据库后端开始,最近包括 MongoDB用于存储文件的所有元信息,因为 MongoDB 更符合要求。例如:照片可能有Exif信息,视频也可能有我们想要存储元信息的音轨。视频和矢量图不共享任何共同的元信息等。所以我知道,MongoDB 非常适合存储这些非结构化数据并使其可搜索。

但是,我们会继续开发我们的平台并添加功能。现在接下来的步骤之一就是为我们的用户提供一个论坛。现在出现的问题是:使用 MySQL 数据库,这将是存储论坛和论坛帖子等的一个不错的选择,还是使用 MongoDB 呢?

所以问题是:何时使用 MongoDB,何时使用 RDBMS。如果可以选择,您会选择 mongoDB 还是 MySQL,为什么要选择?

最佳答案

在 NoSQL: If Only It Was That Easy ,作者写了关于 MongoDB 的文章:

MongoDB is not a key/value store, it’s quite a bit more. It’s definitely not a RDBMS either. I haven’t used MongoDB in production, but I have used it a little building a test app and it is a very cool piece of kit. It seems to be very performant and either has, or will have soon, fault tolerance and auto-sharding (aka it will scale). I think Mongo might be the closest thing to a RDBMS replacement that I’ve seen so far. It won’t work for all data sets and access patterns, but it’s built for your typical CRUD stuff. Storing what is essentially a huge hash, and being able to select on any of those keys, is what most people use a relational database for. If your DB is 3NF and you don’t do any joins (you’re just selecting a bunch of tables and putting all the objects together, AKA what most people do in a web app), MongoDB would probably kick ass for you.

那么,在结论中:

The real thing to point out is that if you are being held back from making something super awesome because you can’t choose a database, you are doing it wrong. If you know mysql, just use it. Optimize when you actually need to. Use it like a k/v store, use it like a rdbms, but for god sake, build your killer app! None of this will matter to most apps. Facebook still uses MySQL, a lot. Wikipedia uses MySQL, a lot. FriendFeed uses MySQL, a lot. NoSQL is a great tool, but it’s certainly not going to be your competitive edge, it’s not going to make your app hot, and most of all, your users won’t care about any of this.

What am I going to build my next app on? Probably Postgres. Will I use NoSQL? Maybe. I might also use Hadoop and Hive. I might keep everything in flat files. Maybe I’ll start hacking on Maglev. I’ll use whatever is best for the job. If I need reporting, I won’t be using any NoSQL. If I need caching, I’ll probably use Tokyo Tyrant. If I need ACIDity, I won’t use NoSQL. If I need a ton of counters, I’ll use Redis. If I need transactions, I’ll use Postgres. If I have a ton of a single type of documents, I’ll probably use Mongo. If I need to write 1 billion objects a day, I’d probably use Voldemort. If I need full text search, I’d probably use Solr. If I need full text search of volatile data, I’d probably use Sphinx.

我喜欢这篇文章,我觉得它信息量很大,它很好地概述了 NoSQL 的前景和炒作。但是,这是最重要的部分,在 RDBMS 和 NoSQL 之间进行选择时,问自己正确的问题确实很有帮助。值得一读恕我直言。

Alternate link to article

https://stackoverflow.com/questions/1476295/

相关文章:

macos - Mongod 提示没有/data/db 文件夹

database - MongoDB 或 CouchDB - 适合生产?

mongodb - 默认在 MongoDB shell 中打印漂亮

architecture - 何时使用 Redis?何时使用 MongoDB?

mongodb - 如何重命名 MongoDB 数据库?

mongodb - 查找包含特定值的数组的文档

mongodb - 查找数组字段不为空的 MongoDB 记录

mongodb - 删除 MongoDB 数据库中的所有内容

mongodb - 如何获取mongodb中的最后N条记录?

mongodb - 检查字段是否包含字符串