MySQL Database Consolidation

Job ID: 39271363

Budget: ₹1,500 – ₹12,500 INR

Database Merging Requirement
Project Title: Merging 9 MySQL Databases into a Single Consolidated Database
Project Overview:
We have 8 MySQL 5.6.17 databases that share the same schema (same tables and columns) but contain different data. The primary keys (IDs) start from 1 in each database, which will cause conflicts when merging.
The goal is to merge all 8 databases into a single database (merged_db) while ensuring:
No data is lost


All primary keys are unique


Foreign key relationships remain intact


Performance is optimized for future scalability



Scope of Work:
Database Analysis:


Structure of tables and columns is identical across all databases.


Primary keys (ID) start from 1 in each database, requiring modification.


Foreign key relationships need to be maintained.


New Consolidated Database (merged_db) Creation:


Create a new database (merged_db) with the same schema.


Ensure all necessary indexes and constraints are included.


Data Migration & Handling Primary Key Conflicts:


Since all databases have overlapping IDs, use an ID offset strategy:


Assign a unique range to each database.


Example:


db1: IDs 1 - 100000


db2: IDs 100001 - 200000


db3: IDs 200001 - 300000


And so on...


Update foreign key references to reflect new IDs.


Insert data into merged_db while shifting IDs dynamically.


Automation of Data Transfer:


Write a script (PHP/Python) to:

Read data from each source database.

Modify primary key values dynamically.

Insert data into merged_db.

Testing & Validation:

Verify that all records from all 8 databases are successfully migrated.

Ensure foreign key relationships remain valid.

Check for performance bottlenecks and optimize indexes if needed.

Backup & Deployment:

Backup all 8 source databases before merging.

Provide a final dump of merged_db after successful completion.


Technical Requirements:

MySQL Version
5.6.17

Number of Databases
8

Database Schema
Identical across all 8 DBs

Primary Key Handling
Offset-based ID shifting

Foreign Keys
Must be preserved

Automation
Scripted solution in PHP or Python

Deliverables:
New consolidated database (merged_db)

Script to automate data merging

Final SQL dump of merged_db

Documentation of the merging process