MongoDB® to SQL Mapping
On this page
Here are a few conceptual mappings between MongoDB® and SQL.
Databases
Similar to MongoDB®, SingleStore databases serve as a lightweight container for scoping permissions and organizing collections, and they are implicitly created with a default configuration when collections are created.
Collections to Tables
In MongoDB®, collections are containers for documents.createCollection command or implicitly when a write occurs targeting a collection.
Documents to Rows
Whenever a BSON document is inserted through SingleStore Kai ("the API"), the document itself is mapped to a row in a target table._ column.
When a document is retrieved through the API, values from all the columns except the _ column are added to the document first._ column are included afterwards._ column has the same name as another column, the value from the existing column takes precedence over the field in the _ column.
BSON
Similar to MongoDB®, SingleStore Kai natively supports the BSON data type for storage.
MongoDB® Terminologies and Concepts Mappings Table
The following table maps MongoDB® terminologies and concepts to their SQL equivalents:
|
MongoDB® Terms/Concepts |
SQL Terms/Concepts |
|---|---|
|
Database |
Database |
|
Collection |
Table |
|
View |
View |
|
Document |
Row |
|
Top-level field |
Column |
|
Additional fields not matching a column |
|
|
Index |
Index |
|
Primary key: the |
Primary key: Any unique column (including the |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE TABLE and ALTER TABLE Statement Examples
The following table shows CREATE TABLE and ALTER TABLE statements written in SQL and their MongoDB® equivalents:
|
MongoDB® Statements |
SQL Statements |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
SELECT Statement Examples
The following table shows SELECT statements written in SQL and their MongoDB® equivalents:
|
MongoDB® Statements |
SQL Statements |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INSERT Statement Examples
The following table shows INSERT statements written in SQL and their MongoDB® equivalents:
|
MongoDB® Statements |
SQL Statements |
|---|---|
|
|
|
|
UPDATE Statement Example
The following table shows UPDATE statements written in SQL and their MongoDB® equivalents:
|
MongoDB® Statements |
SQL Statements |
|---|---|
|
|
DELETE Statement Examples
The following table shows DELETE statements written in SQL and their MongoDB® equivalents:
|
MongoDB® Statements |
SQL Statements |
|---|---|
|
|
|
|
Aggregate Function Examples
The following table shows aggregate functions written in MongoDB® and their SQL equivalents:
|
MongoDB® Statements |
SQL Statements |
|---|---|
|
|
|
|
Last modified: August 9, 2024