Search code examples
mongodbb-tree

How is mongodb implemented and why is it different than sql databases


I was wondering how is mongodb (nosql in general) implemented? Is it using B+ trees? If so, how and why is it different to SQL databases?

Thank you!


Solution

  • please refer here

    What is MySQL?

    MySQL is a popular open-source relational database management system (RDBMS) that is developed, distributed and supported by Oracle Corporation. Like other relational systems, MySQL stores data in tables and uses structured query language (SQL) for database access. In MySQL, you pre-define your database schema based on your requirements and set up rules to govern the relationships between fields in your tables. In MySQL, related information may be stored in separate tables, but associated through the use of joins. In this way, data duplication is minimized.

    What is MongoDB?

    MongoDB is an open-source database developed by MongoDB, Inc. MongoDB stores data in JSON-like documents that can vary in structure. Related information is stored together for fast query access through the MongoDB query language. MongoDB uses dynamic schemas, meaning that you can create records without first defining the structure, such as the fields or the types of their values. You can change the structure of records (which we call documents) simply by adding new fields or deleting existing ones. This data model give you the ability to represent hierarchical relationships, to store arrays, and other more complex structures easily. Documents in a collection need not have an identical set of fields and denormalization of data is common. MongoDB was also designed with high availability and scalability in mind, and includes out-of-the-box replication and auto-sharding.

    Feature Comparison Like MySQL, MongoDB offers a rich set of features and functionality far beyond those offered in simple key-value stores. MongoDB has a query language, highly-functional secondary indexes (including text search and geospatial), a powerful aggregation framework for data analysis, and more. With MongoDB you can also make use of these features across more diverse data types than with a relational database, and at scale.

                          MySQL                             MongoDB
    Rich Data Model        No                                Yes
    Dynamic Schema         No                                Yes
    Typed Data             Yes                               Yes
    Data Locality          No                                Yes
    Field Updates          Yes                               Yes
    Easy for Programmers   No                                Yes
    Complex Transactions   Yes                                No
    Auditing               Yes                               Yes
    Auto-Sharding          No                                Yes