I've got an application. It writes its object graphs to Mongo. For certain collections, we'd like to normalise the data and mirror it onto a relational database (SQL Server or SQLite).
I was thinking the best way to do this would be by a MapReduce job on the collections. Would this be the right way? Is this possible? We're running on Windows if that makes a difference.
Update
What I'm looking for is just general guidance about whether a MapReduce job in JavaScript is the best way to approach this. Let's say I have an object with two fields, FirstName
and LastName
. When I write this to a collection, I need a row in a relational database (which has two columns FirstName
and LastName
).
Of course, I could write this to the SQL table in my application at the point where I write to the collection. But I thought that perhaps a better place to do it would be IN the database. This would allow me to shape the data, if needed, before writing it to the relational database.
Now that I've elaborated a bit, I can see a few other questions which I didn't explicitly ask but which are pertinent. Can the JavaScript that runs the MapReduce job even access anything outside of Mongo? Is it sand-boxed? And would doing this as a MapReduce job impact write performance (I'm guessing not, but IANAE, hence the question(s)).