JReport Designer supports extracting the metadata from the documents of a collection in a MongoDB database, and transforming schemas to relational tables. In the transformation process, elements in a MongoDB collection are transformed to tables according to the ideographic transformation rules, and the hierarchical logic in the MongoDB collection is maintained in the transformed relational schema by joins between the primary key and foreign key in the tables.
The metadata must be extracted from the documents of a MongoDB collection. The following rules and method for a given document will be applied for the extract.
Extracting rules
Extracting method
When a MongoDB collection is transformed to a relational schema automatically, tables will be built based on the schema.
JReport Designer takes the following rules during the transformation:
After a document is mapped to a table, the following elements in the document will be mapped to the columns in the table:
However, as MongoDB databases use dynamic collections, a heterogeneous set of documents may be stored within a collection, and only when the data in an array is of the same data type, can it be supported by JReport Designer.
Before the data types defined in the MongoDB documents can function with JReport Designer, they should be converted into corresponding SQL data types when the MongoDB collections are transformed, following the rules in the tables below.
BSON Data Type ID | BSON Data Type Name | Is Simple Data | SQL Type | SQL Type Name |
---|---|---|---|---|
"\x01" | Floating point | Y | 8 | Double |
"\x02" | UTF-8 string | Y | 12 | VARCHAR |
"\x03" | Embedded document | N | N/A | |
"\x04" | Array (containing simple data only) | N | 2003 | ARRAY |
"\x05" | Binary data | Y | -3 | VARBINARY |
"\x06" | Undefined — Deprecated | N | N/A | |
"\x07" | Objectld | Y | 1 | CHAR (hex string presents 12 bytes) |
"\x08" | Boolean | Y | 16 | BOOLEAN |
"\x09" | UTC datetime | Y | 93 | TIMESTAMP |
"\x0A" | Null value | N | N/A | |
"\x0B" | Regular expression | Y | 12 | VARCHAR |
"\x0C" | DBPointer — Deprecated | N | N/A | |
"\x0D" | JavaScript code | Y | 12 | VARCHAR |
"\x0E" | Symbol — Deprecated | N | N/A | |
"\x0F" | JavaScript code w/ scope | Y | 12 | VARCHAR |
"\x10" | 32-bit Integer | Y | 4 | INTEGER |
"\x11" | Timestamp | Y | 93 | TIMESTAMP |
"\x12" | 64-bit integer | Y | -5 | BIGINT |
"\xFF" | Min key | N | N/A | |
"\x7F" | Max key | N | N/A |
BSON Data Type ID | SQL Data Type Name |
---|---|
\x00" | Binary / Generic |
"\x01" | Function |
"\x02" | Binary (Old) |
"\x03" | UUID (Old) |
"\x04" | UUID |
"\x05" | MD5 |
"\x80" | User defined |