Today’s data has vast needs in terms of storage as well as retrieval. The rigid table structure provided by relational databases are no longer sufficient to meet the growing data demands, and this is the main reason 30% of MongoDB projects are all about migration from these legacy relational systems to the modern and flexible MongoDB data platform that transforms your data to be more useful for querying, analysis, visualization and much more.
Need for modernizing legacy applications
In today’s business landscape, speed is of utmost importance and data is the core to any business. Losing even an inch of data could lead to huge losses. Traditional databases do not have the full capabilities to preserve and retrieve all the data due to their rigid structure, difficulty to adapt to changes, and time required to take new changes to market. Some important challenges that legacy databases face are:
- Delay in publishing application to the market - Due to rigid schemas, monolithic apps, or even waterfall model of development, it may take more time to build certain features or the whole application
- Downtime - Even a small upgrade or change could need a server restart, which could cause significant business loss, today’s applications need 24/7 presence across the globe
- Cost - Legacy systems usually require costly infrastructure, hardware and other resources that may not even be supported or require additional cost for support. Further, any additional workload may add to the existing cost of resources
- Unstructured data - A lot of data that is generated today is unstructured - for example, IoT data, social media and machine learning applications all generate different types of data that may be completely new. With a rigid data model, the data might be lost or untapped.
Legacy modernization solves all the above problems and much more! It not only migrates your data from the legacy system to the new MongoDB developer data platform, but also gets your application to
- align with simpler application architectures (like microservices) from the legacy monolith,
- move infrastructure to the cloud from physical servers and hardware resources,
- follow processes like Agile and DevOps as opposed to waterfall.
Application Modernization Factory
MongoDB provides a set of iterative processes (known as Application Modernization Factory) that can help your organization in modernizing application portfolios. These include thorough application assessment followed by the standard delivery methodology using best practices.
MongoDB experts work with you to check your application’s feasibility to use it with MongoDB and the best way to perform the migration.
MongoDB supports various ETL tools like Apache Kafka, and also provides data migration tools like the MongoDB BI Connector, mongomirror and mongoimport that help with migration from legacy systems to MongoDB. A more convenient way of migration is through the relational migrator, that simplifies the process of migration and eliminates the need for manual intervention.
Why MongoDB Relational Migrator
Relational Migrator enables you to take full advantage of MongoDB’s flexible model. It addresses the most common migration and data modeling challenges and can also assist you in updating your existing code to work with MongoDB. You also get intelligent schema analysis and modeling recommendations. The relational migrator automatically analyzes the legacy system and executes the data migration without any downtime at all. The tool supports Oracle, MySQL, MS SQL Server and PostgreSQL. This way, most of the risks involved are completely taken care of by this simple tool.
How relational migrator works
The first step is to download the tool from the MongoDB Relational Migrator download page. After installing, open the relational migrator tool and you will see a screen like the below:
You can see that MongoDB relational migrator shows 3 options:
- Connect to live database - you can connect your relational databases, like Oracle, MySQL, MS SQL Server and PostgreSQL.
- Load schema from a file - you can upload any SQL file having Data Definition Language (create/alter/drop schema, grant/revoke/analyze roles and privileges) statements.
- Use a sample schema - If you want to learn more about Relational Migrator, you can start with a sample schema.
Once you click on the “Create sample” option, you can follow through the steps. MongoDB already has a northwind database whose public tables are viewable. You can select the tables you want to transform and migrate. Let us see what happens when we select a few tables (let’s say customers and employee_territories):
MongoDB shows you various options on how you want to name your collections and fields (like camel-case, title-case) and the initial mappings. Finally you can name the project and click on ‘Done’. You can then see all the mappings and the schema created automatically for you by the relational migrator tool:
You can use the Code Generation tab to generate application code or use the query converter to convert your SQL queries into MongoDB queries (MQL).
On the Data Migration tab, you can create a sync job to migrate the sample project into MongoDB.
Now, let us say you also want to add the employee table to the schema. You can click on the Manage button and add it in just one click. Once done, you can add the mappings, by migrating the table into a collection as new documents, embedded arrays or embedded documents.
Further reading resources
In this article, we learnt about the need for migration from legacy systems and how MongoDB provides one of the best alternatives for building modern applications with rich database features. To learn more about how to migrate your database using a relational migrator, you can refer to easy migration with MongoDB relational migrator and the white paper on how MongoDB can help you transform your legacy apps into modern applications.