Overview
The following topic provides an overview of using MongoDB as a source endpoint in a Replicate task.
Terminology
The following describes common database terms and their MongoDB equivalents:
Relational Database Term | Corresponding Term in MongoDB |
---|---|
Schema |
Database |
Table |
Collection |
Record |
Document |
With most Replicate source endpoints, when you define a replication task, you can select the tables you wish to replicate from one or more schemas. With MongoDB however, instead of selecting schemas, you select databases, and instead of selecting tables, you select collections. So, from a MongoDB perspective, any label in the UI that refers to source tables (e.g. Table Settings) is actually referring to source collections, and any label that refers to source records is actually referring to source documents. Likewise, any label in the UI that refers to source schemas is actually referring to source databases.
How changes are handled
Replicate reads the MongoDB oplog for changes (see Prerequisites). If a change is detected, the modified JSON document will be replicated in its entirety to the target, where it will replace the current JSON document. If the "Store Changes" replication option is also enabled, a record of all operations (UPDATE, DELETE, etc.) will be stored for each JSON document in the associated Change Table(s).
How target tables are created
For each MongoDB collection, a corresponding target table is created with two columns:
- _id - a WSTRING column containing the document's _id field (the primary key).
- _doc - an NCLOB column containing the JSON representation of the document.