PowerExchange for MongoDB User Guide

PowerExchange for MongoDB User Guide

Example: Data Migration to MongoDB

Example: Data Migration to MongoDB

A media store uses flat files with comma-separated values to store details of the store inventory with a unique flat file for each type of media. The file FF_Music_Collection stores the details of audio CDs and FF_Movie_Collection stores the details of movie DVDs and Blu-ray disks.
You want to use a MongoDB database to store all inventory details. Create a mapping to extract data from FF_Music_Collection and FF_Movie_Collection and load it to the MongoDB collection MDB_Inventory.
Create a mapping with two flat file source definitions to read the records from the flat files. Include the MongoDB target definition to write data from the flat files. Use a Join transformation to join the columns before writing to the corresponding MongoDB columns.
The following figure shows the mapping:
The mapping that contains two flat file data sources, a join transformation, and a MongoDB target.
FF_Music_Data Source
The following table describes the contents of FF_Music_Collection:
Field
Datatype
Name
String
Artist
String
Units
Integer
Cost Price
Integer
Sale Price
Integer
FF_Movies_Data Source
The following table describes the contents of FF_Movies_Collection:
Field
Datatype
Name
String
Director
String
Artist1
String
Artist2
String
Type
String
Units
Integer
Cost Price
Integer
Sale Price
Integer
MDB_Inventory Target
The collection MDB_Inventory stores audio CD information and movies disks information.
The following sample document shows an audio CD document in the collection:
{ "Name" : "Happy Birthday", "Artist" : ["Patty Hill", "Mildred J. Hill", "Derek Underhill"], "Units" : 1000, "Price" : { "Cost_Price" : 1, "Sale_Price" : 3 } }
The following sample document shows a movie disk document in the collection:
{ "Name" : "City Lights", "Type" : "Blu-ray", "Director" : "Charlie Chaplin" "Artist" : ["Charle Chaplin", "Mildred J. Hill", "Derek Underhill"], "Units" : 1000, "Price" : { "Cost_Price" : 10, "Sale_Price" : 15 } }
The following figure shows the data object that you import in the
Developer tool
:
The data object for the MongoDB collection that stores the data from the flat file sources.

0 COMMENTS

We’d like to hear from you!