Mapping Rules
On this page
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.
MongoDB Schema Design Patterns
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:
Mapping Direction Preference
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.
Relationships
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.
Default Rules
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.
Data Type Detection
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.
Preview Mapping Rules
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.
Migrate as Options
Mapping rules can be defined with the following Migrate as
options:
Option | Behavior |
---|---|
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. |