Introduction
Migrating
from relational databases to NoSQL databases has traditionally been a
challenging task. Unlike relational databases that organize data into
normalized tables, MongoDB follows a document-oriented model where related data
is often embedded within a single document. This architectural difference makes
migration more than a simple data transfer—it requires schema redesign.
To
simplify this process, MongoDB provides Relational Migrator, a free
graphical tool that analyzes relational schemas, recommends an optimized
MongoDB document model, and assists with data migration.
In this
article, we'll explore how to migrate a PostgreSQL database using MongoDB
Relational Migrator and examine its intelligent schema mapping capabilities.
What is MongoDB Relational
Migrator?
MongoDB
Relational Migrator is a desktop application designed to simplify migrations
from relational databases to MongoDB.
Instead
of manually redesigning your schema, the tool automatically:
- Connects to relational
databases
- Discovers tables and
relationships
- Analyzes foreign keys
- Recommends an optimized
MongoDB document model
- Generates sample JSON
documents
- Performs migration into
MongoDB
Supported
source databases include:
- PostgreSQL
- MySQL
- SQL Server
- Oracle Database
Target
database:
- MongoDB Community
- MongoDB Enterprise
- MongoDB Atlas
Why Use MongoDB Relational
Migrator?
Migrating
manually usually involves:
- Understanding hundreds of
relationships
- Redesigning normalized
tables
- Writing ETL scripts
- Validating migrated data
- Optimizing document
structures
MongoDB
Relational Migrator automates much of this work, allowing developers to focus
on reviewing and refining the suggested document model rather than building it
from scratch.
Demo Environment
For this
demonstration, the following environment was used.
|
Component |
Version |
|
PostgreSQL |
17 |
|
MongoDB |
Community
Edition |
|
MongoDB
Relational Migrator |
1.16.2 |
|
Operating
System |
Windows
11 |
The
sample PostgreSQL database contains:
- Customers
- Customer Addresses
- Customer Profiles
- Products
- Orders
- Order Items
- Employees
- Categories
- JSONB columns
- Arrays
- Recursive tables
- Partitioned tables
- Table inheritance
This
provides a realistic enterprise-style schema for evaluation.
Step 1: Connect to
PostgreSQL
The first
step is establishing a connection to the source PostgreSQL database.
Provide:
- Host
- Port
- Database
- Username
- Password
After
validating the credentials, Relational Migrator confirms a successful
connection.
Screenshot
Step 2: Select Tables
Once
connected, the tool discovers all available schemas and tables.
You can
choose:
- Manual Selection
- Bulk Selection
For this
demo, all application tables were selected.
Screenshot
Step 3: Generate the
Initial MongoDB Schema
This is
one of the most interesting parts of the migration.
Relational
Migrator offers three options:
- Match relational schema
- Recommended MongoDB schema
- Empty MongoDB schema
For this
demo, we selected:
Start
with a Recommended MongoDB Schema
The tool
analyzes:
- Primary Keys
- Foreign Keys
- Relationship Cardinality
- Table Structure
It then
recommends which tables should become:
- Top-level collections
- Embedded documents
For
example:
Customers
│
├── Customer Addresses
├── Customer Profiles
└── Orders
instead
of creating separate collections for every table.
Screenshot
Step 4: Pre-Migration
Analysis
Before
any migration begins, the tool performs a comprehensive assessment of the
source database.
The
analysis includes:
- Migration readiness
- Unsupported database
features
- Potential risks
- Performance considerations
- Data type compatibility
The
dashboard provides an overall readiness score along with detailed
recommendations.
This
feature helps identify issues before the migration starts, reducing the
likelihood of surprises during execution.
Screenshot
Step 5: Visual Mapping
One of
the standout features of Relational Migrator is its visual mapping interface.
Instead
of reading SQL scripts or ER diagrams, you can see how relational tables are
transformed into MongoDB collections.
The
interface displays:
- Relational schema
- MongoDB collections
- Embedded relationships
- Reference mappings
Developers
can manually adjust the suggested mappings whenever required.
For
example:
Customers
│
├──
CustomerProfile
├──
CustomerAddresses
└── Orders
becomes
customers
{
profile:{},
addresses:[ ],
orders:[ ]
}
This
visualization makes it easy to understand the resulting document model before
migration.
Screenshot
Step 6: Review Generated
JSON Documents
Another
useful capability is the automatic generation of sample MongoDB documents.
The JSON
preview allows developers to verify:
- Nested objects
- Embedded arrays
- Field names
- Data types
- Collection structure
This
helps validate the document model before any data is migrated.
Example:
{
"_id": ObjectId(),
"productName": "Laptop",
"price": 45000,
"attributes": {},
"orderItems": [
{
"quantity": 2,
"price": 45000
}
]
}
This
preview significantly reduces uncertainty during schema design.
Screenshot
Step 7: Configure MongoDB
Destination
After
reviewing the schema, configure the destination MongoDB server.
Provide:
- Connection URI
- Database
- Authentication credentials
Once
connected successfully, the migration destination is ready.
Screenshot
Step 8: Migration Options
MongoDB
Relational Migrator supports multiple migration modes.
Available
options include:
- Snapshot Migration
- Continuous Migration
- Data Verification
- Error Handling
- Selective Collection
Migration
Snapshot
mode performs a one-time migration, while Continuous mode keeps MongoDB
synchronized with ongoing changes in the relational database.
Screenshot
Step 9: Review Migration Summary
Before
execution, the tool displays a migration summary.
This
includes:
- Migration mode
- Number of tables
- Rows to migrate
- Data size
- Target collections
- Validation messages
This
final review provides an opportunity to verify the migration plan before starting
the actual data transfer.
Screenshot
Note: In this demonstration, we stop
at the review stage to focus on schema discovery and document modeling.
Production migrations may require additional schema refinement, particularly
for complex many-to-many relationships and application-specific business logic.
Key Features
MongoDB
Relational Migrator offers several capabilities that simplify
relational-to-document migrations:
- Automatic schema discovery
- Intelligent document
modeling
- Embedded document
recommendations
- Visual mapping interface
- JSON schema generation
- Pre-migration compatibility
analysis
- Snapshot and continuous
migration modes
- Migration validation
- Support for PostgreSQL,
MySQL, SQL Server, and Oracle
Benefits
Organizations
adopting MongoDB can benefit from:
- Reduced migration effort
- Faster modernization
projects
- Better document schema
design
- Visual relationship mapping
- Lower migration risk
- Easier validation before
deployment
- Improved understanding of
MongoDB best practices
Best Practices
To
achieve successful migrations:
- Review the recommended
document model before migrating.
- Understand application query
patterns when deciding between embedding and referencing.
- Test migrations using a
representative subset of production data.
- Validate generated JSON
documents before moving to production.
- Review many-to-many
relationships carefully, as they may require manual refinement.
- Perform application-level
testing after migration to ensure expected behavior.
Conclusion
MongoDB
Relational Migrator significantly simplifies one of the most challenging
aspects of database modernization: transforming normalized relational schemas
into optimized MongoDB document models.
Its
combination of automated schema discovery, visual mapping, pre-migration
analysis, and JSON document generation helps developers understand how
relational data can be represented in MongoDB before executing a migration.
While
complex scenarios such as many-to-many relationships or advanced business logic
may still require manual adjustments, the tool dramatically reduces the time
and effort involved in planning and validating a migration.
For organizations considering a move from PostgreSQL, MySQL, SQL Server, or Oracle to MongoDB, MongoDB Relational Migrator is an excellent starting point for evaluating schema transformations and accelerating modernization initiatives.









0 Comments