Docs Menu
Docs Home
/
Relational Migrator

Mapping Rules

On this page

  • MongoDB Schema Design Patterns
  • Mapping Direction Preference
  • Relationships
  • Default Rules
  • Data Type Detection
  • Preview Mapping Rules
  • Migrate as Options

A mapping rule specifies where data from each relational table should be migrated to and how the columns should be mapped to fields in MongoDB documents. Mapping rules are created inside a project after you have provided a valid relational database connection string and credentials.

Schema design patterns in MongoDB shape how your data is organized. Good schema design practices ensure efficient storage, retrieval, and manipulation of your data. These design decisions can improve the performance and scalability of your MongoDB deployment. Relational Migrator allows you to make key schema design decisions such as combining multiple tables into a single collection or embedding data in your documents.

For an overview of schema design best practices, review the following documentation:

  • Data Model Examples and Patterns.

  • Building with Patterns.

  • Summary of Schema Design Anti-Patterns and How to Spot Them.

The source relational model is static and unchanging while the target MongoDB model is dynamic and customizable.

You can create a mapping rule based on a source relational model or based on a destination MongoDB model.

Mapping rules help define a one-to-one, one-to-many, or many-to-many relationship between your tables and collections.

You can define mapping rules for the following configurations:

  • A single table that maps to a single MongoDB collection.

  • A single table that maps to multiple MongoDB collections.

  • Multiple tables that map into a single collection.

Relational Migrator automatically creates a New Documents mapping rule for each source table. This initial rule produces a MongoDB schema that is identical to the relational database. You can edit the initial rule before running any data migration jobs.

Relational Migrator automatically selects the best MongoDB data type for each source column.

For example, SQL Server source data of types text, varchar, nvarchar or char will become the MongoDB string data type.

You can preview how mapping rules affect your data model by viewing the blue dotted box in the MongoDB diagram pane. This allows you to preview the mapping rule before you apply it.

  • If the collection entity doesn't exist, it is added to the diagram with a preview state around the entire card.

  • If the collection entity already exists, the embedded mappings are added to the card with a preview state around the new fields.

Preview Mapping Options

Mapping rules can be defined with the following Migrate as options:

Option
Behavior
Migrate rows as New Documents
Translates each relational database row to a new document.
Translates each row into an array element within a parent document identified by a foreign key relationship.
Translates each row as a set of fields or an embedded object in a child document identified by a foreign key relationship.
← Rename a Project