@@ -19,29 +19,31 @@ SQL Schema Format
19
19
Overview
20
20
--------
21
21
22
- To query data using SQL, {+adl+} needs to be aware of the schema for that
23
- data. {+dl+} automatically generates a |json| schema for all new collections,
24
- except wildcard collections, and views. To learn more about auto-generated
22
+ To query data using SQL, {+adl+} needs to be aware of the schema for
23
+ that data. {+dl+} automatically generates a |json| schema for all new
24
+ collections and views. To learn more about auto-generated
25
25
schemas, see :ref:`query-with-sql`.
26
26
27
- By default, {+dl+} samples data from a single document in your collection
28
- or view to generate a |json| schema. If your collection or view contains
29
- polymorphic data, you can provide a larger sampling size to {+dl+} when
30
- manually :ref:`generating <sqlgenerateschema-cmd>` the schema.
31
-
32
- {+dl+} maps |json| schemas to relational schemas. MongoDB's :manual:`flexible
33
- schema model </core/data-modeling-introduction/>` allows a given field to
34
- contain data of multiple types, while relational databases restrict columns to
35
- a single data type. The following sections describe the fields supported in
36
- the |json| schema, the |bson| types that are supported in a relational schema,
37
- and how {+dl+} resolves conflicts for polymorphic fields when mapped to
27
+ By default, {+dl+} samples data from a single document in your
28
+ collection or view to generate a |json| schema. If your collection or
29
+ view contains polymorphic data, you can provide a larger sampling size
30
+ to {+dl+} when manually :ref:`generating <sqlgenerateschema-cmd>` the
31
+ schema.
32
+
33
+ {+dl+} maps |json| schemas to relational schemas. MongoDB's
34
+ :manual:`flexible schema model </core/data-modeling-introduction/>`
35
+ allows a given field to contain data of multiple types, while
36
+ relational databases restrict columns to a single data type. The
37
+ following sections describe the fields supported in the |json| schema,
38
+ the |bson| types that are supported in a relational schema, and how
39
+ {+dl+} resolves conflicts for polymorphic fields when mapped to
38
40
relational schema.
39
41
40
42
|json| Schema Format
41
43
--------------------
42
44
43
- The schema for a collection is a document with two fields: ``jsonSchema``
44
- and ``version``.
45
+ The schema for a collection is a document with two fields:
46
+ ``jsonSchema`` and ``version``.
45
47
46
48
.. code-block:: json
47
49
@@ -50,9 +52,9 @@ and ``version``.
50
52
"jsonSchema" : {}
51
53
}
52
54
53
- The ``version`` field represents the version of the schema format used by
54
- the document and the value is always ``1``. The ``jsonSchema`` field is
55
- a document that describes the schema of the :manual:`namespace
55
+ The ``version`` field represents the version of the schema format used
56
+ by the document and the value is always ``1``. The ``jsonSchema`` field
57
+ is a document that describes the schema of the :manual:`namespace
56
58
</reference/limits/#faq-dev-namespace>`.
57
59
58
60
.. _sql-json-schema-fields:
@@ -77,18 +79,18 @@ Supported BSON Types
77
79
{+dl+} only supports the following |bson| types when mapping |json|
78
80
schema to relational schema:
79
81
80
- - ``double``
81
- - ``string``
82
- - ``object``
83
82
- ``array``
84
83
- ``binData``
85
- - ``objectId``
86
84
- ``bool``
87
85
- ``date``
88
- - ``null``
86
+ - ``decimal``
87
+ - ``double``
89
88
- ``int``
90
89
- ``long``
91
- - ``decimal``
90
+ - ``null``
91
+ - ``object``
92
+ - ``objectId``
93
+ - ``string``
92
94
93
95
Other types are ignored in the relational schema. Fields with
94
96
composite types, such as objects and arrays, are handled specially.
@@ -97,8 +99,8 @@ Object Fields
97
99
~~~~~~~~~~~~~
98
100
99
101
Object fields are flattened such that each nested field maps to its
100
- own column in the relational schema. For example, consider the following
101
- ``eg`` collection:
102
+ own column in the relational schema. For example, consider the
103
+ following ``eg`` collection:
102
104
103
105
.. code-block:: json
104
106
@@ -237,12 +239,13 @@ are representations of the above schema:
237
239
Type Conversion Conflicts
238
240
-------------------------
239
241
240
- MongoDB's :manual:`flexible schema model </core/data-modeling-introduction/>`
241
- allows a given field to contain data of multiple types, while relational
242
- databases restrict columns to a single data type. When {+dl+} maps the
243
- |json| schema to relational schema, type conflicts can occur if a field
244
- is polymorphic. There are two main categories of type conversion conflicts
245
- that might occur when there are multiple data types:
242
+ MongoDB's :manual:`flexible schema model
243
+ </core/data-modeling-introduction/>` allows a given field to contain
244
+ data of multiple types, while relational databases restrict columns to
245
+ a single data type. When {+dl+} maps the |json| schema to relational
246
+ schema, type conflicts can occur if a field is polymorphic. There are
247
+ two main categories of type conversion conflicts that might occur when
248
+ there are multiple data types:
246
249
247
250
- Conflicts between scalar types
248
251
- Conflicts involving composite types like documents and arrays
@@ -281,9 +284,9 @@ Document Conflicts
281
284
##################
282
285
283
286
When a conflict occurs involving a document, {+dl+} displays the fields
284
- of the document type as separate columns using dot notation. For example,
285
- consider a collection named ``conflict`` that contains the following
286
- documents:
287
+ of the document type as separate columns using dot notation. For
288
+ example, consider a collection named ``conflict`` that contains the
289
+ following documents:
287
290
288
291
.. code-block:: javascript
289
292
:copyable: false
0 commit comments