Data Modeling
On this page
To model your data in Relational Migrator, design a MongoDB schema and create mapping rules. Mapping rules specify how relational table columns are mapped to MongoDB documents. You can create mapping rules in 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:
Details
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
become the MongoDB string
data type.
Mapping Direction Preference
You can create a mapping rule based on a source relational model or based on a destination MongoDB model.
You can modify your MongoDB model as you create mapping rules, but Relational Migrator treats your relational model as static and unchanging. If your relational database schema changes, you must refresh the relational model. For more information, see Manage the Relational Model.
Row Mapping Options
You can define mapping rules 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. |
Custom Fields and Filters
You can create mapping rules with custom fields. Relational Migrator also supports table filters to limit data migrated from relational tables.
Manually Add Synthetic Foreign Keys
If your database does not have foreign key constraints, you can manually add foreign keys as synthetic foreign keys. All foreign keys are translated to MongoDB document references when Relational Migrator transforms your source relational data into MongoDB collections. For more information, see Synthetic Foreign Keys.
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.
