Docs Menu
Docs Home
/
Relational Migrator
/

Schema Mapping

On this page

  • Mapping Rules
  • Example
  • Use-Case Denormalizing Table Structure
  • Mapping Rule Results
  • Mapping Rule Implementation

Schema mapping is the process by which you decide how your source relational schema should be represented in your target MongoDB database. Facilitate the schema mapping process in Relational Migrator through customized mappings rules.

During the schema mapping design process, Relational Migrator automatically derives the source data model from the schema of your relational database. The destination data model can be influenced by customizing:

  • Mapping Rule options

  • Project ID field options

Schema Mapping Concept

This section provides a scenario and example implementation for the schema mapping process. This example converts a relational data model to a MongoDB data model.

Using the MongoEnterprises relational database, the goal is to flatten all of the database's tables, so that all the order and customer data is available in a single MongoDB collection.

The following image shows the relational data model to be denormalized using the Relational Migrator.

Relational Data Model

When using Relational Migrator, the goal is to achieve the following MongoDB data model. The Order collection contains all the child elements from the Customer, Order, Product and Order Line tables. The collection has nested objects for the migrated tables. The results look like this:

{
"_id": {
"OrderID": 1
},
"CustomerID": 1,
"OrderStatusID": 1,
"TotalAmount": 550,
"Customer": {
"CustomerID": 1,
"Name": "Joelynn Fawthrop",
"Address1": "86 Dwight Pass",
"Address2": "Carregal",
"Address3": "3800-854"
},
"OrderLines": [
{
"OrderLineID": 1,
"OrderID": 1,
"ProductID": 1,
"Quantity": 1,
"Product": {
"ProductID": 1,
"Name": "MongoDB 5.0 Action Figure",
"Price": 50
}
},
{
"OrderLineID": 4,
"OrderID": 1,
"ProductID": 3,
"Quantity": 1,
"Product": {
"ProductID": 3,
"Name": "Gold Plated MongoDB Compass",
"Price": 500
}
}
],
"OrderStatus": {
"OrderStatusID": 1,
"Name": "Order Placed"
}
}

To accomplish the target data model results with Relational Migrator, configure the Order table with the following mapping rule options:

Relational Table
Mapping Rule Type
Root Path
Order
N/A
OrderLine
OrderLines
Customer
Customer
OrderStatus
OrderStatus
Product
OrderLInes.Product
← Mapping Rules