MongoDB and Oracle Compared

March 16, 2017


In the 1970’s, Oracle Corporation became the first company to commercialize the relational database. At a time when software engineers were writing code on pads of paper, Oracle created software that provided tremendous gains in efficiency. The RDBMS became a standard and Oracle became one of most established and entrenched software vendors in the enterprise. Alternatives like MongoDB arrived within the past decade to address the changes in the way we store and manage data.

Today, modern enterprises are thinking about ways to better leverage their data -- whether it's to gain better customer insight, adapt to changing business requirements, or beat competitors to market with new applications. Given the explosion of unstructured data, new, non-relational technologies like MongoDB have emerged to address the requirements of modern applications.

What is Oracle?

Oracle is a global technology company specializing in database management systems. It’s core database offering is Oracle Database 12c Enterprise Edition, which is sold via a proprietary licensing model. Oracle stores data in tables and uses structured query language (SQL) for database access. In Oracle, you pre-define your database schema based on your requirements and set up rules to govern the relationships between fields in your tables. Related information may be stored in separate tables, but associated through the use of foreign keys and joins. In this way, data duplication is minimized.

What is MongoDB?

MongoDB is an open-source, NoSQL 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 MongoDB calls 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 (embedding all required data in a document rather than referring out to other documents) 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.

Terminology and Concepts

Many concepts in Oracle have close analogs in MongoDB. This table outlines some of the common concepts in each system.

Oracle MongoDB
Table Collection
Row Document
Column Field
Joins Embedded documents, linking

Feature Comparison

Like Oracle, 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.

  Oracle MongoDB Key-value
Rich Data Model No Yes No
Dynamic Schema No Yes Yes
Typed Data Yes Yes No
Data Locality No Yes Yes
Field Updates Yes Yes No
Easy for Programmers No Yes Not when modeling complex data structures

Query Language

Both Oracle and MongoDB have a rich query language. Below are a few examples of SQL statements and how they map to MongoDB. A more comprehensive list of statements can be found in the MongoDB documentation.

Oracle MongoDB
INSERT INTO users (user_id, age, status)
VALUES ('bcd001', 45, 'A')
  user_id: 'bcd001',
  age: 45,
  status: 'A'
UPDATE users SET status = 'C'
WHERE age > 25
  { age: { $gt: 25 } },
  { $set: { status: 'C' } },
  { multi: true }

Why use MongoDB instead of Oracle?

Organizations of all sizes are adopting MongoDB because it enables them to build applications faster, handle highly diverse data types, and manage applications more efficiently at scale.

Development is simplified as MongoDB documents map naturally to modern, object-oriented programming languages. Using MongoDB removes the complex object-relational mapping (ORM) layer that translates objects in code to cells in relational tables.

When evaluating databases, it is critical to consider the relative costs of each solution -- not just the cost of the software, but also the hardware, development and deployment costs. Organizations save 70%+ by switching from Oracle to MongoDB as a result of the gains in developer productivity, reduced costs in hardware, and the licensing model.

MongoDB can also be scaled within and across multiple distributed data centers, providing new levels of availability and scalability previously unachievable with relational databases like Oracle. As your deployments grow in terms of data volume and throughput, MongoDB scales easily with no downtime, and without changing your application. In contrast, to achieve scale with Oracle often requires significant, custom engineering work or investment in expensive, custom hardware.

For example, the popular photo-sharing website Shutterfly needed to seek alternatives to Oracle when customer growth pushed the performance limits of their Oracle database. After an extensive analysis of open source relational and non-relational alternatives, Shutterfly chose MongoDB as its persistent data store and experienced a 9x improvement in performance as well as a substantial decrease in infrastructure costs. MongoDB delivers high performance, scalability and fast time to market – a trifecta that helps Shutterfly deliver unrivaled service to customers.

What are common use cases for MongoDB?

MongoDB is a general purpose database that is used for a variety of use cases. The most common use cases for MongoDB include Single View, Internet of Things, Mobile, Real-Time Analytics, Personalization, Catalog, and Content Management.

When would Oracle be a better fit?

While most modern applications require a flexible, scalable system like MongoDB, there are use cases for which a relational database like Oracle would be better suited. Applications that require complex, multi-row transactions (e.g., a double-entry bookkeeping system) would be good examples. MongoDB is also not a drop-in replacement for legacy applications built around the relational data model and SQL.

A concrete example would be the booking engine behind a travel reservation system, which typically involves complex transactions. While the core booking engine might run on Oracle, those parts of the app that engage with users – serving up content, integrating with social networks, managing sessions – would be better placed in MongoDB.

These few exceptions aside, MongoDB is almost always a better option than Oracle because of its flexible data model, scalable architecture, and bottom line impact.

Are MongoDB and Oracle used together?

There are many examples of hybrid deployments of MongoDB and Oracle. In some cases, it’s a matter of using the right tool for the job. For example, many e-commerce applications use a combination of MongoDB and Oracle. The product catalog, which includes multiple products with different attributes, is a good fit for MongoDB’s flexible data model. On the other hand, the checkout system, which requires complex transactions, would likely be built on Oracle or another relational technology. In other cases, new business requirements push organizations to adopt MongoDB for the next-generation components of their applications.

Want to Learn More? Get our guide on a total cost of ownership comparison of MongoDB & Oracle.

This white paper examines the economics of MongoDB and Oracle by comparing the total cost of ownership (TCO) of example applications using these databases. Download the white paper to learn:

  • TCO comparison of upfront costs such as initial developer and administrator effort, software licenses, and server and storage hardware

  • TCO comparison of ongoing costs such as maintenance and support

  • Topline implications of using MongoDB

Previous Article
MongoDB Certified Professional Spotlight: Ulrich Cech
MongoDB Certified Professional Spotlight: Ulrich Cech

This week in our MongoDB Certified Professionals Blog Series we’re talking to Ulrich Cech, a Developer/Arch...

Next Article
Part 6 - The Modern Application Stack: Browsers Aren't the Only UI – Mobile Apps, Amazon Alexa, Cloud Services
Part 6 - The Modern Application Stack: Browsers Aren't the Only UI – Mobile Apps, Amazon Alexa, Cloud Services

This is the sixth and final blog post in a series examining technologies such as MongoDB and REST APIs that...