What are the advantages of using a schema-free database like MongoDB compared to a relational database?

前端 未结 9 1714
别那么骄傲
别那么骄傲 2020-12-22 16:02

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.

But la

相关标签:
9条回答
  • 2020-12-22 16:39

    Here are some of the advantages of MongoDB for building web applications:

    1. 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.
    2. Deep query-ability. MongoDB supports dynamic queries on documents using a document-based query language that's nearly as powerful as SQL.
    3. No schema migrations. Since MongoDB is schema-free, your code defines your schema.
    4. A clear path to horizontal scalability.

    You'll need to read more about it and play with it to get a better idea. Here's an online demo:

    http://try.mongodb.org/

    0 讨论(0)
  • 2020-12-22 16:39

    Bellow Lines Written in MongoDB: The Definitive Guide.

    There are several good reasons:

    1. Keeping different kinds of documents in the same collection can be a nightmare for developers and admins. Developers need to make sure that each query is only returning documents of a certain kind or that the application code performing a query can handle documents of different shapes. If we’re querying for blog posts, it’s a hassle to weed out documents containing author data.
    2. It is much faster to get a list of collections than to extract a list of the types in a collection. For example, if we had a type key in the collection that said whether each document was a “skim,” “whole,” or “chunky monkey” document, it would be much slower to find those three values in a single collection than to have three separate collections and query for their names
    3. Grouping documents of the same kind together in the same collection allows for data locality. Getting several blog posts from a collection containing only posts will likely require fewer disk seeks than getting the same posts from a collection con- taining posts and author data.
    4. We begin to impose some structure on our documents when we create indexes. (This is especially true in the case of unique indexes.) These indexes are defined per collection. By putting only documents of a single type into the same collection, we can index our collections more efficiently
    0 讨论(0)
  • 2020-12-22 16:40

    MongoDB was featured on FLOSS Weekly this week - http://twit.tv/floss105 A database using a similar concept is CouchDB which was featured on another FLOSS Weekly: http://twit.tv/floss36

    I think it's worth listening to those in addition to the links provided by @marcgg

    0 讨论(0)
  • 2020-12-22 16:42
    1. MongoDB supports search by fields, regular expression searches.Includes user defined java script functions.
    2. MongoDB can be used as a file system, taking advantage of load balancing and data replication features over multiple machines for storing files.
    0 讨论(0)
  • 2020-12-22 16:43

    It's all about trade offs. MongoDB is fast but not ACID, it has no transactions. It is better than MySQL in some use cases and worse in others.

    0 讨论(0)
  • 2020-12-22 16:48

    After a question of databases with textual storage), I glanced at MongoDB and similar systems.
    If I understood correctly, they are supposed to be easier to use and setup, and much faster. Perhaps also more secure as the lack of SQL prevents SQL injection...
    Apparently, MongoDB is used mostly for Web applications.
    Basically, and they state that themselves, these databases aren't suited for complex queries, data-mining, etc. But they shine at retrieving quickly lot of flat data.

    0 讨论(0)
提交回复
热议问题