Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCSP-47559 updates the data modeling page #215

Merged
merged 10 commits into from
Mar 21, 2025
72 changes: 51 additions & 21 deletions source/mapping-rules/introduction.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Data Modeling
:depth: 2
:class: singlecol

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.
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
------------------------------
Expand All @@ -39,17 +40,12 @@ documentation:
- `Summary of Schema Design Anti-Patterns and How to Spot Them
<https://www.mongodb.com/developer/products/mongodb/schema-design-anti-pattern-summary/>`__.

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 :ref:`relational model <create-rule-relational>`
or based on a destination :ref:`MongoDB model <create-rule-mongodb>`.
Details
-------

Relationships
-------------
~~~~~~~~~~~~~

Mapping rules help define a ``one-to-one``, ``one-to-many``, or ``many-to-many``
relationship between your tables and collections.
Expand All @@ -63,31 +59,37 @@ You can define mapping rules for the following configurations:
- Multiple tables that map into a single collection.

Default Rules
-------------
~~~~~~~~~~~~~

{+rel-mig+} automatically creates a :ref:`New Documents mapping rule <rm-new-documents>`
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
-------------------
~~~~~~~~~~~~~~~~~~~

{+rel-mig+} 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.
``nvarchar`` or ``char`` become the MongoDB ``string`` data type.

Preview Mapping Rules
---------------------
Mapping Direction Preference
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. include:: /includes/mapping-options-preview.rst
You can create a mapping rule based on a source :ref:`relational model <create-rule-relational>`
or based on a destination :ref:`MongoDB model <create-rule-mongodb>`.

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 :ref:`<rm-manage-relational-model>`.

Migrate as Options
------------------
Row Mapping Options
~~~~~~~~~~~~~~~~~~~

Mapping rules can be defined with the following ``Migrate as`` options:
You can define mapping rules with the following ``Migrate as`` options:

.. list-table::
:header-rows: 1
Expand All @@ -105,6 +107,34 @@ Mapping rules can be defined with the following ``Migrate as`` options:
* - :ref:`Migrate rows as Embedded documents <rm-embedded-documents>`
- 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 :ref:`custom fields <rm-field-customizations>`.
Relational Migrator also supports :ref:`table filters <rm-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 :ref:`synthetic foreign keys <rm-synthetic-foreign-keys>`. All foreign keys are translated
to MongoDB :ref:`document references <data-modeling-referencing>` when Relational
Migrator transforms your source relational data into MongoDB collections. For more information,
see :ref:`<rm-synthetic-foreign-keys>`.

Preview Mapping Rules
---------------------

.. include:: /includes/mapping-options-preview.rst

Learn More
----------

- :ref:`<rm-schema-mapping>`
- :ref:`<rm-mapping-rule-options>`
- :ref:`rm-diagrams`

.. toctree::
:titlesonly:
:hidden:
Expand Down
2 changes: 2 additions & 0 deletions source/mapping-rules/schema-mapping.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _rm-schema-mapping:

==============
Schema Mapping
==============
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _rm-synthetic-foreign-keys:

======================
Synthetic Foreign Keys
======================
Expand Down
Loading