diff --git a/bin/makefile.tables b/bin/makefile.tables index 0f4826916fa..de453929b18 100644 --- a/bin/makefile.tables +++ b/bin/makefile.tables @@ -4,7 +4,11 @@ .PHONY: tables clean-tables # add each built table to this variable here: -output-tables = source/includes/table-sql-to-agg-examples.rst source/includes/table-sql-to-agg-terms.rst +output-tables = source/includes/table-sql-to-agg-examples.rst source/includes/table-sql-to-agg-terms.rst \ + source/includes/table-sql-to-mongo-executables.rst source/includes/table-sql-to-mongo-terms.rst \ + source/includes/table-sql-to-mongo-schema-examples.rst source/includes/table-sql-to-mongo-insert-examples.rst \ + source/includes/table-sql-to-mongo-select-examples.rst source/includes/table-sql-to-mongo-update-examples.rst \ + source/includes/table-sql-to-mongo-delete-examples.rst tables: $(output-tables) @git update-index --assume-unchanged # @echo [build]: clensing git index of $(output-tables) @@ -23,4 +27,25 @@ source/includes/table-sql-to-agg-terms.rst:source/includes/table-sql-to-agg-term source/includes/table-sql-to-agg-examples.rst:source/includes/table-sql-to-agg-examples.yaml @$(PYTHONBIN) bin/table_builder.py $< $@ @echo [table-builder]: \(re\)generate $@ table for inclusion in build +source/includes/table-sql-to-mongo-executables.rst:source/includes/table-sql-to-mongo-executables.yaml + @$(PYTHONBIN) bin/table_builder.py $< $@ + @echo [table-builder]: \(re\)generate $@ table for inclusion in build +source/includes/table-sql-to-mongo-terms.rst:source/includes/table-sql-to-mongo-terms.yaml + @$(PYTHONBIN) bin/table_builder.py $< $@ + @echo [table-builder]: \(re\)generate $@ table for inclusion in build +source/includes/table-sql-to-mongo-schema-examples.rst:source/includes/table-sql-to-mongo-schema-examples.yaml + @$(PYTHONBIN) bin/table_builder.py $< $@ + @echo [table-builder]: \(re\)generate $@ table for inclusion in build +source/includes/table-sql-to-mongo-insert-examples.rst:source/includes/table-sql-to-mongo-insert-examples.yaml + @$(PYTHONBIN) bin/table_builder.py $< $@ + @echo [table-builder]: \(re\)generate $@ table for inclusion in build +source/includes/table-sql-to-mongo-select-examples.rst:source/includes/table-sql-to-mongo-select-examples.yaml + @$(PYTHONBIN) bin/table_builder.py $< $@ + @echo [table-builder]: \(re\)generate $@ table for inclusion in build +source/includes/table-sql-to-mongo-update-examples.rst:source/includes/table-sql-to-mongo-update-examples.yaml + @$(PYTHONBIN) bin/table_builder.py $< $@ + @echo [table-builder]: \(re\)generate $@ table for inclusion in build +source/includes/table-sql-to-mongo-delete-examples.rst:source/includes/table-sql-to-mongo-delete-examples.yaml + @$(PYTHONBIN) bin/table_builder.py $< $@ + @echo [table-builder]: \(re\)generate $@ table for inclusion in build diff --git a/source/contents.txt b/source/contents.txt index 83872dc192c..1b4276cab04 100644 --- a/source/contents.txt +++ b/source/contents.txt @@ -18,3 +18,4 @@ MongoDB Manual Contents use-cases faq reference + sql diff --git a/source/includes/table-sql-to-mongo-delete-examples.yaml b/source/includes/table-sql-to-mongo-delete-examples.yaml new file mode 100644 index 00000000000..72364df9ee7 --- /dev/null +++ b/source/includes/table-sql-to-mongo-delete-examples.yaml @@ -0,0 +1,38 @@ +# table structure. all content symbolic. +section: layout +header: [ meta.header1, meta.header2, meta.header3] +rows: + - 1: [ content.sql1, content.mongo1, content.ref1 ] + - 2: [ content.sql2, content.mongo2, content.ref1 ] +--- +# table metadata, as meta. +section: meta +header1: "SQL Delete Statements" +header2: "MongoDB remove() Statements" +header3: "Reference" +--- +# table content, as content. +section: content +sql1: | + .. code-block:: sql + + DELETE FROM users + WHERE status = "D" +mongo1: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.remove( { status: "D" } ) +ref1: | + See :method:`remove() ` + for more information. +sql2: | + .. code-block:: sql + + DELETE FROM users +mongo2: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.remove( ) +... \ No newline at end of file diff --git a/source/includes/table-sql-to-mongo-executables.yaml b/source/includes/table-sql-to-mongo-executables.yaml new file mode 100644 index 00000000000..35b476eb448 --- /dev/null +++ b/source/includes/table-sql-to-mongo-executables.yaml @@ -0,0 +1,22 @@ +# table structure. all content symbolic. +section: layout +header: [ meta.header1, meta.header2, meta.header3 ] +rows: + - 1: [ content.desc1, content.sql1, content.mongo1 ] + - 2: [ content.desc2, content.sql2, content.mongo2 ] +--- +# table metadata, as meta. +section: meta +header1: " " +header2: "MySQL/Oracle" +header3: "MongoDB" +--- +# table content, as content. +section: content +desc1: Database Server +sql1: mysqld/oracle +mongo1: :doc:`mongod ` +desc2: Database Client +sql2: mysql/sqlplus +mongo2: :doc:`mongo ` +... \ No newline at end of file diff --git a/source/includes/table-sql-to-mongo-insert-examples.yaml b/source/includes/table-sql-to-mongo-insert-examples.yaml new file mode 100644 index 00000000000..40c3d60f8ae --- /dev/null +++ b/source/includes/table-sql-to-mongo-insert-examples.yaml @@ -0,0 +1,37 @@ +# table structure. all content symbolic. +section: layout +header: [ meta.header1, meta.header2, meta.header3] +rows: + - 1: [ content.sql1, content.mongo1, content.ref1 ] +--- +# table metadata, as meta. +section: meta +header1: "SQL INSERT Statements" +header2: "MongoDB insert() Statements" +header3: "Reference" +--- +# table content, as content. +section: content +sql1: | + + .. code-block:: sql + + INSERT INTO users(user_id, + age, + status) + VALUES ("bcd001", + 45, + "A") +mongo1: | + .. code-block:: javascript + :emphasize-lines: 1-5 + + db.users.insert( { + user_id: "bcd001", + age: 45, + status: "A" + } ) +ref1: | + See :method:`insert() ` + for more information. +... \ No newline at end of file diff --git a/source/includes/table-sql-to-mongo-schema-examples.yaml b/source/includes/table-sql-to-mongo-schema-examples.yaml new file mode 100644 index 00000000000..5d3b2d50bdb --- /dev/null +++ b/source/includes/table-sql-to-mongo-schema-examples.yaml @@ -0,0 +1,135 @@ +# table structure. all content symbolic. +section: layout +header: [ meta.header1, meta.header2, meta.header3] +rows: + - 1: [ content.sql1, content.mongo1, content.ref1 ] + - 2: [ content.sql2, content.mongo2, content.ref2 ] + - 3: [ content.sql3, content.mongo3, content.ref3 ] + - 4: [ content.sql4, content.mongo4, content.ref4 ] + - 5: [ content.sql5, content.mongo5, content.ref4 ] + - 6: [ content.sql6, content.mongo6, content.ref6 ] +--- +# table metadata, as meta. +section: meta +header1: "SQL Schema Statements" +header2: "MongoDB Schema Statements" +header3: "Reference" +--- +# table content, as content. +section: content +sql1: | + .. code-block:: sql + + CREATE TABLE users ( + id MEDIUMINT NOT NULL + AUTO_INCREMENT, + user_id Varchar(30), + age Number, + status char(1), + PRIMARY KEY (id) + ) +mongo1: | + Implicitly created on first :method:`insert + ` operation. The primary key ``_id`` is + automatically added if ``_id`` field is not specified. + + .. code-block:: javascript + :emphasize-lines: 1-5 + + db.users.insert( { + user_id: "abc123", + age: 55, + status: "A" + } ) + + However, you can also explicitly create a table: + + .. code-block:: javascript + :emphasize-lines: 1 + + db.createCollection("users") +ref1: | + See + :method:`insert() ` and + :method:`createCollection() ` + for more information. +sql2: | + .. code-block:: sql + + ALTER TABLE users + ADD join_date DATETIME +mongo2: | + Update operations can add fields to all documents in a + collection: + + .. code-block:: javascript + :emphasize-lines: 1-5 + + db.users.update( + { }, + { $set: { join_date: null } }, + { multi: 1 } + ) + + Because each :term:`document` determines its own fields, a + document may contain fields not contained by the other + documents in the collection. +ref2: | + See :method:`update() ` and + :operator:`$set` for more information. +sql3: | + .. code-block:: sql + + ALTER TABLE users + DROP COLUMN join_date +mongo3: | + Update operations can remove fields from all documents in a + collection: + + .. code-block:: javascript + :emphasize-lines: 1-5 + + db.users.update( + { }, + { $unset: { join_date: "" } }, + { multi: 1 } + ) +ref3: | + See :method:`update() ` + and :operator:`$unset` for more information. +sql4: | + .. code-block:: sql + + CREATE INDEX idx_user_id_asc + ON users(user_id) +mongo4: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.ensureIndex( { user_id: 1 } ) +ref4: | + See :method:`ensureIndex() ` + and :doc:`indexes ` for more information. +sql5: | + .. code-block:: sql + + CREATE INDEX idx_user_id_asc_age_desc + ON users(name, age DESC) +mongo5: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.ensureIndex( { user_id: 1, age: -1 } ) +sql6: | + .. code-block:: sql + + DROP TABLE users +mongo6: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.remove() +ref6: | + See :method:`remove() ` for + more information. +... diff --git a/source/includes/table-sql-to-mongo-select-examples.yaml b/source/includes/table-sql-to-mongo-select-examples.yaml new file mode 100644 index 00000000000..4e75e2a9f67 --- /dev/null +++ b/source/includes/table-sql-to-mongo-select-examples.yaml @@ -0,0 +1,402 @@ +# table structure. all content symbolic. +section: layout +header: [ meta.header1, meta.header2, meta.header3] +rows: + - 1: [ content.sql1, content.mongo1, content.ref1 ] + - 2: [ content.sql2, content.mongo2, content.ref1 ] + - 3: [ content.sql3, content.mongo3, content.ref1 ] + - 4: [ content.sql4, content.mongo4, content.ref1 ] + - 5: [ content.sql5, content.mongo5, content.ref1 ] + - 6: [ content.sql6, content.mongo6, content.ref6 ] + - 7: [ content.sql7, content.mongo7, content.ref7 ] + - 8: [ content.sql8, content.mongo8, content.ref8 ] + - 9: [ content.sql9, content.mongo9, content.ref9 ] + - 10: [ content.sql10, content.mongo10, content.ref10 ] + - 11: [ content.sql11, content.mongo11, content.ref11 ] + - 12: [ content.sql12, content.mongo12, content.ref12 ] + - 13: [ content.sql13, content.mongo13, content.ref12 ] + - 14: [ content.sql14, content.mongo14, content.ref14 ] + - 15: [ content.sql15, content.mongo15, content.ref14 ] + - 16: [ content.sql16, content.mongo16, content.ref16 ] + - 17: [ content.sql17, content.mongo17, content.ref17 ] + - 18: [ content.sql18, content.mongo18, content.ref18 ] + - 19: [ content.sql19, content.mongo19, content.ref19 ] + - 20: [ content.sql20, content.mongo20, content.ref20 ] + - 21: [ content.sql21, content.mongo21, content.ref21 ] + - 22: [ content.sql22, content.mongo22, content.ref22 ] +--- +# table metadata, as meta. +section: meta +header1: "SQL SELECT Statements" +header2: "MongoDB find() Statements" +header3: "Reference" +--- +# table content, as content. +section: content +sql1: | + .. code-block:: sql + + SELECT * + FROM users +mongo1: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find( ) + + *or* + + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find( { } ) +ref1: | + See :method:`find() ` + for more information. +sql2: | + .. code-block:: sql + + SELECT id, user_id, status + FROM users +mongo2: | + .. code-block:: javascript + :emphasize-lines: 1-4 + + db.users.find( + { }, + { user_id: 1, status: 1 } + ) +sql3: | + .. code-block:: sql + + SELECT user_id, status + FROM users +mongo3: | + .. code-block:: javascript + :emphasize-lines: 1-4 + + db.users.find( + { }, + { user_id: 1, status: 1, _id: 0 } + ) +sql4: | + .. code-block:: sql + + SELECT * + FROM users + WHERE status = "A" +mongo4: | + .. code-block:: javascript + :emphasize-lines: 1-3 + + db.users.find( + { status: "A" } + ) +sql5: | + .. code-block:: sql + + SELECT user_id, status + FROM users + WHERE status = "A" +mongo5: | + .. code-block:: javascript + :emphasize-lines: 1-3 + + db.users.find( + { status: "A" }, + { user_id: 1, status: 1, _id: 0 } + ) +sql6: | + .. code-block:: sql + + SELECT * + FROM users + WHERE status != "A" +mongo6: | + .. code-block:: javascript + :emphasize-lines: 1-3 + + db.users.find( + { status: { $ne: "A" } } + ) +ref6: | + See :method:`find() ` + and :operator:`$ne` for more information. +sql7: | + .. code-block:: sql + + SELECT * + FROM users + WHERE status = "A" + AND age = 50 +mongo7: | + .. code-block:: javascript + :emphasize-lines: 1-4 + + db.users.find( + { status: "A", + age: 50 } + ) +ref7: | + See :method:`find() ` + and :operator:`$and` for more information. +sql8: | + .. code-block:: sql + + SELECT * + FROM users + WHERE status = "A" + OR age = 50 +mongo8: | + .. code-block:: javascript + :emphasize-lines: 1-4 + + db.users.find( + { $or: [ { status: "A" } , + { age: 50 } ] } + ) +ref8: | + See :method:`find() ` + and :operator:`$or` for more information. +sql9: | + .. code-block:: sql + + SELECT * + FROM users + WHERE age > 25 +mongo9: | + .. code-block:: javascript + :emphasize-lines: 1-3 + + db.users.find( + { age: { $gt: 25 } } + ) +ref9: | + See :method:`find() ` + and :operator:`$gt` for more information. +sql10: | + .. code-block:: sql + + SELECT * + FROM users + WHERE age < 25 +mongo10: | + .. code-block:: javascript + :emphasize-lines: 1-3 + + db.users.find( + { age: { $lt: 25 } } + ) +ref10: | + See :method:`find() ` + and :operator:`$lt` for more information. +sql11: | + .. code-block:: sql + + SELECT * + FROM users + WHERE age > 25 + AND age <= 50 +mongo11: | + .. code-block:: javascript + :emphasize-lines: 1-3 + + db.users.find( + { age: { $gt: 25, $lte: 50 } } + ) +ref11: | + See :method:`find() `, + :operator:`$gt`, and :operator:`$lte` for + more information. +sql12: | + .. code-block:: sql + + SELECT * + FROM users + WHERE user_id like "%bc%" +mongo12: | + .. code-block:: javascript + :emphasize-lines: 1-3 + + db.users.find( + { user_id: /bc/ } + ) +ref12: | + See :method:`find() ` + and :operator:`$regex` for more information. + +sql13: | + .. code-block:: sql + + SELECT * + FROM users + WHERE user_id like "bc%" +mongo13: | + .. code-block:: javascript + :emphasize-lines: 1-3 + + db.users.find( + { user_id: /^bc/ } + ) +sql14: | + .. code-block:: sql + + SELECT * + FROM users + WHERE status = "A" + ORDER BY user_id ASC +mongo14: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find( { status: "A" } ).sort( { user_id: 1 } ) +ref14: | + See :method:`find() ` + and :method:`sort() ` + for more information. +sql15: | + .. code-block:: sql + + SELECT * + FROM users + WHERE status = "A" + ORDER BY user_id DESC +mongo15: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find( { status: "A" } ).sort( { user_id: -1 } ) +sql16: | + .. code-block:: sql + + SELECT COUNT(*) + FROM users +mongo16: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.count() + + *or* + + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find().count() +ref16: | + See :method:`find() ` + and :method:`count() ` for + more information. +sql17: | + .. code-block:: sql + + SELECT COUNT(user_id) + FROM users +mongo17: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.count( { user_id: { $exists: true } } ) + + *or* + + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find( { user_id: { $exists: true } } ).count() +ref17: | + See :method:`find() `, + :method:`count() `, and + :operator:`$exists` for more information. +sql18: | + .. code-block:: sql + + SELECT COUNT(*) + FROM users + WHERE age > 30 +mongo18: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.count( { age: { $gt: 30 } } ) + + *or* + + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find( { age: { $gt: 30 } } ).count() +ref18: | + See :method:`find() `, + :method:`count() `, and + :operator:`$gt` for more information. +sql19: | + .. code-block:: sql + + SELECT DISTINCT(status) + FROM users +mongo19: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.distinct( "status" ) +ref19: | + See :method:`find() ` + and :method:`distinct() ` + for more information. +sql20: | + .. code-block:: sql + + SELECT * + FROM users + LIMIT 1 +mongo20: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.findOne() + + *or* + + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find().limit(1) +ref20: | + See :method:`find() `, + :method:`findOne() `, + and :method:`limit() ` + for more information. +sql21: | + .. code-block:: sql + + SELECT * + FROM users + LIMIT 5 + SKIP 10 +mongo21: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find().limit(5).skip(10) +ref21: | + See :method:`find() `, + :method:`limit() `, and + :method:`skip() ` for + more information. +sql22: | + .. code-block:: sql + + EXPLAIN SELECT * + FROM users + WHERE status = "A" +mongo22: | + .. code-block:: javascript + :emphasize-lines: 1 + + db.users.find( { status: "A" } ).explain() +ref22: | + See :method:`find() ` + and :method:`explain() ` + for more information. +... diff --git a/source/includes/table-sql-to-mongo-terms.yaml b/source/includes/table-sql-to-mongo-terms.yaml new file mode 100644 index 00000000000..51fb859f06a --- /dev/null +++ b/source/includes/table-sql-to-mongo-terms.yaml @@ -0,0 +1,49 @@ +# table structure. all content symbolic. +section: layout +header: [ meta.header1, meta.header2] +rows: + - 1: [ content.sql1, content.mongo1 ] + - 2: [ content.sql2, content.mongo2 ] + - 3: [ content.sql3, content.mongo3 ] + - 4: [ content.sql4, content.mongo4 ] + - 5: [ content.sql5, content.mongo5 ] + - 6: [ content.sql6, content.mongo6 ] + - 7: [ content.sql7, content.mongo7 ] + - 8: [ content.sql8, content.mongo8 ] +--- +# table metadata, as meta. +section: meta +header1: "SQL Terms/Concepts" +header2: "MongoDB Terms/Concepts" +--- +# table content, as content. +section: content +sql1: database +mongo1: :term:`database` +sql2: table +mongo2: :term:`collection` +sql3: row +mongo3: :term:`document` or :term:`BSON` document +sql4: column +mongo4: :term:`field` +sql5: index +mongo5: :term:`index` +sql6: table joins +mongo6: embedded documents and linking +sql7: | + primary key + + Specify any unique column or column combination as primary + key. +mongo7: | + :term:`primary key` + + In MongoDB, the primary key is automatically set to the + :term:`_id` field. +sql8: aggregation (e.g. group by) +mongo8: | + aggregation framework + + See the :doc:`SQL to Aggregation Framework Mapping Chart + `. +... diff --git a/source/includes/table-sql-to-mongo-update-examples.yaml b/source/includes/table-sql-to-mongo-update-examples.yaml new file mode 100644 index 00000000000..602d37b0e25 --- /dev/null +++ b/source/includes/table-sql-to-mongo-update-examples.yaml @@ -0,0 +1,56 @@ +# table structure. all content symbolic. +section: layout +header: [ meta.header1, meta.header2, meta.header3] +rows: + - 1: [ content.sql1, content.mongo1, content.ref1 ] + - 2: [ content.sql2, content.mongo2, content.ref2 ] +--- +# table metadata, as meta. +section: meta +header1: "SQL Update Statements" +header2: "MongoDB update() Statements" +header3: "Reference" +--- +# table content, as content. +section: content +sql1: | + + .. code-block:: sql + + UPDATE users + SET status = "C" + WHERE age > 25 +mongo1: | + .. code-block:: javascript + :emphasize-lines: 1-5 + + db.users.update( + { age: { $gt: 25 } }, + { $set: { status: "C" } }, + { multi: true } + ) +ref1: | + See :method:`update() `, + :operator:`$gt`, and :operator:`$set` for more + information. +sql2: | + + .. code-block:: sql + + UPDATE users + SET age = age + 3 + WHERE status = "A" +mongo2: | + .. code-block:: javascript + :emphasize-lines: 1-5 + + db.users.update( + { status: "A" } , + { $inc: { age: 3 } }, + { multi: true } + ) +ref2: | + See :method:`update() `, + :operator:`$inc`, and :operator:`$set` for more + information. +... \ No newline at end of file diff --git a/draft/reference/sql-reference/sql-aggregation-xref.txt b/source/reference/sql-aggregation-comparison.txt similarity index 94% rename from draft/reference/sql-reference/sql-aggregation-xref.txt rename to source/reference/sql-aggregation-comparison.txt index 6b69adc7c05..fbdcaa9ca34 100644 --- a/draft/reference/sql-reference/sql-aggregation-xref.txt +++ b/source/reference/sql-aggregation-comparison.txt @@ -1,7 +1,7 @@ .. default-domain:: mongodb -SQL to Aggregation Framework ----------------------------- +SQL to Aggregation Framework Mapping Chart +------------------------------------------ With its :doc:`aggregation framework `, MongoDB provides analogous functionality to common SQL aggregation diff --git a/source/reference/sql-comparison.txt b/source/reference/sql-comparison.txt new file mode 100644 index 00000000000..4ec5a424588 --- /dev/null +++ b/source/reference/sql-comparison.txt @@ -0,0 +1,87 @@ +.. default-domain:: mongodb + +SQL to Mongo Mapping Chart +-------------------------- + +Executables +~~~~~~~~~~~ + +The following table presents a quick reference to the MySQL/Oracle +executables and the corresponding MongoDB executables. + +.. include:: /includes/table-sql-to-mongo-executables.rst + +Terminology/Concepts +~~~~~~~~~~~~~~~~~~~~ + +The following table presents a quick reference of the various SQL +terminology and concepts and the corresponding MongoDB terminology and +concepts. + +.. include:: /includes/table-sql-to-mongo-terms.rst + +Examples +~~~~~~~~ + +The following table presents a quick reference of the various SQL +statements and the corresponding MongoDB statements. The examples in +the table assume the following conditions: + +- The SQL examples assume a table ``users``. + +- The MongoDB examples assume a collection ``users`` that contain + documents of the following prototype: + + .. code-block:: javascript + + { + _id: ObjectID("509a8fb2f3f4948bd2f983a0"), + user_id: "abc123", + age: 55, + status: 'A' + } + +Create and Alter Table +`````````````````````` + +The following table presents a quick reference of the various SQL +statements related to table-level actions and the corresponding MongoDB +statements. + +.. include:: /includes/table-sql-to-mongo-schema-examples.rst + +Insert into Table +````````````````` + +The following table presents a quick reference of the various SQL +statements related to inserting records into tables and the +corresponding MongoDB statements. + +.. include:: /includes/table-sql-to-mongo-insert-examples.rst + +Select from Table +````````````````` + +The following table presents a quick reference of the various SQL +statements related to reading records from tables and the corresponding +MongoDB statements. + +.. include:: /includes/table-sql-to-mongo-select-examples.rst + +Update Records in Table +``````````````````````` + +The following table presents a quick reference of 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 + +Delete Records from Table +````````````````````````` + +The following table presents a quick reference of the various SQL +statements related to deleting records from tables and the +corresponding MongoDB statements. + +.. include:: /includes/table-sql-to-mongo-delete-examples.rst diff --git a/source/sql.txt b/source/sql.txt new file mode 100644 index 00000000000..d9ad1ffa5ec --- /dev/null +++ b/source/sql.txt @@ -0,0 +1,12 @@ +=== +SQL +=== + +The following documents provide mappings between SQL +concepts/statements and MongoDB concepts/statements. + +.. toctree:: + :maxdepth: 1 + + reference/sql-comparison + reference/sql-aggregation-comparison diff --git a/themes/epub_mongodb/static/epub.css b/themes/epub_mongodb/static/epub.css index 2ae00b2e3dc..e12b6937116 100644 --- a/themes/epub_mongodb/static/epub.css +++ b/themes/epub_mongodb/static/epub.css @@ -392,9 +392,10 @@ div.highlight-javascript>div.highlight>pre>span.hll>span.nx { font-weight: bold; } -/* Specific to the SQL to Aggregation Framework page -- Begin */ +/* Specific to the SQL to ... Mapping pages -- Begin */ -div#sql-to-aggregation-framework td pre { +div#sql-to-aggregation-framework-mapping-chart td pre, +div#sql-to-mongo-mapping-chart td pre { border: none; -webkit-box-shadow: none; -moz-box-shadow: none; @@ -403,23 +404,33 @@ div#sql-to-aggregation-framework td pre { background-color: transparent; } -div#sql-to-aggregation-framework table.docutils { +div#sql-to-aggregation-framework-mapping-chart table.docutils, +div#sql-to-mongo-mapping-chart table.docutils { border-collapse:collapse; border:1px solid black; } -div#sql-to-aggregation-framework table.docutils>colgroup>col { +div#sql-to-aggregation-framework-mapping-chart table.docutils>colgroup>col, +div#sql-to-mongo-mapping-chart table.docutils>colgroup>col { border-collapse:collapse; border-left:1px solid black; } -div#sql-to-aggregation-framework table.docutils>thead th.head{ +div#sql-to-aggregation-framework-mapping-chart table.docutils>thead th.head, +div#sql-to-mongo-mapping-chart table.docutils>thead th.head{ padding-top: 5px; padding-bottom: 5px; background-color: #F7F2E0; } -/* Specific to the SQL to Aggregation Framework page -- End */ +div#sql-to-mongo-mapping-chart div#examples.section table.docutils { + width: 85%; +} + +div#sql-to-mongo-mapping-chart div#examples.section table.docutils>colgroup>col:first-child { + width: 33%; +} +/* Specific to the SQL to ... Mapping page -- End */ /* -- math display ---------------------------------------------------------- */ diff --git a/themes/mongodb/static/mongodb-docs.css_t b/themes/mongodb/static/mongodb-docs.css_t index 6646a57f798..85b020b8b3e 100644 --- a/themes/mongodb/static/mongodb-docs.css_t +++ b/themes/mongodb/static/mongodb-docs.css_t @@ -312,16 +312,17 @@ table.docutils.field-list ul.first.last.simple>li>p { padding-top: 1em; } -div.first.last.highlight-javascript>div.highlight>pre>span.hll { +div.highlight-javascript>div.highlight>pre>span.hll { background-color: transparent; } -div.first.last.highlight-javascript>div.highlight>pre>span.hll>span.nx { +div.highlight-javascript>div.highlight>pre>span.hll>span.nx { font-weight: bold; } -/* Specific to the SQL to Aggregation Framework page -- Begin */ +/* Specific to the SQL to ... Mapping pages -- Begin */ -div#sql-to-aggregation-framework td pre { +div#sql-to-aggregation-framework-mapping-chart td pre, +div#sql-to-mongo-mapping-chart td pre { border: none; -webkit-box-shadow: none; -moz-box-shadow: none; @@ -330,23 +331,33 @@ div#sql-to-aggregation-framework td pre { background-color: transparent; } -div#sql-to-aggregation-framework table.docutils { +div#sql-to-aggregation-framework-mapping-chart table.docutils, +div#sql-to-mongo-mapping-chart table.docutils { border-collapse:collapse; border:1px solid black; } -div#sql-to-aggregation-framework table.docutils>colgroup>col { +div#sql-to-aggregation-framework-mapping-chart table.docutils>colgroup>col, +div#sql-to-mongo-mapping-chart table.docutils>colgroup>col { border-collapse:collapse; border-left:1px solid black; } -div#sql-to-aggregation-framework table.docutils>thead th.head{ +div#sql-to-aggregation-framework-mapping-chart table.docutils>thead th.head, +div#sql-to-mongo-mapping-chart table.docutils>thead th.head{ padding-top: 5px; padding-bottom: 5px; background-color: #F7F2E0; } -/* Specific to the SQL to Aggregation Framework page -- End */ +div#sql-to-mongo-mapping-chart div#examples.section table.docutils { + width: 85%; +} + +div#sql-to-mongo-mapping-chart div#examples.section table.docutils>colgroup>col:first-child { + width: 33%; +} +/* Specific to the SQL to ... Mapping page -- End */ /* for main page to knock out the bullets & padding for main columns */