By default, the driver generates a mixed-normalized view, which changes the composition of the relational tables and which objects are mapped to child tables.

In the following example, the collection residents contains the array vehicles and fields in the address document (or object). The collection's JSON structure can be rendered as follows:

{"_id": "ajx363",
 "name": "Sydney Smith",
 "address": {"street": "101 Main Street", "city": "Raleigh", "state": "NC"},
 "county": "Wake",
 "vehicles": ["car", "boat"]
}

{"_id": "tzn525",
 "name": "Cora Welch",
 "address": {"street": "191 First Street", "city": "Chapel Hill", "state": "NC"},
 "county": "Orange",
 "vehicles": ["scooter", "truck"]
}

In the mixed view, fields containing simple types are mapped to the parent table and nested complex types and arrays are mapped as child tables. Subdocuments with simple types are appended to the parent table. Therefore, normalization of the residents collection, produces a single table. The resulting table takes the following form:

Table 1. RESIDENTS
_ID (PK) NAME ADDRESS_ STREET ADDRESS_ CITY ADDRESS_ STATE COUNTY VEHICLES_ 1 VEHICLES_ 2
ajx363 Sydney Smith 101 Main Street Raleigh NC Wake car boat
tzn525 Cora Welch 191 First Street Chapel Hill NC Orange scooter truck
The mapping of the residents collection to the RESIDENTS table is handled as follows:
  • Simple types are mapped to columns in the parent table as columns. For example, the name object is mapped to NAME column.
  • Fields for the subdocument address are mapped as columns to the parent table. Column names for fields generated from a subdocument take the following form:
    <subdocument_name>_<field_name>

    For example, for the field street in the subdocument address, the resulting column name would be ADDRESS_STREET.

  • Fields in the vehicles array are mapped as columns to the parent table. Column names for fields generated from an array take the following form:
    <array_name>_<oridinal_location>
    Important: In the mixed view, if the number of values in an array are uniform across the collection and are less than or equal to twelve per element, the array values are flattened into columns in the parent table (for example, VEHICLES_1, VEHICLES_2). If the number of values are not uniform or exceed twelve per element, the driver maps the array to a child table.
    For example, for the second value of the array vehicles, the resulting column name would be VEHICLE_2.