Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
114 lines (78 sloc) 3.431 kb
============================
SQL to MongoDB Mapping Chart
============================
.. default-domain:: mongodb
.. all of the included table files are built from corresponding .yaml
files in the includes directory. To change the content of the
tables, edit those files.
In addition to the charts that follow, you might want to consider the
:doc:`/faq` section for a selection of common questions about MongoDB.
Terminology and Concepts
------------------------
The following table presents the various SQL terminology and concepts
and the corresponding MongoDB terminology and concepts.
.. include:: /includes/table/sql-to-mongo-terms.rst
Executables
-----------
The following table presents some database executables and the
corresponding MongoDB executables. This table is *not* meant to be
exhaustive.
.. include:: /includes/table/sql-to-mongo-executables.rst
Examples
--------
The following table presents the various SQL statements and the
corresponding MongoDB statements. The examples in the table assume the
following conditions:
- The SQL examples assume a table named ``users``.
- The MongoDB examples assume a collection named ``users`` that contain
documents of the following prototype:
.. code-block:: javascript
{
_id: ObjectId("509a8fb2f3f4948bd2f983a0"),
user_id: "abc123",
age: 55,
status: 'A'
}
Create and Alter
~~~~~~~~~~~~~~~~
The following table presents the various SQL statements related to
table-level actions and the corresponding MongoDB statements.
.. include:: /includes/table/sql-to-mongo-schema-examples.rst
For more information, see :method:`db.collection.insert()`,
:method:`db.createCollection()`, :method:`db.collection.update()`,
:update:`$set`, :update:`$unset`,
:method:`db.collection.createIndex()`, :doc:`indexes </core/indexes>`,
:method:`db.collection.drop()`, and :doc:`/core/data-models`.
Insert
~~~~~~
The following table presents the various SQL statements related to
inserting records into tables and the corresponding MongoDB statements.
.. include:: /includes/table/sql-to-mongo-insert-examples.rst
For more information, see :method:`db.collection.insert()`.
Select
~~~~~~
The following table presents the various SQL statements related to
reading records from tables and the corresponding MongoDB statements.
.. include:: /includes/table/sql-to-mongo-select-examples.rst
For more information, see
:method:`db.collection.find()`, :method:`db.collection.distinct()`,
:method:`db.collection.findOne()`, :query:`$ne`
:query:`$and`, :query:`$or`, :query:`$gt`, :query:`$lt`,
:query:`$exists`, :query:`$lte`, :query:`$regex`,
:method:`~cursor.limit()`, :method:`~cursor.skip()`,
:method:`~cursor.explain()`, :method:`~cursor.sort()`, and
:method:`~cursor.count()`.
Update Records
~~~~~~~~~~~~~~
The following table presents the various SQL statements related to
updating existing records in tables and the corresponding MongoDB
statements.
.. include:: /includes/table/sql-to-mongo-update-examples.rst
For more information, see :method:`db.collection.update()`,
:update:`$set`, :update:`$inc`, and :query:`$gt`.
Delete Records
~~~~~~~~~~~~~~
The following table presents the various SQL statements related to
deleting records from tables and the corresponding MongoDB statements.
.. include:: /includes/table/sql-to-mongo-delete-examples.rst
For more information, see :method:`db.collection.remove()`.
Jump to Line
Something went wrong with that request. Please try again.