In the process of replacing commercial software with open-source alternatives, IT departments of companies and organizations often encounter the need for database conversion. Database conversion involves converting data, meta-objects, stored procedures, functions and triggers from one database management system (DBMS) format to another. This procedure often requires modifying the application layer, mapping data types, and adjusting SQL statements.
There are several reasons why organizations opt for database conversion:
- Cost: Commercial DBMS often come with expensive license fees and strict licensing terms. Open-source DBMS alternatives, on the other hand, offer similar capabilities and are free to install and use.
- Customization: Open-source DBMS comes with a wide range of extensions, frameworks, and APIs for flexible database management and development. Most of them are available for free.
- Flexibility: Open-source DBMS can easily integrate with Database-as-a-Service (DBaaS) providers like AWS, eliminating the risk of being locked into a specific vendor.
However, migrating a database between two DBMS with different SQL syntax and data types can be a challenging and time-consuming process. The best practices of database conversion include the following steps:
- Assessment: The main goal of this phase is to evaluate the compatibility of the source and target systems and to analyze the required modifications of architecture.
- Migration of schemas and meta-objects: This phase focuses on transferring the database schemas and related meta-objects, such as tables, views, indexes, and constraints, to the target DBMS.
- Functional and performance testing: Once the schema migration is complete, thorough testing is essential to ensure that the migrated database functions correctly and meets the required performance standards.
- Data Migration: The data transfer from the source database to the target includes data types mapping, handling data conversions, and ensuring data integrity.
Migration of meta-objects
During the phase of migrating schemas and meta-objects, table definitions, columns, data types, constraints, indexes, and relationships between tables are typically converted. The database meta-objects are examined to determine the necessary changes for the target environment. It’s crucial to test migration scripts on a development or staging environment to ensure they accurately reflect the desired table definitions and do not cause any data loss or inconsistencies. Once the migration scripts have been successfully tested, they are executed on the target database to create the desired table definitions, constraints, indexes, and relationships.
After the migration is completed, all table definitions and associated meta-objects are verified in the target environment to ensure they match the desired structure and meet the requirements of the applications.
For data migration, there are various methods available in the market: snapshot, parallel snapshot, and change data replication (CDR).
The snapshot method migrates all the data from the source DBMS to the target DBMS in a single operation. The drawback of this approach is preventing write operations on the source database during the snapshot process. Also, it may cause significant overhead for the DBMS due to bulk data reading.
The parallel snapshot method splits the data into chunks and takes snapshots of each part simultaneously. Although this technique reduces the total time of the snapshots generation and the required downtime window for the source database, some downtime is still required.
Alternatively, change data replication methods can be used for database conversion. This technique involves monitoring and recording real-time changes from the source database and applying them to the target database. There are two generic implementations of CDR: trigger-based and transaction log.
The first approach creates triggers on insert, update and delete that capture the changes and propagate them to the target database. The second approach relies on an analysis of the transaction log to discover all changes in the source database.
Unlike snapshot and parallel snapshot methods, CDR approaches to database conversion reduce the overhead on the DBMS and network traffic by capturing and applying only the changed data instead of reading and transferring bulk data.